mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-25 18:31:00 +00:00
Fix None access bug
This commit is contained in:
parent
183edafc41
commit
d174967f5c
1 changed files with 3 additions and 2 deletions
|
@ -9,7 +9,8 @@ import numpy as np
|
||||||
import websockets
|
import websockets
|
||||||
from websockets.exceptions import ConnectionClosedOK
|
from websockets.exceptions import ConnectionClosedOK
|
||||||
|
|
||||||
from whispering.transcriber import Context, WhisperStreamingTranscriber
|
from whispering.schema import Context
|
||||||
|
from whispering.transcriber import WhisperStreamingTranscriber
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
|
@ -66,7 +67,6 @@ async def serve_with_websocket_main(websocket):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.debug(f"Message size: {len(message)}")
|
logger.debug(f"Message size: {len(message)}")
|
||||||
audio = np.frombuffer(message, dtype=np.dtype(ctx.data_type)).astype(np.float32)
|
|
||||||
if ctx is None:
|
if ctx is None:
|
||||||
await websocket.send(
|
await websocket.send(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
|
@ -76,6 +76,7 @@ async def serve_with_websocket_main(websocket):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
audio = np.frombuffer(message, dtype=np.dtype(ctx.data_type)).astype(np.float32)
|
||||||
for chunk in g_wsp.transcribe(
|
for chunk in g_wsp.transcribe(
|
||||||
audio=audio, # type: ignore
|
audio=audio, # type: ignore
|
||||||
ctx=ctx,
|
ctx=ctx,
|
||||||
|
|
Loading…
Reference in a new issue