We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f64a646 commit 888e8dbCopy full SHA for 888e8db
1 file changed
src/routing/outbound.py
@@ -42,13 +42,21 @@ async def _send_frame(
42
ctx: "ConnectionContext",
43
frame: OutboundFrame,
44
) -> None:
45
- """Send a frame to the WebSocket as JSON.
+ """Send a frame to the WebSocket.
46
+
47
+ AUDIO frames are sent as binary PCM, all others as JSON.
48
49
Args:
50
ctx: The ConnectionContext
51
frame: The OutboundFrame to send
52
"""
53
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
60
message = frame.model_dump(mode="json")
61
await ctx.websocket.send_json(message)
62
except (asyncio.CancelledError, RuntimeError):
0 commit comments