fix(sarvam): request word timestamps on the REST recognize path - #6935
Open
devbm7 wants to merge 2 commits into
Open
fix(sarvam): request word timestamps on the REST recognize path#6935devbm7 wants to merge 2 commits into
devbm7 wants to merge 2 commits into
Conversation
REST recognize() never sent Sarvam's with_timestamps field, so the timestamps block the response parser already handles never came back and start_time/end_time silently fell back to a buffer-duration estimate. Now requested whenever the model isn't on the legacy translate endpoint. Sarvam removed server-side support for input_audio_codec in January 2026 (the API now negotiates it automatically); the plugin now warns when it's passed and no longer sends or acts on it, while keeping the parameter in both signatures for backward compatibility.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 944b3b4e42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The legacy streaming audio message schema documents `encoding` as a required per-chunk field, and Sarvam's PCM formats (which is what _process_audio always sends — raw int16 samples, never a real WAV container) still require explicit codec declaration even after the January 2026 change that made codec auto-detection the default for self-describing formats (wav, mp3, etc). Deprecating input_audio_codec was based on an incomplete reading of that changelog entry and would have made every stream mislabel its audio as audio/wav regardless of what the caller actually sends.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_recognize_implnever sent Sarvam'swith_timestampsfield, so thetimestampsblock the response parser already handles never came back from the API —start_time/end_timesilently fell back to a buffer-duration estimate instead of real word timing. Now requested whenever the model isn't on the legacy/speech-to-text-translateendpoint (gated via a new_model_supports_timestampshelper, mirroring the existing_model_supports_mode/_model_supports_vad_paramspattern).(An earlier revision of this PR also deprecated
input_audio_codec, based on an incomplete reading of Sarvam's changelog. That's been reverted: Sarvam's docs confirm PCM formats — which is what this plugin's streaming path always sends — still require explicit codec declaration even after codec auto-detection became the default for self-describing formats like wav/mp3. Soinput_audio_codecis left untouched.)Test plan
ruff format --check/ruff checkcleanmypystrict cleanuv run pytest livekit-plugins/livekit-plugins-sarvam/tests/— newtest_timestamps_model_gating.pypasses; existingtest_speech_timing.pyunaffected. (Note:test_language_probability.pyhas 16 pre-existing failures onmainunrelated to this change — anAttributeErroron_pending_eosin theSpeechStream.__new__test-bypass pattern — not touched by this PR.)