pipecat-ai / pipecat

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

CartesiaTTSService: Potential Bug in WebSocket Handling #471

Open dominikroblek opened 2 months ago

dominikroblek commented 2 months 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 1 month ago

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

Shoshin23 commented 1 month ago

I'm getting a similar issue, but with ElevenLabs TTS. Here's the link to my issue: https://github.com/pipecat-ai/pipecat/issues/563

This seems to be happening fairly commonly. I'm not sure if this is to do with my code or if it's to do with Pipecat. My code itself is fairly straightforward. It uses based on one of the foundational examples so i'm not sure.

Thanks!

markbackman commented 2 weeks ago

Hi, I'm interested in understanding this issue. Do you have repro steps that you can share?