Carl Taylor
3a4aa2f8e6
feat(gateway): streaming TTS adapter contract and consumer ( #60671 )
...
Add an opt-in streaming-audio adapter seam to BasePlatformAdapter so
voice-capable gateway platforms (LiveKit, Discord voice, future adapters)
can consume LLM output as streaming PCM audio before the full response
completes, dropping perceived voice latency from ~2-3.5s to ~500-800ms.
Adapter contract (gateway/platforms/base.py):
- AudioFormat dataclass: declared sample_rate, channels, sample_width
- StreamingTTSHandle: opaque handle with audible/aborted flags
- supports_streaming_tts / begin_streaming_tts / write_streaming_tts
/ finish_streaming_tts / abort_streaming_tts
- All default to unsupported/no-op so existing adapters are source-compatible
- Per-turn _streaming_tts_completed_chats set suppresses duplicate whole-file
auto-TTS when streaming succeeded; cleared after turn completion
Gateway consumer (gateway/streaming_tts_consumer.py):
- StreamingTTSConsumer: bridges sync agent deltas to async adapter audio sink
- Uses existing SentenceChunker (no competing parser)
- Thread-safe bounded queue; on_delta never blocks the agent worker thread
- Resolves configured streaming provider via resolve_streaming_provider()
- Serialises clause playback in order; flushes tail on completion
- Pre-audio failure: completed=False (falls back to whole-file TTS)
- Post-audio failure: completed=True, partial=True (no replay from start)
- Abort is idempotent; late chunks silently dropped
- Per-turn state isolated across concurrent chats
Gateway integration (gateway/run.py):
- message_type parameter threaded through _run_agent -> _run_agent_inner
- StreamingTTSConsumer created when voice input + auto-TTS + provider active
- Delta callback teed to both text stream consumer and TTS consumer
- TTS-only delta callback installed when text streaming is off
- finish() called from executor; wait_complete() in async context after
- Barge-in aborts the consumer at all three interrupt detection points
- Runner-level _send_voice_reply suppressed when streaming TTS completed
Tests (tests/gateway/test_streaming_tts_consumer.py):
- 15 focused tests: adapter defaults, lifecycle, ordered chunks,
unsupported/No-streamer fallback, abort idempotency, late-chunk drop,
pre/post-audio failure, concurrent-turn isolation, think-block suppression,
queue backpressure
Does not touch desktop/TUI code or add config flags. Plugin TTS provider
stream() metadata gap (#47896 ) is explicitly out of scope — built-in
ElevenLabs/OpenAI PCM streamers are the first consumers.
Refs: #60671 , #47896
2026-07-28 22:31:40 -07:00
..
2026-07-27 14:24:14 +10:00
2026-07-28 11:56:37 -07:00
2026-07-13 23:26:10 +05:30
2026-07-19 03:49:29 -07:00
2026-06-28 02:41:36 -07:00
2026-07-20 02:22:22 -07:00
2026-07-16 04:43:45 -07:00
2026-07-28 14:19:14 -07:00
2026-07-19 03:49:29 -07:00
2026-06-28 02:41:36 -07:00
2026-07-16 04:26:06 -07:00
2026-07-26 17:15:38 -07:00
2026-06-25 21:29:57 -07:00
2026-07-09 19:09:38 -07:00
2026-07-28 00:15:00 +05:00
2026-07-26 17:13:52 -07:00
2026-07-05 14:48:28 -07:00
2026-07-13 23:26:10 +05:30
2026-07-16 06:29:09 -07:00
2026-07-13 23:26:10 +05:30
2026-07-03 03:27:47 -07:00
2026-07-28 14:22:18 -07:00
2026-07-24 11:53:46 -07:00
2026-07-02 13:25:25 +05:30
2026-07-26 20:37:04 -07:00
2026-07-13 04:31:55 -07:00
2026-07-26 21:13:03 -07:00
2026-07-14 16:58:47 +05:30
2026-07-22 06:56:08 -07:00
2026-07-23 08:33:55 -07:00
2026-07-24 10:45:34 -05:00
2026-07-10 12:38:48 +05:30
2026-07-28 14:07:21 -07:00
2026-07-11 05:41:58 -07:00
2026-07-28 11:55:48 -07:00
2026-07-20 13:04:12 -07:00
2026-07-23 11:55:17 -07:00
2026-07-28 11:55:48 -07:00
2026-07-28 11:55:01 -07:00
2026-07-01 00:42:56 -07:00
2026-07-18 20:01:55 +05:30
2026-07-28 11:57:11 -07:00
2026-07-28 17:57:48 -07:00
2026-07-28 21:45:34 -07:00
2026-07-28 00:15:00 +05:00
2026-06-25 21:29:57 -07:00
2026-06-28 02:05:50 -07:00
2026-07-23 11:49:44 -07:00
2026-07-07 17:04:32 -07:00
2026-07-23 11:34:11 -07:00
2026-07-02 03:08:11 -07:00
2026-07-20 13:04:12 -07:00
2026-07-20 03:27:22 -07:00
2026-07-22 07:56:47 -07:00
2026-07-14 21:31:32 -07:00
2026-07-22 07:00:47 -07:00
2026-07-22 07:00:47 -07:00
2026-07-17 04:51:39 -07:00
2026-07-23 11:50:28 -07:00
2026-06-25 21:29:57 -07:00
2026-07-27 21:07:49 -05:00
2026-07-22 06:56:08 -07:00
2026-07-29 02:13:41 +05:30
2026-07-23 08:19:14 -07:00
2026-07-23 08:19:14 -07:00
2026-07-02 05:10:31 -07:00
2026-07-23 16:23:57 -07:00
2026-07-28 21:45:44 -07:00
2026-07-14 16:56:34 +05:30
2026-07-14 16:56:34 +05:30
2026-07-23 19:44:19 -07:00
2026-07-28 19:38:11 +05:30
2026-07-04 13:28:47 -07:00
2026-07-01 03:56:28 -07:00
2026-07-28 00:15:00 +05:00
2026-07-24 10:45:13 -07:00
2026-07-22 11:19:37 +05:30
2026-07-19 03:49:29 -07:00
2026-07-07 22:15:04 -07:00
2026-07-13 23:26:10 +05:30
2026-07-06 01:37:10 +05:30
2026-07-04 13:28:47 -07:00
2026-07-01 15:11:38 +05:30
2026-07-24 15:55:08 -07:00
2026-07-19 00:45:32 -07:00
2026-07-20 11:52:41 +05:30
2026-07-24 10:45:13 -07:00
2026-07-26 18:28:20 -07:00
2026-07-28 14:06:56 -07:00
2026-07-18 20:01:55 +05:30
2026-06-28 00:57:03 -07:00
2026-07-01 15:38:34 -04:00
2026-07-01 00:12:17 -07:00
2026-07-07 02:40:12 -07:00
2026-07-05 06:42:42 -07:00
2026-07-22 07:14:42 -07:00
2026-07-28 14:07:21 -07:00
2026-07-01 00:12:17 -07:00
2026-07-05 13:58:11 -07:00
2026-07-07 06:25:23 -07:00
2026-07-07 17:01:08 -07:00
2026-06-27 03:57:24 +05:30
2026-07-01 16:25:16 +05:30
2026-07-18 20:01:55 +05:30
2026-07-18 14:01:33 -07:00
2026-07-07 02:40:12 -07:00
2026-06-30 02:48:42 -07:00
2026-07-23 12:01:24 -07:00
2026-07-07 06:25:23 -07:00
2026-07-07 05:50:08 -07:00
2026-07-01 03:56:28 -07:00
2026-07-28 11:56:37 -07:00
2026-07-07 17:00:58 -07:00
2026-07-07 12:42:29 -07:00
2026-07-07 12:42:29 -07:00
2026-07-28 11:56:37 -07:00
2026-07-23 11:34:11 -07:00
2026-07-01 01:20:14 -07:00
2026-07-28 11:52:44 -07:00
2026-06-25 21:29:57 -07:00
2026-07-02 03:12:53 -07:00
2026-07-01 03:56:28 -07:00
2026-07-02 03:00:59 -07:00
2026-06-25 21:29:57 -07:00
2026-07-23 11:50:28 -07:00
2026-07-13 23:26:10 +05:30
2026-07-28 11:52:44 -07:00
2026-07-09 02:22:12 +05:30
2026-07-20 03:27:22 -07:00
2026-07-01 03:56:28 -07:00
2026-06-28 00:57:03 -07:00
2026-06-30 17:20:41 -07:00
2026-06-27 04:13:09 -07:00
2026-07-20 09:19:24 -07:00
2026-07-28 14:06:56 -07:00
2026-07-28 14:06:56 -07:00
2026-07-01 02:29:24 -07:00
2026-07-16 04:40:23 -07:00
2026-07-16 08:02:47 -07:00
2026-07-01 15:59:37 +05:30
2026-07-18 20:01:55 +05:30
2026-07-24 15:47:12 -07:00
2026-07-23 11:49:44 -07:00
2026-07-20 05:38:25 -07:00
2026-07-18 12:28:59 -07:00
2026-06-29 15:51:57 -07:00
2026-07-16 05:39:58 -07:00
2026-07-23 17:57:33 +05:30
2026-07-15 09:48:24 -07:00
2026-06-25 21:29:57 -07:00
2026-07-23 11:55:17 -07:00
2026-07-26 16:14:15 -07:00
2026-07-26 16:27:52 -07:00
2026-06-25 21:29:57 -07:00
2026-07-28 14:06:56 -07:00
2026-07-24 16:03:42 -07:00
2026-06-28 20:47:33 -07:00
2026-07-21 12:04:47 -07:00
2026-07-20 11:10:49 -07:00
2026-07-23 12:01:24 -07:00
2026-07-01 05:38:03 -07:00
2026-07-28 11:55:48 -07:00
2026-07-20 11:10:49 -07:00
2026-07-23 12:01:24 -07:00
2026-07-22 21:14:44 -07:00
2026-07-23 11:44:43 -07:00
2026-07-26 13:41:53 -07:00
2026-07-26 12:52:31 -07:00
2026-07-26 12:52:31 -07:00
2026-07-26 12:52:31 -07:00
2026-07-18 14:01:33 -07:00
2026-06-27 19:26:04 -07:00
2026-06-27 03:43:28 -07:00
2026-06-27 03:43:38 -07:00
2026-06-27 04:36:22 -07:00
2026-07-22 11:19:37 +05:30
2026-07-22 11:19:37 +05:30
2026-07-18 14:01:56 -07:00
2026-07-16 07:22:24 -07:00
2026-07-28 21:45:52 -07:00
2026-07-24 13:39:21 -07:00
2026-07-16 07:57:06 -07:00
2026-06-30 15:30:06 -07:00
2026-07-08 00:34:34 +00:00
2026-07-15 12:11:16 -07:00
2026-07-07 18:25:39 +10:00
2026-07-26 16:27:52 -07:00
2026-07-03 03:33:06 -07:00
2026-07-04 16:34:16 -07:00
2026-07-28 21:36:23 +00:00
2026-07-01 03:56:28 -07:00
2026-07-01 05:31:15 -07:00
2026-07-07 02:18:17 -07:00
2026-06-25 21:29:57 -07:00
2026-06-25 21:29:57 -07:00
2026-07-23 12:01:24 -07:00
2026-06-30 14:29:51 -07:00
2026-07-17 20:55:24 +00:00
2026-07-28 11:57:11 -07:00
2026-07-23 11:54:05 -07:00
2026-06-25 21:29:57 -07:00
2026-07-28 11:56:37 -07:00
2026-07-01 02:12:25 -07:00
2026-07-22 21:58:13 -07:00
2026-07-28 11:58:54 -07:00
2026-07-10 12:38:48 +05:30
2026-07-22 04:19:10 -07:00
2026-07-15 09:50:05 -07:00
2026-07-23 11:32:24 -07:00
2026-07-05 00:41:34 -07:00
2026-07-28 14:06:56 -07:00
2026-07-22 20:55:51 -07:00
2026-07-05 21:48:59 -07:00
2026-07-03 03:33:06 -07:00
2026-07-05 13:57:37 -07:00
2026-07-11 08:42:21 -07:00
2026-07-12 00:26:49 -07:00
2026-07-14 11:46:40 -07:00
2026-06-25 21:29:57 -07:00
2026-07-08 00:20:23 +00:00
2026-07-21 12:40:21 -07:00
2026-07-19 08:25:35 +05:30
2026-07-26 16:55:42 -07:00
2026-07-23 11:13:14 -07:00
2026-07-24 10:45:13 -07:00
2026-07-20 12:11:07 +05:30
2026-07-26 19:30:14 -07:00
2026-07-16 05:08:56 -07:00
2026-07-05 13:58:03 -07:00
2026-07-23 11:36:49 -07:00
2026-07-01 17:08:50 +05:30
2026-07-23 11:36:49 -07:00
2026-07-18 20:01:55 +05:30
2026-07-24 16:03:10 -07:00
2026-07-18 20:01:55 +05:30
2026-06-26 14:01:48 +10:00
2026-07-26 12:52:31 -07:00
2026-07-22 21:58:13 -07:00
2026-06-25 21:29:57 -07:00
2026-07-24 16:00:34 -07:00
2026-07-05 13:58:03 -07:00
2026-07-01 05:38:03 -07:00
2026-07-01 15:42:19 +05:30
2026-07-26 16:01:32 -07:00
2026-07-28 19:38:11 +05:30
2026-07-01 02:29:24 -07:00
2026-07-22 11:19:37 +05:30
2026-07-04 16:34:16 -07:00
2026-07-02 05:51:12 -07:00
2026-06-29 15:51:57 -07:00
2026-07-17 04:51:39 -07:00
2026-06-25 21:29:57 -07:00
2026-07-17 04:51:39 -07:00
2026-07-17 20:55:24 +00:00
2026-07-14 17:13:20 +05:30
2026-07-22 06:56:08 -07:00
2026-07-17 04:51:39 -07:00
2026-07-24 16:00:34 -07:00
2026-07-23 12:01:24 -07:00
2026-07-22 07:22:55 -07:00
2026-07-18 20:01:55 +05:30
2026-07-28 18:08:24 +05:30
2026-07-18 19:53:00 +05:30
2026-07-28 11:52:44 -07:00
2026-07-23 11:50:08 -07:00
2026-07-23 11:50:28 -07:00
2026-07-23 11:50:28 -07:00
2026-07-01 16:32:32 +05:30
2026-07-22 07:00:47 -07:00
2026-07-01 03:16:13 -07:00
2026-07-22 07:14:42 -07:00
2026-07-23 11:44:43 -07:00
2026-06-29 01:02:53 -07:00
2026-07-22 21:14:44 -07:00
2026-07-23 11:34:11 -07:00
2026-07-22 07:22:55 -07:00
2026-07-23 11:34:11 -07:00
2026-07-22 21:14:44 -07:00
2026-07-23 12:01:24 -07:00
2026-07-23 12:51:13 +10:00
2026-07-22 21:14:44 -07:00
2026-07-23 12:01:24 -07:00
2026-07-22 20:55:51 -07:00
2026-07-22 07:14:42 -07:00
2026-07-23 11:36:49 -07:00
2026-06-29 20:57:43 -07:00
2026-07-22 07:22:55 -07:00
2026-07-23 12:01:24 -07:00
2026-06-28 02:43:23 -07:00
2026-07-05 17:38:36 -07:00
2026-06-27 03:52:44 -07:00
2026-07-05 13:57:11 -07:00
2026-07-07 14:40:32 +05:30
2026-07-21 12:40:21 -07:00
2026-07-16 00:11:22 +05:30
2026-06-30 03:22:18 -07:00
2026-07-26 18:06:21 -07:00
2026-07-05 06:29:26 -07:00
2026-07-26 08:08:38 -07:00
2026-07-22 20:55:51 -07:00
2026-07-14 21:31:32 -07:00
2026-06-30 23:37:04 -07:00
2026-07-18 14:01:33 -07:00
2026-07-26 13:41:53 -07:00
2026-07-28 22:31:40 -07:00
2026-07-28 22:31:40 -07:00
2026-07-28 14:06:56 -07:00
2026-07-05 06:12:49 -07:00
2026-07-18 20:01:55 +05:30
2026-07-18 20:01:55 +05:30
2026-06-27 03:57:24 +05:30
2026-07-25 17:51:06 +05:30
2026-07-19 07:27:29 +05:30
2026-07-22 12:47:41 +05:30
2026-06-28 00:57:03 -07:00
2026-06-28 01:07:53 -07:00
2026-07-24 19:11:04 -07:00
2026-07-22 07:14:42 -07:00
2026-07-28 11:52:44 -07:00
2026-07-16 04:25:54 -07:00
2026-07-26 19:30:27 -07:00
2026-07-11 11:13:50 +05:30
2026-07-05 00:32:35 -07:00
2026-07-26 11:50:34 -07:00
2026-07-14 17:09:50 +05:30
2026-07-04 13:48:33 +05:30
2026-07-21 12:11:52 +05:30
2026-07-26 19:30:27 -07:00
2026-07-23 08:43:21 -07:00
2026-06-30 15:36:58 -07:00
2026-07-24 19:11:04 -07:00
2026-07-14 06:48:53 -07:00
2026-07-14 17:32:41 +05:30
2026-07-24 19:11:04 -07:00
2026-06-30 17:39:30 -07:00
2026-07-23 11:44:43 -07:00
2026-07-26 16:01:32 -07:00
2026-07-07 02:39:31 -07:00
2026-06-27 04:01:58 -07:00
2026-07-28 11:55:48 -07:00
2026-07-16 04:40:35 -07:00
2026-07-28 11:57:11 -07:00
2026-07-20 11:10:49 -07:00
2026-06-29 15:51:57 -07:00
2026-07-02 05:09:38 -07:00
2026-07-06 03:42:14 -07:00
2026-07-26 12:52:31 -07:00
2026-07-13 04:31:55 -07:00
2026-07-19 03:49:29 -07:00
2026-06-29 21:12:57 -07:00
2026-06-28 02:05:26 -07:00
2026-07-28 11:57:11 -07:00
2026-07-22 16:51:01 -04:00
2026-07-07 22:15:04 -07:00
2026-07-14 03:23:19 -07:00
2026-07-05 06:29:26 -07:00
2026-07-28 14:07:21 -07:00
2026-07-23 11:55:17 -07:00
2026-07-28 14:22:18 -07:00
2026-07-24 11:45:57 -07:00
2026-07-02 17:39:09 -07:00
2026-06-28 22:35:43 -07:00
2026-07-23 12:01:24 -07:00
2026-07-23 11:44:43 -07:00
2026-07-28 14:06:56 -07:00
2026-07-01 03:56:28 -07:00
2026-07-05 00:41:34 -07:00
2026-07-16 07:22:24 -07:00
2026-07-28 18:02:51 +05:30
2026-07-28 14:06:56 -07:00
2026-07-01 03:56:28 -07:00
2026-07-01 03:56:28 -07:00
2026-06-28 02:05:26 -07:00
2026-06-30 15:30:06 -07:00
2026-07-05 06:27:20 -07:00
2026-07-23 12:01:24 -07:00
2026-07-28 18:02:51 +05:30
2026-07-28 18:02:51 +05:30
2026-06-28 15:29:59 -07:00