Fish Audio Avatar
Use a Fish Audio voice instead of Gemini Live. Fish Audio is text-to-speech only, so this is a different pipeline shape than Gemini Live or OpenAI Realtime — see "How it works" below.
Fish Audio does not do speech understanding or live conversation — it only turns text into audio. Setting a project's speech engine to Fish Audio 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
Unlike Gemini Live's single bidirectional session, a Fish Audio turn is two server calls chained together:
- 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 the Fish Audio TTS API (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 Fish Audio API key
# .env — server-side only, never sent to the browser
FISH_AUDIO_API_KEY=your-fish-audio-api-key
Step 2 — Set the engine and voice for a project
In the dashboard, open your project → Settings tab and set Speech engine to Fish Audio, then paste your voice's reference 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": "fish-audio",
"voice": "your-fish-audio-reference-id"
}
Find your reference IDs in the Fish Audio dashboard under your saved/cloned voice models.
Saving is rejected with a clear error if FISH_AUDIO_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 raw PCM16 little-endian mono audio at 24kHz directly from Fish Audio, 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 synthesizeFishAudio() (endpoint, headers, and body fields like reference_id/format) was verified directly against the official fish-audio-sdk npm package's source, not guessed from docs — if a future Fish Audio 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) | Fish Audio | |
|---|---|---|
| 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/clone in your Fish Audio account |
| Latency | Lowest — one streaming session | Higher — two sequential HTTP calls per turn |