Skip to content

fix: stop realtime TTS after final message - #821

Open
tylergibbs1 wants to merge 1 commit into
elevenlabs:mainfrom
tylergibbs1:fix/569-realtime-final-message
Open

tylergibbs1 wants to merge 1 commit into
elevenlabs:mainfrom
tylergibbs1:fix/569-realtime-final-message

Conversation

@tylergibbs1

@tylergibbs1 tylergibbs1 commented Jul 24, 2026 •

Copy link
Copy Markdown

summary

  • stop the realtime TTS drain loop when the server sends isFinal
  • yield audio from the final frame before closing the generator
  • add a regression test that fails on any extra socket read

This changes only realtime_tts.py and tests, both of which are hand maintained according to .fernignore.

testing

  • Python compilation for the changed source and test files
  • focused standard library harness using the actual edited method
  • git diff check

Pytest and Ruff are not installed in the local workspace, so the repository CI will run those checks.

Fixes #569


Note

Low Risk
Small, targeted change to hand-maintained realtime streaming logic with a focused unit test; no auth or data-model impact.

Overview
Fixes convert_realtime so the post-input WebSocket drain loop exits when the API marks the stream complete with isFinal, instead of reading until the connection closes.

Audio on the final frame is still decoded and yielded before the generator stops, which avoids hanging or extra recv calls after generation ends.

Adds test_convert_realtime_stops_after_final_message to assert a single read and that no further socket reads occur after the final message.

Reviewed by Cursor Bugbot for commit 82c5263. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

Potential Realtime TTS Ending Delay

1 participant