Repository navigation
fix(tts): avoid synthesizing and streaming TTS audio for text-only listeners (#1411) - #1412
VineetRamshetty wants to merge 2 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Reviewer's GuideData structuresTrack text-only TTS sockets separately from audio-capable sockets so listener counts can distinguish whether synthesis is needed.
APIExpose the audio preference on TTS subscriptions and bundle delivery so clients can opt into text-only bundles and audio-only delivery can be targeted.
Uses of the APIUse audio-subscriber demand to decide whether to synthesize, recheck demand before synthesis, and restrict Stage-2 audio broadcasts to audio subscribers.
UIPass the listener’s audio preference through TTS connection and reconnect logic, and avoid creating audio playback resources or prompts for text-only listeners.
DocumentationDocument the optional text-only TTS subscription and its effect on synthesis and PCM delivery.
TestsAdd coverage for text-only and audio subscribers, synthesis gating and rechecks, the WebSocket query option, frontend reconnect behavior, and compatible test doubles.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Description
Stops VoxBento from running TTS synthesis (
Deepgram Aura,ElevenLabs v4, orSupertonic ONNX) and broadcasting Stage-2 24 kHz PCM binary frames when no listener has requested TTS audio — covering both caption/overlay-only audiences (/ws/captions/, OBS/overlay/) and/listener/{event_slug}attendees who enable translated captions with AI Voice toggled off.Related Issue
Closes #1411
Changes Made
portal/websockets/manager.py,portal/websockets/handlers.py):TTSConnectionManager._roomsasdict[str, set[WebSocket]]for backward compatibility and addedself._audio_roomswithhas_audio_listeners(...)andwants_audio: bool = Trueinadd()/remove().audio_only: bool = Falsetobroadcast_bundle(...)so Stage-2 audio frames (and TTS-stage synthesis errors) are sent only toself._audio_roomssubscribers.ws_ttsto parse optional?audio=0(wants_audio = websocket.query_params.get("audio", "1") != "0"), keeping existing/ws/tts/clients as audio subscribers by default.portal/translations/worker.py):_build_language_tasksandrecheck_audienceto setsynthesize_audiofromtts_manager.has_audio_listeners(...)rather thanaudience == LISTENERS.tts_manager.has_audio_listeners(...)immediately before callingportal.tts.worker.synthesize(...)so mid-flight disconnects skip synthesis and mid-flight joins still synthesize.broadcast_bundle(...)calls withaudio_only=True.portal/static/js/listener-event.js,website/docs/api/overview.mdx,website/docs/how-it-works.mdx):wantsTtsAudiointostartTtsWs→openTtsWs, appending?audio=0when text-only (preserving?audio=0across reconnects).AudioContext/AudioSchedulerinitialization and gatedttsPlaybackBlocked()onttsAudioDesiredso text-only listeners do not allocate anAudioContextor see spurious "Tap to listen" prompts.?audio=0on/ws/tts/{room_id}/{language_code}/{booth_id}.tests/test_tts_framing.py,tests/test_translation_pipeline.py,tests/test_fastapi_app.py,tests/test_listener_event.js):?audio=0/?audio=1subscribers, Stage-2 isolation, caption-only skippingsynthesize(), dynamic mid-flight rechecks, and lazyAudioContext+?audio=0reconnects.Testing
node tests/test_listener_event.js— 99 passed, 0 faileduv run ruff check portal/websockets/manager.py portal/websockets/handlers.py portal/translations/worker.py tests/test_tts_framing.py tests/test_translation_pipeline.py tests/test_fastapi_app.py— All checks passeduv run pytest tests/test_fastapi_app.py -k "ws_tts" -v— 15 passed (177 deselected)uv run pytest tests/test_tts_framing.py tests/test_translation_pipeline.py -k "not test_language_independence" -v— 27 passed (1 deselected;test_language_independencehit a pre-existingsqlite3.OperationalError: no such table: transcript_translationswhen run aftertest_tts_framing.py)Tested locally
Existing tests pass
Added/updated tests (if applicable)
Screencast
Screen.Recording.2026-11-28.085843.mp4
Checklist
Additional Notes
dev.?audio=0composes cleanly with?replay=1in feat(listener): resilient broadcast pause/resume, delay sync, and opt-in replay #1392.Created with Gemini in Antigravity.
Summary by Sourcery
Gate TTS synthesis and audio delivery on active listener audio demand while retaining translated text for text-only audiences.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: