Send context

This commit is contained in:
Yuta Hayashibe 2022-10-02 22:02:17 +09:00
parent 3f60122e49
commit e478564ca2
2 changed files with 16 additions and 0 deletions

View file

@ -28,6 +28,19 @@ async def serve_with_websocket_main(websocket):
if isinstance(message, str):
logger.debug(f"Got str: {message}")
d = json.loads(message)
v = d.get("context")
if v is not None:
ctx = Context.parse_obj(v)
else:
await websocket.send(
json.dumps(
{
"error": "unsupported message",
}
)
)
return
continue
logger.debug(f"Message size: {len(message)}")

View file

@ -38,6 +38,9 @@ async def transcribe_from_mic_and_send(
callback=sd_callback,
):
async with websockets.connect(uri, max_size=999999999) as ws: # type:ignore
logger.debug("Sent context")
await ws.send(ctx.json())
idx: int = 0
while True: