From 183edafc417bf210d029717377a926195a32b89d Mon Sep 17 00:00:00 2001 From: charles-zablit Date: Mon, 17 Oct 2022 10:53:59 +0200 Subject: [PATCH] feat: add datatype in context --- whispering/schema.py | 2 ++ whispering/serve.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/whispering/schema.py b/whispering/schema.py index 5e5fda0..c3c12ac 100644 --- a/whispering/schema.py +++ b/whispering/schema.py @@ -48,6 +48,8 @@ class Context(BaseModel, arbitrary_types_allowed=True): vad_threshold: float max_nospeech_skip: int + data_type: Optional[str] = "float32" + class ParsedChunk(BaseModel): start: float diff --git a/whispering/serve.py b/whispering/serve.py index 8ca32ec..579adf6 100644 --- a/whispering/serve.py +++ b/whispering/serve.py @@ -66,7 +66,7 @@ async def serve_with_websocket_main(websocket): continue logger.debug(f"Message size: {len(message)}") - audio = np.frombuffer(message, dtype=np.float32) + audio = np.frombuffer(message, dtype=np.dtype(ctx.data_type)).astype(np.float32) if ctx is None: await websocket.send( json.dumps(