APTalkmoji ElevenLabs Avatar
Docs›SDK Introduction

ElevenLabs Avatar

Use an ElevenLabs voice instead of Gemini Live. Unlike Fish Audio and Cartesia, Talkmoji calls ElevenLabs' "with-timestamps" endpoint — a lesser-known variant of its TTS API that also returns the start time of every character in the synthesized audio — and uses that to drive real, precisely-timed lip-sync instead of falling back to amplitude-only mouth movement.

⚠️

Like Fish Audio and Cartesia, ElevenLabs does not do speech understanding or live conversation — it only turns text into audio. Setting a project's speech engine to ElevenLabs 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

  1. The visitor's message goes to the existing POST /embed/:publicId/ask endpoint, which runs the normal Gemini-backed knowledge-base RAG pipeline and returns reply text — completely unchanged by which voice engine is selected.
  2. The widget calls POST /embed/:publicId/speak with that text. The server calls ElevenLabs' /v1/text-to-speech/:voice_id/with-timestamps endpoint (backend/services/tts.js), which returns both the synthesized audio and an alignment object: parallel arrays of every character in the text, its start time, and its end time, all in seconds.
  3. The browser calls avatar.speakPCMWithAlignment(audio, text, alignment) (public/lipsync-sdk.js) instead of the plain speakPCM() used for Fish Audio/Cartesia. This reuses the exact same multilingual G2P (grapheme-to-phoneme) → Azure-viseme engine already built for Gemini Live's text-only lip-sync estimation, then time-warps that estimate's relative pacing onto the real per-character timestamps (warpScheduleToAlignment()) — so pauses, emphasis, and speaking-rate changes in the actual audio are reflected in the mouth movement, not just guessed at.
💡

Why this is more accurate than Gemini Live's own lip-sync: Gemini Live's API gives no phoneme or word timing at all, so its estimate can only be scaled to fit each audio chunk's overall duration. ElevenLabs' per-character timestamps give a real, non-uniform pacing signal to anchor to — no new phoneme engine was needed to take advantage of it.

Configuration

Step 1 — Add your ElevenLabs API key

# .env — server-side only, never sent to the browser
ELEVENLABS_API_KEY=your-elevenlabs-api-key
# Optional override:
ELEVENLABS_MODEL_ID=eleven_multilingual_v2

Step 2 — Set the engine and voice for a project

In the dashboard, open your project → Settings tab and set Speech engine to ElevenLabs, then paste your 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": "elevenlabs",
  "voice": "21m00Tcm4TlvDq8ikWAM"
}

Popular voice IDs

Voice IDNameDescription
21m00Tcm4TlvDq8ikWAMRachelCalm, American female. Great for support bots.
AZnzlk1XvdvUeBnXmlldDomiStrong, American female. Good for confident agents.
EXAVITQu4vr4xnSDxMaLBellaSoft, American female. Warm and friendly.
ErXwobaYiN019PkySvjVAntoniWell-rounded, American male.
VR6AewLTigWG4xSOukaGArnoldCrisp, American male. Great for product demos.

Browse all available voices in the ElevenLabs voice library.

ℹ️

Saving is rejected with a clear error if ELEVENLABS_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=pcm_24000 directly, 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 synthesizeElevenLabs() (endpoint path, header names, the alignment field names) was verified directly against the official @elevenlabs/elevenlabs-js npm package's source, not guessed from docs — if a future ElevenLabs 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, Fish Audio, or Cartesia

Gemini LiveElevenLabsFish Audio / Cartesia
Speech understandingNative, liveNone — text from /askNone — text from /ask
Vision (image upload)YesNot supportedNot supported
Lip-sync accuracyText-estimated, scaled to chunk durationText-estimated, warped onto real per-character timestamps — the most accurate of the three TTS-only enginesAmplitude-only (no timing data available)
LatencyLowest — one streaming sessionHigher — two sequential HTTP calls per turn