Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def __init__(
interim_results=True,
aligned_transcript="word",
offline_recognize=False,
diarization=is_given(speaker_labels) and speaker_labels is True,
),
)
if model == "u3-pro":
Expand Down Expand Up @@ -500,6 +501,10 @@ def _process_stream_event(self, data: dict) -> None:
transcript = data.get("transcript", "")
language = LanguageCode(data.get("language_code", "en"))

# Extract speaker label for diarization (returns "A", "B", ... or "UNKNOWN")
speaker_label = data.get("speaker_label")
speaker_id = speaker_label if speaker_label and speaker_label != "UNKNOWN" else None

# transcript (final) and words (interim) are cumulative
# utterance (preflight) is chunk based
start_time: float = 0
Expand Down Expand Up @@ -535,6 +540,7 @@ def _process_stream_event(self, data: dict) -> None:
end_time=end_time,
words=timed_words,
confidence=confidence,
speaker_id=speaker_id,
)
],
)
Expand Down Expand Up @@ -565,6 +571,7 @@ def _process_stream_event(self, data: dict) -> None:
end_time=end_time,
words=utterance_words,
confidence=utterance_confidence,
speaker_id=speaker_id,
)
],
)
Expand All @@ -584,6 +591,7 @@ def _process_stream_event(self, data: dict) -> None:
end_time=end_time,
words=timed_words,
confidence=confidence,
speaker_id=speaker_id,
)
],
)
Expand Down