mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-29 04:21:07 +00:00
Changed
This commit is contained in:
parent
f8bda94117
commit
1ebef74d3a
1 changed files with 16 additions and 10 deletions
|
@ -44,22 +44,28 @@ async def transcribe_from_mic_and_send(
|
||||||
async def g():
|
async def g():
|
||||||
return await q.get()
|
return await q.get()
|
||||||
|
|
||||||
logger.debug(f"Segment #: {idx}")
|
logger.debug(f"Loop #: {idx}")
|
||||||
|
segment = None
|
||||||
try:
|
try:
|
||||||
segment = await asyncio.wait_for(g(), timeout=3.0)
|
segment = await asyncio.wait_for(g(), timeout=0.5)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
continue
|
pass
|
||||||
|
if segment is not None:
|
||||||
|
logger.debug(f"Segment size: {len(segment)}")
|
||||||
|
await ws.send(segment)
|
||||||
|
logger.debug("Sent")
|
||||||
|
|
||||||
logger.debug(f"Segment size: {len(segment)}")
|
async def recv():
|
||||||
await ws.send(segment)
|
return await ws.recv()
|
||||||
logger.debug("Sent")
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
c = await ws.recv()
|
try:
|
||||||
if len(c) == 0:
|
c = await asyncio.wait_for(recv(), timeout=0.5)
|
||||||
|
chunk = ParsedChunk.parse_raw(c)
|
||||||
|
print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}")
|
||||||
|
except asyncio.TimeoutError:
|
||||||
break
|
break
|
||||||
chunk = ParsedChunk.parse_raw(c)
|
|
||||||
print(f"{chunk.start:.2f}->{chunk.end:.2f}\t{chunk.text}")
|
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue