mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-25 10:21:00 +00:00
Changed protocol
This commit is contained in:
parent
e9534ec977
commit
f8bda94117
1 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue