why does it give me this error in livekit when i c...
# ask-ai
p
why does it give me this error in livekit when i change to a dutch voice of elevenlabs but not in english ones. {"level": "WARNING", "name": "livekit.agents", "message": "failed to synthesize speech, retrying in 0.1s\nTraceback (most recent call last):\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/tts/tts.py\", line 383, in _main_task\n await self._run(output_emitter)\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/plugins/elevenlabs/tts.py\", line 440, in _run\n raise e\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/plugins/elevenlabs/tts.py\", line 435, in _run\n await waiter\nlivekit.agents._exceptions.APIStatusError: connection closed (status_code=-1, request_id=None, body=None, retryable=True)", "tts": "livekit.plugins.elevenlabs.tts.TTS", "attempt": 1, "streamed": true, "pid": 713, "job_id": "AJ_46Vz7WLVKUD8", "room_id": "RM_7xfrzkn89Kgg", "timestamp": "2025-12-01T194431.382251+00:00"} {"level": "ERROR", "name": "livekit.agents", "message": "Error in _tts_inference_task\nTraceback (most recent call last):\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/tts/tts.py\", line 556, in __anext__\n val = await self._event_aiter.__anext__()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nStopAsyncIteration\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/utils/log.py\", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/appuser/.local/lib/python3.11/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/voice/generation.py\", line 241, in _tts_inference_task\n async for audio_frame in tts_node:\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/voice/agent.py\", line 446, in tts_node\n async for ev in stream:\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/tts/tts.py\", line 559, in __anext__\n raise exc # noqa: B904\n ^^^^^^^^^\n File \"/home/appuser/.local/lib/python3.11/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/tts/tts.py\", line 383, in _main_task\n await self._run(output_emitter)\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/plugins/elevenlabs/tts.py\", line 440, in _run\n raise e\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/plugins/elevenlabs/tts.py\", line 435, in _run\n await waiter\nlivekit.agents._exceptions.APIStatusError: connection closed (status_code=-1, request_id=None, body=None, retryable=True)", "pid": 713, "job_id": "AJ_46Vz7WLVKUD8", "room_id": "RM_7xfrzkn89Kgg", "timestamp": "2025-12-01T194427.501283+00:00"}
t
Thanks for reaching out, Vaneeza. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking at the error you shared about ElevenLabs Dutch voices causing an APIStatusError while English voices work. I can help troubleshoot — a few quick clarifying questions and checks will narrow this down: 1. Which exact
voice_id
and
model
are you using for the Dutch voice? 2. Do you set
language="nl"
in the ElevenLabs TTS config (example:
model="eleven_multilingual_v2"
,
language="nl"
)? 3. Are you using LiveKit’s ElevenLabs plugin with your own ElevenLabs API key, or LiveKit Inference (managed)? 4. Can you reproduce the failure calling ElevenLabs directly (outside LiveKit) with the same
voice_id
and model? 5. Does the failure always happen immediately, or is it intermittent? Any network/firewall restrictions on outbound connections? What you can try right now: • Verify the Dutch
voice_id
via ElevenLabs’ list_voices endpoint and confirm it supports Dutch and the
eleven_multilingual_v2
model. • Explicitly set
language="nl"
and
model="eleven_multilingual_v2"
in your LiveKit TTS config. • Test the same request directly against ElevenLabs to see if the connection closes there as well (this isolates LiveKit vs ElevenLabs). • If it’s intermittent, try a few retries and check network latency or firewall rules (the error shows connection closed / status_code=-1 which indicates a dropped/closed connection). Send me the
voice_id
,
model
, and whether direct ElevenLabs calls succeed and I’ll suggest the next steps. Sources: ElevenLabs TTS plugin guide | LiveKit Docs | ElevenLabs TTS | LiveKit Docs
p
I’ve already tried almost all of these steps. I’m using the Dutch voice_id h6uBOiAjLKklte8hdYio, and I’ve tested it with multiple models, including eleven_turbo_v2_5, eleven_flash_v2_5, and eleven_multilingual_v2, with language="nl" explicitly set. I’m using LiveKit’s ElevenLabs plugin with my own ElevenLabs API key, not LiveKit Inference. When I call ElevenLabs directly (REST + streaming endpoint), everything works perfectly with the same voice_id and model. The failure happens immediately only inside LiveKit — never when calling ElevenLabs directly — which makes it unlikely to be a firewall or network issue. So the issue only appears in LiveKit’s ElevenLabs streaming integration, not in ElevenLabs itself. Happy to provide any additional details if needed.
t
Thanks — you’ve given exactly the right details. I agree this is isolated to LiveKit’s ElevenLabs streaming integration (since direct ElevenLabs calls succeed). Here’s a concise plan and targeted checks to get this resolved quickly. What I’m responding to: the LiveKit ElevenLabs plugin fails immediately with APIStatusError for Dutch voice_id
h6uBOiAjLKklte8hdYio
while the same voice works when called directly. Immediate checks (do these now): 1. Re-run LiveKit with the minimal TTS config to rule out extra params:
Copy code
tts = elevenlabs.TTS(
  voice_id="h6uBOiAjLKklte8hdYio",
  model="eleven_multilingual_v2",
  language="nl"
)
1. Remove any
voice_settings
(stability/similarity) or SSML — use defaults only. 2. Enable debug logging in the LiveKit agent so we capture the WebSocket handshake and exact plugin request/response (this will show whether LiveKit sends different parameters or endpoint). Things this will rule out: • malformed/unsupported voice settings sent by LiveKit • parameter mismatch (language/model/voice) during the plugin WebSocket handshake • immediate client-side rejection before the ElevenLabs API responds If debug logs still show
connection closed (status_code=-1)
immediately, please paste (or confirm) the following from the LiveKit debug output: • The exact outgoing ElevenLabs request JSON or the logged plugin init payload • Any plugin-level headers or endpoint URL shown in logs • The first 2–3 debug lines around the WebSocket connect attempt Next steps I’ll take once you provide those logs: • Inspect the plugin init payload for parameter mismatches or unsupported fields. • Verify LiveKit’s streaming call uses the same ElevenLabs endpoint/mode as your direct test. • Suggest a configuration change (or a temporary fallback to non-streaming TTS) depending on what the logs show. Would you like me to analyze the debug logs now? Sources: ElevenLabs TTS plugin guide | LiveKit Docs | ElevenLabs TTS | LiveKit Docs | Events and error handling | LiveKit docs
p
1. youre asking to Remove any
voice_settings
(stability/similarity) or SSML — use defaults only. should i remove speed too?
t
Yes — remove
speed
as well. Use the absolute minimal config (voice_id, model, language) with no
voice_settings
(stability, similarity, speed) and no SSML so we can isolate whether LiveKit is altering or rejecting any parameter. If that fixes it, re-add settings one at a time (speed last) and share which setting reproduces the failure.
p
{"level": "ERROR", "name": "livekit.agents", "message": "unhandled exception while running the job task\nTraceback (most recent call last):\n File \"/home/appuser/.local/lib/python3.11/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/appuser/.local/lib/python3.11/site-packages/livekit/agents/ipc/job_proc_lazy_main.py\", line 275, in _traceable_entrypoint\n await self._job_entrypoint_fnc(job_ctx)\n File \"/home/appuser/main.py\", line 1121, in entrypoint\n tts_provider = create_tts_provider()\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/home/appuser/main.py\", line 893, in create_tts_provider\n voice_settings = elevenlabs.VoiceSettings(\n ^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: VoiceSettings.__init__() missing 2 required positional arguments: 'stability' and 'similarity_boost'", "pid": 714, "job_id": "AJ_hmyLszJTywMQ", "room_id": "RM_JwLYwjgQ8o9m", "timestamp": "2025-12-01T205645.461499+00:00"} when i do this: voice_settings = elevenlabs.VoiceSettings( speed=elevenlabs_speed # 0.25-4.0, speech rate )
t
Thanks — I’m responding to the new TypeError you hit when you tried to remove voice settings but only supplied
speed
. Cause:
elevenlabs.VoiceSettings
requires
stability
and
similarity_boost
positional args in its constructor, so calling it with only
speed=
raises the TypeError. What to do now: • Don’t construct
VoiceSettings
at all. Use the minimal TTS config with no
voice_settings
object:
Copy code
tts = elevenlabs.TTS(
  voice_id="h6uBOiAjLKklte8hdYio",
  model="eleven_multilingual_v2",
  language="nl"
)
• If your code must call
VoiceSettings
, pass valid defaults for the required fields plus
speed
. Example:
Copy code
voice_settings = elevenlabs.VoiceSettings(
  stability=0.5,
  similarity_boost=0.75,
  speed=1.0
)
(use values you prefer; start with 0.5/0.75/1.0 to test) Next step: Try running LiveKit with the minimal config (no
voice_settings
). If it still fails, paste the debug lines around the WebSocket connect and the plugin init payload and I’ll inspect them.
p
dutch voices are working with minimal config, now i want to adjust speed too. how can i do that?
t
Great — glad minimal config works. To change speed without reintroducing the constructor error, include all required
VoiceSettings
fields (stability and similarity_boost) when you set
speed
. Example safe defaults you can tweak:
Copy code
voice_settings = elevenlabs.VoiceSettings(
  stability=0.5,
  similarity_boost=0.75,
  speed=1.25   # 0.25 - 4.0, increase >1.0 to speed up, <1.0 to slow down
)

tts = elevenlabs.TTS(
  voice_id="h6uBOiAjLKklte8hdYio",
  model="eleven_multilingual_v2",
  language="nl",
  voice_settings=voice_settings
)
Recommended approach: • Start with conservative values (e.g.,
stability=0.5
,
similarity_boost=0.75
) and adjust
speed
gradually. • If you hit the original connection error again, remove
voice_settings
and re-add only
speed
last to confirm which field triggers the issue. Want me to suggest specific values for faster or slower speech for Dutch?