Merge pull request #4028 from inworld-ai/ian/close-on-turn-complete
fix(inworld): close context at end of turn instead of relying on idle timeout
This commit is contained in:
1
changelog/4028.changed.md
Normal file
1
changelog/4028.changed.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Modeified `InworldTTSService` to close context at end of turn instead of relying on idle timeout
|
||||||
@@ -791,14 +791,20 @@ class InworldTTSService(WebsocketTTSService):
|
|||||||
self._cumulative_time = 0.0
|
self._cumulative_time = 0.0
|
||||||
self._generation_end_time = 0.0
|
self._generation_end_time = 0.0
|
||||||
|
|
||||||
|
async def on_turn_context_completed(self):
|
||||||
|
"""Close the server-side context at end of turn.
|
||||||
|
|
||||||
|
Sends close_context so contextClosed arrives immediately after the
|
||||||
|
last audio byte.
|
||||||
|
"""
|
||||||
|
ctx_id = self._turn_context_id
|
||||||
|
await super().on_turn_context_completed()
|
||||||
|
await self._close_context(ctx_id)
|
||||||
|
|
||||||
async def on_audio_context_interrupted(self, context_id: str):
|
async def on_audio_context_interrupted(self, context_id: str):
|
||||||
"""Callback invoked when an audio context has been interrupted."""
|
"""Callback invoked when an audio context has been interrupted."""
|
||||||
await self._close_context(context_id)
|
await self._close_context(context_id)
|
||||||
|
|
||||||
async def on_audio_context_completed(self, context_id: str):
|
|
||||||
"""Callback invoked when an audio context has been completed."""
|
|
||||||
await self._close_context(context_id)
|
|
||||||
|
|
||||||
def _get_websocket(self):
|
def _get_websocket(self):
|
||||||
"""Get the websocket for the Inworld WebSocket TTS service.
|
"""Get the websocket for the Inworld WebSocket TTS service.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user