Skip to content

fix(nvidia): set speaker_id on each word when diarization is enabled - #8918

Draft
AnandaRaju742 wants to merge 1 commit into
livekit:mainfrom
AnandaRaju742:fix/nvidia-stt-word-speaker-id
Draft

AnandaRaju742 wants to merge 1 commit into
livekit:mainfrom
AnandaRaju742:fix/nvidia-stt-word-speaker-id

Conversation

@AnandaRaju742

@AnandaRaju742 AnandaRaju742 commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

With enable_diarization=True, the NVIDIA Speech (Riva) server labels every recognized word with an integer speaker_tag. The plugin read these tags only to pick one label for the whole final transcript. It then dropped them. SpeechData.words came back with speaker_id=None on every word, even when two people spoke inside one final result.

This PR keeps the tag on each word, using the existing TimedString.speaker_id field.

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:

segment speaker_id: S1
word speaker_ids  : Hello=None, there=None, hi=None, how=None, are=None, you=None

After:

segment speaker_id: S1
word speaker_ids  : Hello=S0, there=S0, hi=S1, how=S1, are=S1, you=S1

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, set TimedString.speaker_id to "S<speaker_tag>" for each word of a final result when diarization is enabled.
  • stt.py: document the behavior in the enable_diarization docstring.
  • tests/test_plugin_nvidia.py: add test_stt_speaker_id_on_words.

Compatibility

  • SpeechData.speaker_id is unchanged. It still holds the label shared by most words, in the same "S<n>" form as before.
  • Interim results are unchanged. Their word labels stay None, as before.
  • With diarization off, nothing changes.
  • No new argument, no new class, no core change. TimedString.speaker_id already exists. LiveKit Inference and the Mistral plugin already fill it for each word.

Not in this PR

Splitting one final result into one FINAL_TRANSCRIPT event 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

  • New test test_stt_speaker_id_on_words covers three cases: final result with diarization (words S1, S1, S2 and segment S1), interim result, and diarization off. The final case fails on main without 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 check and ruff format --check: passed.
  • mypy on stt.py: 14 errors on main and 14 on this branch. This PR adds none. I ran mypy on this file only, with a minimal environment. I did not run the full make check.
  • The tests use fake Riva responses. I did not test against a live NVIDIA Speech server.

Checklist

  • ruff check and ruff format pass
  • Test module keeps its unit marker. The new test makes no network call.
  • Docstring updated
  • No change to CHANGELOG.md, version files, or package manifests
  • Full make check (not run)
  • Live server test (not run)

@CLAassistant

CLAassistant commented Dec 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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
AnandaRaju742 force-pushed the fix/nvidia-stt-word-speaker-id branch from 7cc466a to 61a8923 Compare December 4, 2026 08:32

This branch has not been deployed

No deployments
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.

2 participants