19 lines
452 B
Python
19 lines
452 B
Python
import json
|
|
|
|
from fastapi import WebSocket
|
|
|
|
|
|
async def send_text_message(websocket: WebSocket, content: str) -> None:
|
|
await websocket.send_text(json.dumps({"type": "text", "content": content}))
|
|
|
|
|
|
async def send_audio_message(websocket: WebSocket, audio_data_url: str) -> None:
|
|
await websocket.send_text(
|
|
json.dumps(
|
|
{
|
|
"type": "audio",
|
|
"content": audio_data_url,
|
|
}
|
|
)
|
|
)
|