mirror of
https://github.com/shirayu/whispering.git
synced 2025-02-16 18:45:14 +00:00
Send context
This commit is contained in:
parent
3f60122e49
commit
e478564ca2
2 changed files with 16 additions and 0 deletions
|
@ -28,6 +28,19 @@ async def serve_with_websocket_main(websocket):
|
||||||
|
|
||||||
if isinstance(message, str):
|
if isinstance(message, str):
|
||||||
logger.debug(f"Got str: {message}")
|
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
|
continue
|
||||||
|
|
||||||
logger.debug(f"Message size: {len(message)}")
|
logger.debug(f"Message size: {len(message)}")
|
||||||
|
|
|
@ -38,6 +38,9 @@ async def transcribe_from_mic_and_send(
|
||||||
callback=sd_callback,
|
callback=sd_callback,
|
||||||
):
|
):
|
||||||
async with websockets.connect(uri, max_size=999999999) as ws: # type:ignore
|
async with websockets.connect(uri, max_size=999999999) as ws: # type:ignore
|
||||||
|
logger.debug("Sent context")
|
||||||
|
await ws.send(ctx.json())
|
||||||
|
|
||||||
idx: int = 0
|
idx: int = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue