Skip to content

fix(voice): flush zero-duration transcription segments - #2389

Open
kokoite wants to merge 2 commits into
livekit:mainfrom
kokoite:fix/flush-zero-duration-transcription
Open

fix(voice): flush zero-duration transcription segments#2389
kokoite wants to merge 2 commits into
livekit:mainfrom
kokoite:fix/flush-zero-duration-transcription

Conversation

@kokoite

@kokoite kokoite commented Aug 31, 2026

Copy link
Copy Markdown

Description

Fixes #2383.

TranscriptionSynchronizer waits for playback to start before forwarding paced text. When TTS completes with non-empty text but produces zero audio frames, no playback-started event can occur, so the segment keeps its transcript indefinitely.

This change completes a segment only when both text and audio inputs have ended and its pushed audio duration is zero. It releases the existing text-forwarding task and rotates the completed segment. Segments containing audio continue to use the existing playback-gated pacing path.

Related duplicate report: #2384.

Changes Made

  • Complete and rotate zero-duration segments regardless of whether text or audio input ends first.
  • Add deterministic regression coverage for zero-frame transcript delivery and the following audible segment.
  • Preserve playback gating for segments that contain audio.
  • Add a patch changeset for @livekit/agents.

Pre-Review Checklist

  • Build passes: Build, lint, typecheck, tests, formatting, and throws checks pass locally.
  • AI-generated code reviewed: Reviewed the complete base-to-head diff, naming, lifecycle races, and scope.
  • Changes explained: The zero-duration state transition and preserved audio path are documented above.
  • Scope appropriate: Changes are limited to the transcription synchronizer, its tests, and a changeset.
  • Video demo: Not applicable; this internal edge case is reproduced and verified deterministically without external services.

Testing

  • Automated tests added.
  • pnpm test agents --silent — 141 files passed; 2,321 tests passed and 5 skipped.
  • pnpm exec turbo run build --filter=@livekit/agents... --output-logs=errors-only — passed.
  • pnpm exec turbo lint typecheck throws:check --output-logs=errors-only — 74 tasks passed.
  • pnpm format:check — passed.
  • Built-code reproduction delivered silent reply with zero pending rotated segments.
  • restaurant_agent.ts and realtime_agent.ts: not applicable for this focused internal lifecycle fix.

Additional Notes

pnpm api:check reports existing declaration drift on current main. The same failure reproduces outside this branch, and its generated differences do not include the transcription synchronizer or any symbol changed here. This PR does not change public API.


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@kokoite
kokoite requested a review from a team as a code owner August 31, 2026 12:23
@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5c29f96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

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.

TranscriptionSynchronizer should flush text for zero-duration audio segments

1 participant