Skip to content

fix(elevenlabs): restore chunk_length_schedule in WS init payload#5006

Open
IanSteno wants to merge 2 commits intolivekit:mainfrom
aisteno:fix/elevenlabs-chunk-length-schedule
Open

fix(elevenlabs): restore chunk_length_schedule in WS init payload#5006
IanSteno wants to merge 2 commits intolivekit:mainfrom
aisteno:fix/elevenlabs-chunk-length-schedule

Conversation

@IanSteno
Copy link
Contributor

@IanSteno IanSteno commented Mar 4, 2026

Summary

  • restore generation_config.chunk_length_schedule in ElevenLabs multi-context websocket init packets
  • keep existing default auto_mode=True for normal usage, but default to auto_mode=False when chunk_length_schedule is explicitly provided so the schedule is not implicitly disabled
  • refactor init packet construction into a helper for deterministic unit coverage

Why

chunk_length_schedule has been accepted/stored by the plugin but not forwarded in current multi-context websocket flow, making it a no-op in practice.

Changes

  • livekit/plugins/elevenlabs/tts.py
    • add _build_context_init_packet(...) to include:
      • text
      • voice_settings
      • context_id
      • generation_config.chunk_length_schedule when provided
      • pronunciation_dictionary_locators when provided
    • use this helper in _Connection._send_loop() init path
    • set constructor defaulting to auto_mode = not is_given(chunk_length_schedule) when auto_mode is not explicitly provided

Tests

Added tests/test_plugin_elevenlabs_tts.py covering:

  • auto_mode defaults with and without explicit chunk schedule
  • explicit auto_mode override precedence
  • init packet includes generation_config when schedule is set
  • init packet omits generation_config when schedule is unset
  • pronunciation dictionary locators are preserved in init packet

Run locally:

  • uv run pytest tests/test_plugin_elevenlabs_tts.py -q
  • uv run ruff check livekit-plugins/livekit-plugins-elevenlabs/livekit/plugins/elevenlabs/tts.py tests/test_plugin_elevenlabs_tts.py

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant