Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Fix None access bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shirayu committed Oct 17, 2022
1 parent 183edaf commit d174967
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions whispering/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import websockets
from websockets.exceptions import ConnectionClosedOK

from whispering.transcriber import Context, WhisperStreamingTranscriber
from whispering.schema import Context
from whispering.transcriber import WhisperStreamingTranscriber

logger = getLogger(__name__)

Expand Down Expand Up @@ -66,7 +67,6 @@ async def serve_with_websocket_main(websocket):
continue

logger.debug(f"Message size: {len(message)}")
audio = np.frombuffer(message, dtype=np.dtype(ctx.data_type)).astype(np.float32)
if ctx is None:
await websocket.send(
json.dumps(
Expand All @@ -76,6 +76,7 @@ async def serve_with_websocket_main(websocket):
)
)
return
audio = np.frombuffer(message, dtype=np.dtype(ctx.data_type)).astype(np.float32)
for chunk in g_wsp.transcribe(
audio=audio, # type: ignore
ctx=ctx,
Expand Down

0 comments on commit d174967

Please sign in to comment.