mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-28 20:11:08 +00:00
Check error
This commit is contained in:
parent
e478564ca2
commit
8f0e03de7f
1 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from logging import getLogger
|
||||
from typing import Optional, Union
|
||||
|
||||
|
@ -64,11 +66,14 @@ async def transcribe_from_mic_and_send(
|
|||
while True:
|
||||
try:
|
||||
c = await asyncio.wait_for(recv(), timeout=0.5)
|
||||
chunk = ParsedChunk.parse_raw(c)
|
||||
c_json = json.loads(c)
|
||||
if (err := c_json.get("error")) is not None:
|
||||
print(f"Error: {err}")
|
||||
sys.exit(1)
|
||||
chunk = ParsedChunk.parse_obj(c_json)
|
||||
print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}")
|
||||
except asyncio.TimeoutError:
|
||||
break
|
||||
|
||||
idx += 1
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue