Repository navigation
fix(nvidia): set speaker_id on each word when diarization is enabled - #8918
Draft
AnandaRaju742 wants to merge 1 commit into
Draft
AnandaRaju742 wants to merge 1 commit into
AnandaRaju742 wants to merge 1 commit into
Conversation
With enable_diarization=True the Riva server returns a speaker_tag for
every word. The plugin used the tags only to pick one majority label for
the whole final transcript and dropped them from SpeechData.words.
Set TimedString.speaker_id ("S<tag>") on each word of a final result.
SpeechData.speaker_id keeps the majority label, so existing users see no
change. Interim results and runs without diarization are unchanged.
Add test_stt_speaker_id_on_words (final, interim, diarization disabled).
AnandaRaju742
force-pushed
the
fix/nvidia-stt-word-speaker-id
branch
from
December 4, 2026 08:32
7cc466a to
61a8923
Compare
This branch has not been deployed
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
With
enable_diarization=True, the NVIDIA Speech (Riva) server labels every recognized word with an integerspeaker_tag. The plugin read these tags only to pick one label for the whole final transcript. It then dropped them.SpeechData.wordscame back withspeaker_id=Noneon every word, even when two people spoke inside one final result.This PR keeps the tag on each word, using the existing
TimedString.speaker_idfield.Behavior
Input: one final result with six words. The server tagged the first two words speaker 0 and the last four words speaker 1.
Before:
After:
An application can now split a final result into speaker runs from the word labels. Before, the information was lost inside the plugin.
Changes
stt.py: in_combine_result_alternatives, setTimedString.speaker_idto"S<speaker_tag>"for each word of a final result when diarization is enabled.stt.py: document the behavior in theenable_diarizationdocstring.tests/test_plugin_nvidia.py: addtest_stt_speaker_id_on_words.Compatibility
SpeechData.speaker_idis unchanged. It still holds the label shared by most words, in the same"S<n>"form as before.None, as before.TimedString.speaker_idalready exists. LiveKit Inference and the Mistral plugin already fill it for each word.Not in this PR
Splitting one final result into one
FINAL_TRANSCRIPTevent per speaker. That changes what applications receive, so it needs its own discussion. This PR only stops the plugin from discarding data that the server already sends.Testing
test_stt_speaker_id_on_wordscovers three cases: final result with diarization (words S1, S1, S2 and segment S1), interim result, and diarization off. The final case fails onmainwithout this change.pytest tests/test_plugin_nvidia.py tests/test_multi_speaker_adapter.py: 68 passed.pytest tests/test_plugin_nvidia.py --unit: 49 passed.ruff checkandruff format --check: passed.mypyonstt.py: 14 errors onmainand 14 on this branch. This PR adds none. I ran mypy on this file only, with a minimal environment. I did not run the fullmake check.Checklist
ruff checkandruff formatpassunitmarker. The new test makes no network call.CHANGELOG.md, version files, or package manifestsmake check(not run)