From f8bda941177e34a917ddce130adb63d4e60b9571 Mon Sep 17 00:00:00 2001 From: Yuta Hayashibe Date: Sat, 24 Sep 2022 21:39:22 +0900 Subject: [PATCH] Changed protocol --- whisper_streaming/websocket_client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/whisper_streaming/websocket_client.py b/whisper_streaming/websocket_client.py index e842c80..afbaf18 100644 --- a/whisper_streaming/websocket_client.py +++ b/whisper_streaming/websocket_client.py @@ -48,16 +48,17 @@ async def transcribe_from_mic_and_send( try: segment = await asyncio.wait_for(g(), timeout=3.0) except asyncio.TimeoutError: - await ws.send("dummy") continue logger.debug(f"Segment size: {len(segment)}") await ws.send(segment) logger.debug("Sent") - d = await ws.recv() - for c in json.loads(d): - chunk = ParsedChunk.parse_obj(c) + while True: + c = await ws.recv() + if len(c) == 0: + break + chunk = ParsedChunk.parse_raw(c) print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}") idx += 1