Cartesia Sonic Avatar
Use a Cartesia Sonic voice instead of Gemini Live. Like Fish Audio, Cartesia is text-to-speech only — see "How it works" below for how that changes the pipeline.
Cartesia does not do speech understanding or live conversation — it only turns text into audio. Setting a project's speech engine to Cartesia changes how it answers: no native vision (image upload is unavailable), and microphone input is transcribed by the browser's own Web Speech API (Chrome/Edge) instead of being streamed to the provider.
How it works
- The visitor's message goes to the existing
POST /embed/:publicId/askendpoint, which runs the normal Gemini-backed knowledge-base RAG pipeline and returns reply text — completely unchanged by which voice engine is selected. - The widget then calls
POST /embed/:publicId/speakwith that text. The server calls Cartesia's/tts/bytesendpoint (backend/services/tts.js) and returns raw PCM16 audio, base64-encoded. - The browser plays that audio through the avatar's existing amplitude-driven lip-sync pipeline (
avatar.speakPCM()inpublic/lipsync-sdk.js) — the same code path that drives the mouth when no phoneme timing is available from Gemini.
Configuration
Step 1 — Add your Cartesia API key
# .env — server-side only, never sent to the browser
CARTESIA_API_KEY=your-cartesia-api-key
# Optional overrides:
CARTESIA_MODEL_ID=sonic-3.5
CARTESIA_VERSION=2026-08-14
Step 2 — Set the engine and voice for a project
In the dashboard, open your project → Settings tab and set Speech engine to Cartesia Sonic, then paste your Cartesia voice ID into the field that appears. You can also do this via the API:
PATCH /api/projects/:id
Content-Type: application/json
Authorization: Bearer YOUR_JWT
{
"voiceEngine": "cartesia",
"voice": "your-cartesia-voice-id"
}
Find your voice IDs in the Cartesia dashboard's voice library, or clone your own.
Saving is rejected with a clear error if CARTESIA_API_KEY isn't set on the server yet — this is checked at save time so a broken engine choice can't silently ship to visitors.
Output format
backend/services/tts.js requests output_format: { container: "raw", encoding: "pcm_s16le", sample_rate: 24000 } directly from Cartesia, matching the sample rate the avatar's playback pipeline already expects (no client-side resampling). As a defensive fallback, a response wrapped in a WAV container is detected and unwrapped automatically, in case your account's API response shape differs slightly from what's documented.
The request shape in synthesizeCartesia() (auth header, model IDs, the voice field, the cartesia-version header) was verified directly against the official @cartesia/cartesia-js npm package's source, not guessed from docs — if a future Cartesia API change breaks it, failures are logged server-side with the response body to make it quick to diagnose and re-verify the same way.
When to use this instead of Gemini Live
| Gemini Live (default) | Cartesia Sonic | |
|---|---|---|
| Speech understanding | Native, live | None — text comes from /ask, mic uses the browser's Web Speech API |
| Vision (image upload) | Yes | Not supported |
| Voice selection | 30 built-in voices | Any voice in your Cartesia account |
| Latency | Lowest — one streaming session | Cartesia's synthesis is very fast, but this is still two sequential HTTP calls per turn |