fix: keep websocket TTS word timestamps inside their turn#4102
Open
namanbansal013 wants to merge 2 commits intopipecat-ai:mainfrom
Open
fix: keep websocket TTS word timestamps inside their turn#4102namanbansal013 wants to merge 2 commits intopipecat-ai:mainfrom
namanbansal013 wants to merge 2 commits intopipecat-ai:mainfrom
Conversation
added 2 commits
March 22, 2026 15:49
Drop stale websocket TTS word timestamp events after interruptions and clamp any backward PTS values so interrupted speech cannot leak into later turns or reorder transcripts.
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.
Fixes #1361
Related to #1355
Summary
Repro
The downstream repro that motivated this fix interrupted a Cartesia response immediately after playback began:
That single stale word was later flushed into the next turn and reordered transcript output. The same interruption-driven transcript ordering bug is already described upstream in #1361 and #1355, just with ElevenLabs instead of Cartesia.
Test plan
uv run ruff check .uv run pytest tests/test_tts_word_timestamp_interruptions.py tests/test_tts_frame_ordering.pyuv run pytest984 passed, 88 skipped, 592 warnings in 104.34s