Add non-streaming websocket server for python (#259)

This commit is contained in:
Fangjun Kuang
2023-08-11 15:56:24 +08:00
committed by GitHub
parent 6c0f002825
commit b094868fb8
24 changed files with 1247 additions and 92 deletions

View File

@@ -119,7 +119,13 @@ async def run(
buf += (samples.size * 4).to_bytes(4, byteorder="little")
buf += samples.tobytes()
await websocket.send(buf)
payload_len = 10240
while len(buf) > payload_len:
await websocket.send(buf[:payload_len])
buf = buf[payload_len:]
if buf:
await websocket.send(buf)
decoding_results = await websocket.recv()
logging.info(f"{wave_filename}\n{decoding_results}")