Skip to content

Commit 888e8db

Browse files
Send audio output as binary PCM instead of JSON
1 parent f64a646 commit 888e8db

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/routing/outbound.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,21 @@ async def _send_frame(
4242
ctx: "ConnectionContext",
4343
frame: OutboundFrame,
4444
) -> None:
45-
"""Send a frame to the WebSocket as JSON.
45+
"""Send a frame to the WebSocket.
46+
47+
AUDIO frames are sent as binary PCM, all others as JSON.
4648
4749
Args:
4850
ctx: The ConnectionContext
4951
frame: The OutboundFrame to send
5052
"""
5153
try:
54+
if frame.type == "AUDIO":
55+
audio_data = frame.payload.get("data")
56+
if isinstance(audio_data, bytes):
57+
await ctx.websocket.send_bytes(audio_data)
58+
return
59+
5260
message = frame.model_dump(mode="json")
5361
await ctx.websocket.send_json(message)
5462
except (asyncio.CancelledError, RuntimeError):

0 commit comments

Comments
 (0)