From 1801a6b7e4e5e98869f0adc135066dbed09ec666 Mon Sep 17 00:00:00 2001 From: Yuta Hayashibe Date: Sat, 24 Sep 2022 21:39:30 +0900 Subject: [PATCH] Changed protocol --- whisper_streaming/serve.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/whisper_streaming/serve.py b/whisper_streaming/serve.py index e2c9217..20f3cf9 100644 --- a/whisper_streaming/serve.py +++ b/whisper_streaming/serve.py @@ -26,8 +26,9 @@ async def serve_with_websocket_main(websocket): logger.debug(f"Message size: {len(message)}") segment = np.frombuffer(message, dtype=np.float32) - chunks = [chunk.dict() for chunk in g_wsp.transcribe(segment=segment)] - await websocket.send(json.dumps(chunks)) + for chunk in g_wsp.transcribe(segment=segment): + await websocket.send(chunk.json()) + await websocket.send("") idx += 1