Update GradiumTTSService to flush instead of ending stream

This commit is contained in:
Mark Backman
2026-01-29 18:49:14 -05:00
parent 7be2b8cc34
commit b012220ab9
2 changed files with 7 additions and 2 deletions

1
changelog/3597.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed an issue in `GradiumTTSService` where the websocket was being disconnected at the end of every bot turn.

View File

@@ -232,11 +232,15 @@ class GradiumTTSService(InterruptibleWordTTSService):
raise Exception("Websocket not connected")
async def flush_audio(self):
"""Flush any pending audio synthesis."""
"""Flush any pending audio synthesis.
Sends a <flush> tag to force the model to output audio for all text
that has been input so far, without closing the connection.
"""
if not self._websocket:
return
try:
msg = {"type": "end_of_stream"}
msg = {"type": "text", "text": "<flush>"}
await self._websocket.send(json.dumps(msg))
except ConnectionClosedOK:
logger.debug(f"{self}: connection closed normally during flush")