Skip to content

fix(sarvam): align TTS validation with the Bulbul API - #6864

Open
uuzzrm wants to merge 2 commits into
livekit:mainfrom
uuzzrm:fix/sarvam-tts-validation
Open

fix(sarvam): align TTS validation with the Bulbul API#6864
uuzzrm wants to merge 2 commits into
livekit:mainfrom
uuzzrm:fix/sarvam-tts-validation

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #6774

The sarvam plugin's TTS option validation drifted from what the Bulbul
endpoints actually accept, so three combos that should work were being
rejected up front and three that can't work were only failing once the
request hit the API.

Speakers. bulbul:v3 has 37 documented voices. Nine were missing from
the compatibility map (anand, tarun, sunny, mani, gokul, vijay, mohit,
rehan, soham), while amelia/sophia were listed even though the API
rejects them with "Speaker is not recognized". Verified against
https://docs.sarvam.ai/api/getting-started/models/bulbul and the REST
reference.

Sample rates. 32/44.1/48 kHz are REST-only (bulbul:v3). stream()
now raises up front for those instead of erroring mid-session over the
socket, and synthesize() rejects them for non-v3 models.

pace. Now validated per model in both the constructor and
update_options: 0.5-2.0 for v3/v3-beta, 0.3-3.0 for v2.

Added tests/test_tts_validation.py (unit category) covering the speaker
map, pace ranges, and the streaming/REST sample-rate gates. uv run pytest --unit livekit-plugins/livekit-plugins-sarvam passes and
ruff check / ruff format are clean on the changed files.

The plugin's option validation drifted from what the Sarvam endpoints actually accept:

- bulbul:v3 ships 37 documented speakers; nine were missing from the compatibility map (anand, tarun, sunny, mani, gokul, vijay, mohit, rehan, soham) while amelia/sophia were listed even though the API rejects them.
- 32/44.1/48 kHz sample rates are REST-only (bulbul:v3); streaming now fails fast with a clear error instead of erroring mid-session, and synthesize() rejects them for non-v3 models.
- pace is validated per model: 0.5-2.0 for v3/v3-beta, 0.3-3.0 for v2, in both the constructor and update_options.

Adds unit tests covering the speaker map, pace ranges, and the streaming/REST sample-rate gates.
devin-ai-integration[bot]

This comment was marked as resolved.

@uuzzrm

uuzzrm commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the stale-pace finding in 94829cc: update_options now re-validates the stored pace against the new model's range when only the model changes, clamping with a warning (same policy as pitch) instead of letting an out-of-range value reach the API. Added regression coverage for the clamp and for the in-range case.

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.

sarvam: TTS parameter validation diverges from the live Bulbul API

1 participant