Clean up _receive_messages to use WebsocketService class
This commit is contained in:
@@ -666,12 +666,8 @@ class InworldTTSService(AudioContextWordTTSService):
|
|||||||
self._websocket = None
|
self._websocket = None
|
||||||
await self._call_event_handler("on_disconnected")
|
await self._call_event_handler("on_disconnected")
|
||||||
|
|
||||||
async def _process_messages(self):
|
async def _receive_messages(self):
|
||||||
"""Process incoming WebSocket messages from Inworld.
|
"""Handle incoming WebSocket messages from Inworld."""
|
||||||
|
|
||||||
Returns:
|
|
||||||
The messages.
|
|
||||||
"""
|
|
||||||
async for message in self._get_websocket():
|
async for message in self._get_websocket():
|
||||||
try:
|
try:
|
||||||
msg = json.loads(message)
|
msg = json.loads(message)
|
||||||
@@ -761,18 +757,6 @@ class InworldTTSService(AudioContextWordTTSService):
|
|||||||
await self.remove_audio_context(ctx_id)
|
await self.remove_audio_context(ctx_id)
|
||||||
await self.add_word_timestamps([("TTSStoppedFrame", 0), ("Reset", 0)])
|
await self.add_word_timestamps([("TTSStoppedFrame", 0), ("Reset", 0)])
|
||||||
|
|
||||||
async def _receive_messages(self):
|
|
||||||
"""Receive messages from the Inworld WebSocket TTS service with auto-reconnect.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The messages.
|
|
||||||
"""
|
|
||||||
while True:
|
|
||||||
await self._process_messages()
|
|
||||||
# Inworld may disconnect after period of inactivity, so we try to reconnect
|
|
||||||
logger.debug(f"{self} Inworld connection was disconnected, reconnecting")
|
|
||||||
await self._connect_websocket()
|
|
||||||
|
|
||||||
async def _send_context(self, context_id: str):
|
async def _send_context(self, context_id: str):
|
||||||
"""Send a context to the Inworld WebSocket TTS service.
|
"""Send a context to the Inworld WebSocket TTS service.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user