Merge pull request #1194 from Vaibhav159/vl_fix_elevenlabs_disconnect_issue

fixing disconnect issue
This commit is contained in:
Aleix Conchillo Flaqué
2025-02-10 13:41:59 -08:00
committed by GitHub
3 changed files with 11 additions and 1 deletions

View File

@@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed an `RTVI` issue that was causing `bot-tts-text` messages to be sent
before being processed by the output transport.
- Fixed an issue[#1192] in 11labs where we are trying to reconnect/disconnect the
websocket connection even when the connection is already closed.
## [0.0.56] - 2025-02-06
### Changed

View File

@@ -388,7 +388,11 @@ class ElevenLabsTTSService(WordTTSService, WebsocketService):
async def _keepalive_task_handler(self):
while True:
await asyncio.sleep(10)
await self._send_text("")
try:
await self._send_text("")
except websockets.ConnectionClosed as e:
logger.warning(f"{self} keepalive error: {e}")
break
async def _send_text(self, text: str):
if self._websocket:

View File

@@ -85,6 +85,9 @@ class WebsocketService(ABC):
await self._receive_messages()
logger.debug(f"{self} connection established successfully")
retry_count = 0 # Reset counter on successful message receive
except websockets.ConnectionClosed as e:
logger.warning(f"{self} connection closed: {e}")
break
except Exception as e:
retry_count += 1
if retry_count >= MAX_RETRIES: