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:
|
try:
|
||||||
segment = await asyncio.wait_for(g(), timeout=3.0)
|
segment = await asyncio.wait_for(g(), timeout=3.0)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await ws.send("dummy")
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.debug(f"Segment size: {len(segment)}")
|
logger.debug(f"Segment size: {len(segment)}")
|
||||||
await ws.send(segment)
|
await ws.send(segment)
|
||||||
logger.debug("Sent")
|
logger.debug("Sent")
|
||||||
|
|
||||||
d = await ws.recv()
|
while True:
|
||||||
for c in json.loads(d):
|
c = await ws.recv()
|
||||||
chunk = ParsedChunk.parse_obj(c)
|
if len(c) == 0:
|
||||||
|
break
|
||||||
|
chunk = ParsedChunk.parse_raw(c)
|
||||||
print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}")
|
print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}")
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue