diff --git a/main.py b/main.py index fcaff93e..b1afc5e2 100644 --- a/main.py +++ b/main.py @@ -96,6 +96,12 @@ async def receive_from_twilio(): elif data['event'] == 'mark': if mark_queue: mark_queue.pop(0) + elif data['event'] == 'stop': + print(f"Call ended, stream {stream_sid} stopped") + if openai_ws.open: + await openai_ws.close() + await websocket.close() + return except WebSocketDisconnect: print("Client disconnected.") if openai_ws.open: