After upgrading to the latest livekit version the ...
# ask-ai
f
After upgrading to the latest livekit version the elevenlabs TTS node has started using different voices (sounds like defaults) rather than the ones I'm setting via
elevenlabs.TTS(_voice_id_="...")
or via:
Copy code
self.tts.update_options(
            voice_id=new_voice_id,
            voice_settings=VoiceSettings(
                speed=new_voice_speed,
                stability=stability,
                similarity_boost=boost,
            )
        )
Did this route change in the later updates, is there a different way to select voices with elevenlabs in the latest code?
t
Thanks for reaching out, Hayden. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about the ElevenLabs TTS voice selection changing after your LiveKit upgrade. Two things up front: setting
voice_id
at construction and calling
update_options(voice_id=..., voice_settings=...)
are still the supported ways to choose a voice. That behavior did not change in the latest LiveKit versions. Please check these likely causes and confirm details so I can help further: • Confirm the
voice_id
you pass is valid for your ElevenLabs account (paste one example
voice_id
you’re using). • Confirm your
ELEVEN_API_KEY
is set and correct in the environment used by your running service. • Verify the installed plugin/package version (run
pip show livekit-plugins-elevenlabs
or check
requirements.txt
) and share the version. The plugin referenced in docs is around
~=1.2
. • If you call
update_options
, ensure it runs before synthesis starts and is invoked on the same TTS instance used for generation. Share the small code path where you call
update_options
+ the subsequent synth call. • Restart the session/process to avoid stale cached clients after upgrade; tell me if you already restarted. • If possible, log or print the active TTS options just before synth to confirm the
voice_id
and
voice_settings
values being used. Share the
voice_id
, plugin version, and a short snippet showing how/when you call
update_options
and synthesize — I’ll review and suggest the exact fix. Sources: ElevenLabs TTS plugin guide | LiveKit Docs
f
The codepath for this hasn't changed - only the livekit version upgrade. elevenlabs plugin is on 1.3.5
t
Thanks — you're on 1.3.5 and the codepath didn't change. Let’s narrow this down. Please provide: • The exact
voice_id
and
model
you’re passing (one example). • The LiveKit Agents SDK version (run
pip show livekit-agents
or show
requirements.txt
entry). • A short snippet (5–10 lines) showing where you construct the ElevenLabs TTS, call
update_options
, and then trigger synthesis. • A few lines of agent logs around TTS initialization and the synth call (include warnings/errors). Quick checks to run now: • Confirm
ELEVEN_API_KEY
is set in the runtime environment (print a masked value to logs). • Restart the process after the upgrade to avoid cached clients. • Make a direct curl/request to ElevenLabs TTS with the same key and voice_id to verify the voice works outside LiveKit. Send the above items and I’ll review the config/logs and recommend the exact fix. Sources: ElevenLabs TTS plugin guide | LiveKit Docs | ElevenLabs STT plugin guide | LiveKit docs | Models | LiveKit Docs
f
elevenlabs.TTS(_voice_id_="EXAVITQu4vr4xnSDxMaL", model="eleven_flash_v2_5") livekit agent: 1.3.5 Logger:
Copy code
logger.info(f"TTS settings: voice_id={self.tts._opts.voice_id}, model={self.tts._opts.model}, "
                    f"speed={new_voice_speed}, target_lang={target_language_id}")
Result:
Copy code
TTS settings: voice_id=x5IDPSl4ZUbhosMmVFTk, model=eleven_flash_v2_5, speed=1.0
The voice setting doesn't match
t
Thanks — you gave exactly the info I needed. The logs show the plugin is ignoring the
voice_id
you passed and using a different voice. Use
voice
(not
voice_id
) when constructing the ElevenLabs TTS; the plugin expects
voice="EXAVITQu4vr4xnSDxMaL"
. Please update the init to:
Copy code
tts = elevenlabs.TTS(
    voice="EXAVITQu4vr4xnSDxMaL",
    model="eleven_flash_v2_5"
)
Then log
tts._opts.voice
(not
voice_id
) to confirm. If you still see the wrong voice after that, share the post-change log lines and I’ll help trace whether something else (env var, override, or cached instance) is replacing the setting. Sources: ElevenLabs TTS plugin guide | LiveKit Docs
f
TypeError: TTS.__init__() got an unexpected keyword argument 'voice'
t
Thanks — I see the TypeError after trying
voice
, so let's fix this cleanly. You're on
livekit-plugins-elevenlabs
1.3.5 and Python expects
voice_id
. Your original init using
voice_id="EXAVITQu4vr4xnSDxMaL"
was correct. The problem is the runtime shows a different
voice_id
(x5ID...), meaning something is overwriting the option after construction. Please do the following and share the outputs: 1. Confirm the exact import and instantiation lines (paste 5–10 lines around where you create
self.tts
). 2. Show the
update_options
call (the snippet you posted earlier) and where you call the synth method. 3. Add these debug prints/logs and paste their output: ◦ Immediately after construction: logger.info(f"after init: voice_id={self.tts._opts.voice_id}, model={self.tts._opts.model}") • Immediately after any
update_options
call: logger.info(f"after update: voice_id={self.tts._opts.voice_id}, voice_settings={self.tts._opts.voice_settings}") • Right before synth: logger.info(f"before synth: voice_id={self.tts._opts.voice_id}") 1. Confirm
ELEVEN_API_KEY
at runtime (log a masked prefix, e.g. first 4 chars). 2. Confirm there are no other TTS constructions in your process (search for
elevenlabs.TTS(
). With those snippets/logs I'll pinpoint whether an override, a secondary initialization, or a timing/caching issue is replacing your
voice_id
. Sources: ElevenLabs TTS plugin guide | LiveKit Docs
f
This is a different issue. After further debugging it looks like the voice is not respecting the voice which is being set at all. The voice sounds completely different than any of the ones I can log
t
Thanks — I hear you: the TTS is not using any voice you log and sounds completely different. Let’s isolate whether ElevenLabs, the model, or LiveKit is producing that fallback voice. Please provide these quick items so I can pinpoint the cause: • The exact code that constructs the TTS and triggers synthesis (5–15 lines, including imports and AgentSession if used). • The three debug log lines requested earlier (after init, after update_options, before synth) and their outputs. • Confirm how
ELEVEN_API_KEY
is set at runtime (env/.env) and paste a masked sample (first 4 chars + ). • Tell me if you’re running LiveKit Agents locally or calling LiveKit Inference (managed service). • One short audio sample filename or timestamped log entry of a synth run that produced the wrong voice. Immediate checks you can run now: • Make a direct ElevenLabs API call with the same
voice_id
+ model to confirm ElevenLabs returns the expected voice outside LiveKit. • Try synthesizing with a different known voice_id (e.g., a default listed in your ElevenLabs account) to see if any voice change takes effect. Send the above outputs and I’ll trace whether the plugin is overriding the voice, the model enforces a different voice, or authentication/quotas are causing a fallback. Sources: ElevenLabs TTS plugin guide | LiveKit Docs | ElevenLabs TTS | LiveKit Docs
f
It is not the voice setting but it appears to be the playback sample rate is off - the voice sounds higher pitched and faster
t
Thanks — you’ve narrowed it to a sample-rate mismatch (higher pitch + faster). I’ll help confirm where the mismatch is. Please provide these quick items/logs so I can pinpoint the mismatch: • Are you running ElevenLabs TTS locally in LiveKit Agents or sending TTS via LiveKit Inference (managed gateway)? • The 10–15 lines of code that read the ElevenLabs audio response and create/publish the AudioSource/Track. • A log of the synthesized audio’s sample rate (from the plugin/HTTP response) — e.g., print the response headers or audio metadata. • A log of the AudioSource/Track publish options (the
sample_rate
used when constructing the source). • One audio-frame debug print immediately before publish and immediately after receive (show
audio_frame.sample_rate
,
channel_count
,
bytes_per_sample
, and frame length). • livekit-agents version and confirmation plugin is 1.3.5, ElevenLabs model name (you said
eleven_flash_v2_5
), and how
ELEVEN_API_KEY
is provided. Quick tests to run now (optional but helpful): • Synthesize directly with ElevenLabs (curl/SDK) and play locally to confirm original file’s pitch/speed and sample rate. • Publish a known-good WAV with explicit sample rate (16k/24k) through your pipeline to see if it reproduces correctly. Send the code snippets and the three sample-rate logs (synth output, publish options, audio_frame before publish) and I’ll tell you exactly which component is resampling or misconfigured and how to fix it. Sources: Camera & microphone | LiveKit docs | Agent session | LiveKit docs | Processing raw media tracks | LiveKit docs | Agent speech and audio | LiveKit docs | client-sdk-unity | livekit/livekit_composite | DeepWiki
f
Are there any options or configurations that need to be set to tell livekit how to handle the audio returned from elevenlabs tts? Does it automatically resample?
t
Short answer: LiveKit does not automatically resample ElevenLabs TTS audio. You must ensure the TTS output sample rate matches the sample rate your audio source/track expects (or resample manually before publishing). What to check and actions to fix: • Set ElevenLabs TTS output sample rate to match your pipeline:
Copy code
tts = elevenlabs.TTS(voice_id="EXAVITQu4vr4xnSDxMaL", model="eleven_flash_v2_5", sample_rate=24000)
• Ensure your AudioSource/Track is created with the same
sample_rate
and
num_channels
. • If the plugin output rate differs, resample the audio before feeding it to LiveKit (libraries: librosa, pydub, ffmpeg). • Add debug logs showing the synthesized audio metadata (sample_rate, channels) and the
audio_frame.sample_rate
just before publish to confirm consistency. If you want, paste: • the code that creates/publishes the AudioSource, • the TTS response metadata (sample rate), • and a short audio-frame log, and I’ll point to the exact line to change. Sources: Camera & microphone | LiveKit docs | ElevenLabs TTS plugin guide | LiveKit Docs | Processing raw media tracks | LiveKit docs