pipecat-ai / pipecat

Open Source framework for voice and multimodal conversational AI
BSD 2-Clause "Simplified" License
3.11k stars 270 forks source link

CartesiaTTSService: Potential Bug in WebSocket Handling #471

Open amacapri opened 1 week ago

amacapri commented 1 week ago

Occasionally, I encounter this error in CartesiaTTSService. Could this be a bug in the CartesiaTTSService, the Cartesia library, or my code?

2024-09-18 09:25:01.202 | ERROR | pipecat.services.cartesia:_receive_task_handler:189 - CartesiaTTSService#0 exception: no close frame received or sent Traceback (most recent call last):

File "/Users/magnacarta/p/sunray/.venv/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 963, in transfer_data message = await self.read_message() │ └ <function WebSocketCommonProtocol.read_message at 0x13c9f4360> └ <websockets.legacy.client.WebSocketClientProtocol object at 0x175ec6fc0> File "/Users/magnacarta/p/sunray/.venv/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1033, in read_message frame = await self.read_data_frame(max_size=self.max_size) │ │ │ └ 1048576 │ │ └ <websockets.legacy.client.WebSocketClientProtocol object at 0x175ec6fc0> │ └ <function WebSocketCommonProtocol.read_data_frame at 0x13c9f4400> └ <websockets.legacy.client.WebSocketClientProtocol object at 0x175ec6fc0> File "/Users/magnacarta/p/sunray/.venv/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1108, in read_data_frame frame = await self.read_frame(max_size) │ │ └ 1048576 │ └ <function WebSocketCommonProtocol.read_frame at 0x13c9f44a0> └ <websockets.legacy.client.WebSocketClientProtocol object at 0x175ec6fc0> File "/Users/magnacarta/p/sunray/.venv/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1165, in read_frame frame = await Frame.read( │ └ <classmethod(<function Frame.read at 0x13c9cefc0>)> └ <class 'websockets.legacy.framing.Frame'> File "/Users/magnacarta/p/sunray/.venv/lib/python3.12/site-packages/websockets/legacy/framing.py", line 68, in read data = await reader(2) └ <bound method StreamReader.readexactly of <StreamReader eof limit=32768 transport=<asyncio.sslproto._SSLProtocolTransport obj...

File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/streams.py", line 750, in readexactly raise exceptions.IncompleteReadError(incomplete, n) │ │ │ └ 2 │ │ └ b'' │ └ <class 'asyncio.exceptions.IncompleteReadError'> └ <module 'asyncio.exceptions' from '/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/pyth...

asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes

sourav-bz commented 2 days ago

getting the same issue as well, i think the connection is timing out after inactivity and not connecting back after that.