Repository navigation
fix(room_io): drop the previous participant's track when the transcription output switches participants - #7531
Conversation
…ption output switches participants
…s participant on switch
|
This is valid. Clearing the track alone leaves the open segment to be finalized with the new participant's identity and track, or skipped when the new participant has no microphone. Fixed in 34e01c4. |
| ) -> None: | ||
| # finalize the open segment for the participant it was captured for, before the | ||
| # identity and track are replaced | ||
| self.flush() |
There was a problem hiding this comment.
🔴 Stream final loses the previous speaker
When set_participant switches during an open user transcript, the legacy final targets the old speaker but the stream final targets the new one. The stream output changes identity before flushing and resets its stored text, leaving that final empty.
Learn more
The composite transcription output sends each user transcript through both legacy RTC transcription and a text stream. A participant switch now schedules the legacy final before changing its identity, but the stream implementation assigns the new identity before its own flush and resets _latest_text immediately after scheduling the final task. For non-delta user transcripts, that task reads the reset text and current identity when it runs, so it sends an empty final for the incoming speaker. The None branch also skips flushing the old stream entirely here.
Example: User A has an interim transcript hello. Switching to B finalizes hello for A via the legacy output; the stream output sends a final for B with an empty payload instead of finalizing A's stream.
Recommended fix: Update _ParticipantStreamTranscriptionOutput.set_participant to flush before replacing the identity, including when unsetting it. Snapshot the identity, track, segment ID, and latest text needed by _flush_task before resetting state; pass these snapshots into the asynchronous task.
Was this helpful? React with 👍 or 👎 to provide feedback.
fix(room_io): drop the previous participant's track when the transcription output switches participants
Description
_ParticipantLegacyTranscriptionOutput.set_participantsearches for the newparticipant's microphone track only when
_track_idis empty. After a switch, thefield still held the previous participant's track, so the search was skipped and
transcriptions were published with the new identity and the old
track_sid.set_participantnow clears_track_idfirst, so the track is always resolved forthe participant that is being linked. The stream-based output already behaves this
way.
Testing
test_legacy_transcription_output_follows_the_new_participants_trackintests/test_room_io.py._output.pythe test fails ('TR_a' == 'TR_b'). With it,uv run pytest --unit -q tests/test_room_io.pypasses (45 tests).ruff checkandruff format --checkpass.Related issues
tests/test_room_io.py; the two changes do not overlap in code.