Echonic.-.Main.Preview.mp4
The open-source ElevenLabs alternative.
AI-powered text-to-speech and voice cloning application built with Next.js 16 and the Chatterbox model.
- About Echonic
- Key Features
- Architecture & Tech Stack
- Deployment & Monitoring
- Getting Started
- Monetization & Billing
- Contributing
- License
Echonic is an open-source, full-stack alternative to platforms like ElevenLabs, designed from the ground up for teams and developers who need a bride variety of voice synthesis within a collaborative environment.
While there are many closed-source AI voice tools available today, some organizations require complete control over their audio infrastructure, predictable usage-based B2B billing, and the ability to integrate custom voice cloning directly into their workflows. Echonic bridges this gap by combining quite powerful, open-source AI (the Chatterbox model) with modern web architecture.
It provides a platform where users can instantly generate lifelike audio, clone custom voices directly within their browser, and centralize all their billing and media in one unified organization.
Echonic.-.TTS.mp4
The central page featuring text synthesis.
Echonic.-.explore.voices.mp4
Discover prebuilt system voices alongside custom, user-generated options.
Echonic.-.voice.cloining.mp4
The intuitive Voice Cloning modal allowing immediate browser recording or audio file upload.
- Text-to-speech (TTS) generation: Leverages the open-source Chatterbox model to convert written text into natural audio. You control the output with adjustable creativity and expression parameters, seamlessly outputting standard formats for immediate playback or download.
- Voice cloning: Upload an existing audio file or record yourself directly from your browser using the native audio capturing interface (10s minimum). Echonic instantly maps the frequency and tonality of the sample to create a reusable voice model.
- Organizations: Built on a fully multi-tenant architecture to support collaborative workflows using Better Auth. Users can create teams and securely share custom-cloned voices and generation history logs across the entire organization.
- Pay-as-you-go billing: Secure, usage-based B2B billing strictly tied to your organization using Polar. Start generating using checkouts and dedicated customer portals. Echonic features real-time backend metering, tracking the exact character count of every generation to ensure fair pricing.
- Robust audio infrastructure: Audio generations and custom voice samples are securely uploaded to and streamed directly from Cloudflare R2 object storage. You can also browse and replay past generations dynamically through a rich WaveSurfer.js waveform audio player.
- Modern app experience: A highly responsive, mobile-first UI built on the server-rendered Next.js 16 App Router. Designed with React, Tailwind CSS, and Shadcn UI, it delivers an accessible user experience complete with bottom drawers, compact controls, and adaptive layouts.
Echonic relies on the following architecture separating the user-facing web server, the billing provider, and the distributed storage.
The core backend orchestrating Better Auth, tRPC + Drizzle ORM, Cloudflare R2 Storage, and Polar billing.
Echonic leverages a cutting-edge, type-safe ecosystem to guarantee smooth DX.
- Framework: Next.js 16 (App Router, React 19)
- API Network: tRPC
- Database ORM: Drizzle ORM
- Authentication: Better Auth
- Styling & Components: Tailwind CSS, TanStack, Shadcn UI
- Hardware Integration: Web Audio API & WaveSurfer.js
Every API operation is strictly typed end-to-end via tRPC, except voice creation, which is a Route Handler (/api/voices/create) because it accepts a file upload. Both entry points enforce the same rules:
- The session from Better Auth determines the current Organization (
orgId). Without an active Organization the request is rejected (orgProcedurethrowsFORBIDDEN; the Route Handler returns401). TheorgIdnever comes from client input. - Before any paid work, the Organization's subscription is checked against Polar in real time. If there is no active subscription, the request is rejected with
SUBSCRIPTION_REQUIRED(403). For text-to-speech this check lives in the generate workflow; for voice creation it lives in the Route Handler. - If validated, the operation processes the audio, and the usage event (character count or voice creation) is ingested to Polar from the server. This ensures zero manipulation of character limits from the frontend.
Echonic is designed to be completely self-hosted. You will need:
- A PostgreSQL database – Any managed Postgres instance.
- Better Auth – For native, customizable authentication and multi-tenant organizational structure.
- Cloudflare R2 – For secure audio storage (S3-compatible, generous free tier!).
- Modal – For serverless GPU inference of the TTS engine (pay-per-second deployment).
- Polar – For B2B metered billing (you can use the Sandbox mode with card
4242 4242 4242 4242for frictionless local testing).
- The Next.js remote API validates the payload and proxies a request to the self-hosted Chatterbox AI server running on Modal.
- The GPU leverages the tensor model to generate the resulting
.wavaudio. - Instead of streaming the heavy audio payload back through the Node.js server, the model saves the asset directly to Cloudflare R2 and returns a reference ID.
- The frontend client receives a highly-optimized, secure Signed URL linked directly to R2 for rapid playback across edge locations.
You can easily deploy the Next.js application to any Node.js host (like Railway, Vercel, or a custom VPS).
- I decided to deploy this project on Railway because we have no cold starts, no surprise serverless bills, no AWS wrapper adding markup. They run on their own hardware, and we can use their CI/CD pipeline to deploy the application automatically. Every PR can get its own preview deployment, so nothing hits production untested.
- I use BetterAuth Infrastructure as well as Sentry for error monitoring. These services allow me to monitor the application's performance, logs and generally provide a much better developer experience while working.
- CodeRabbit for code reviews. It can generate PRs, suggest improvements, and generally help with the development process, catching bugs and security vulnerabilities before they hit production.
Ensure you have the following installed on your local machine:
- Bun
- PostgreSQL (local installation or a hosted provider)
git clone https://github.com/Pr1ncep5/echonic.git
cd echonic
bun installCreate a .env file in the root directory. You must configure the following key services to run the project fully:
- Better Auth:
BETTER_AUTH_SECRET,BETTER_AUTH_URL - PostgreSQL Database connection:
DATABASE_URL - Cloudflare R2:
R2_ACCOUNT_ID,R2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY,R2_BUCKET_NAME - Chatterbox:
CHATTERBOX_API_KEY,CHATTERBOX_API_URL - Polar Billing:
POLAR_ACCESS_TOKEN,POLAR_PRODUCT_ID - Sentry Logging:
SENTRY_AUTH_TOKEN,SENTRY_DSN - OAuth Providers (Optional): GitHub and Google Client IDs/Secrets
(Refer to src/lib/env.ts for the exact Zod schema and validation rules).
Echonic relies on a serverless GPU to generate speech and clone voices using the Chatterbox model.
You must deploy the Chatterbox SDK to a GPU provider (e.g., via Modal) and copy your resulting endpoint URL into your .env as CHATTERBOX_API_URL.
Once your GPU endpoint is live, synchronize the strictly typed API schema for the frontend:
bun run sync-apiTo securely meter organizational usage, log into your Polar dashboard and configure the event rules:
-
Create two Meters:
- Voice Creation: Filter Name equals
voice_creation(Aggregation: Count) - Text-to-Speech Characters: Filter Name equals
tts_generation(Aggregation: Sum overcharacters)
- Voice Creation: Filter Name equals
-
Create a Product (Recurring Subscription). Under Price Type, inject your two metered prices:
- Text-to-Speech Characters: Set an Amount per unit (e.g.,
€0.003) - Voice Creation: Set an Amount per unit (e.g.,
€0.20)
- Text-to-Speech Characters: Set an Amount per unit (e.g.,
-
Copy the resulting Product ID into your
.envasPOLAR_PRODUCT_ID.
Push the Drizzle ORM schema to your target PostgreSQL database:
bunx drizzle-kit pushNext, run the seed script to populate the prebuilt Chatterbox system voices:
bun run db:seedbun devThe application will now be available at http://localhost:3000.
Echonic is engineered as a fully functional B2B SaaS, featuring a robust pay-as-you-go billing architecture powered securely by Polar.
Instead of locking organizations into rigid monthly tiers that they might never fully utilize, the platform strictly meters actual usage via serverless event ingestion:
- TTS Generation: Organizations are charged exactly based on the volume of characters they synthesize into actual audio (€0.003 per character).
- Voice Cloning: A nominal flat rate of €0.20 is incurred whenever an organization trains and uploads a new custom voice model.
Because Echonic is built on Better Auth's multi-tenant architecture, Polar Customers are directly mapped to the Organization instead of individual users. This means an entire creative department can collaboratively generate audio and clone voices, seamlessly pooling their usage onto a single automated company invoice.
At any time, members can navigate to their organization settings and launch the Polar Customer Portal to view real-time usage meters, manage payment methods, and download receipts—all without needing to build a custom billing UI.
Any contributions you make to Echonic are highly appreciated!
If you have a workflow improvement, a bug fix, or a new feature idea (e.g. integrating a new AI model), please fork the repo and create a pull request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/amazingFeature) - Commit your Changes (
git commit -m 'Add some amazingFeature') - Push to the Branch (
git push origin feature/amazingFeature) - Open a Pull Request
You can also simply open an Issue with the tag "enhancement" to discuss an idea before building it ^^
This project is licensed under the MIT License.
- A special thanks to Code with Antonio for the original idea and layout inspiration behind this application. While Echonic has been re-engineered with a different technology stack (using Better Auth and Drizzle ORM) and features custom functionality, the core foundation and aesthetic inspiration stem entirely from his excellent educational content.
- Chatterbox TTS by Resemble AI - the open-source zero-shot voice cloning model powering speech generation
- Modal - serverless GPU deployment example and voice sample pack
