bcci commited on
Commit
74e732d
·
verified ·
1 Parent(s): 589cb0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -35,6 +35,14 @@ vad_iterator = VADIterator(
35
  min_silence_duration_ms=300,
36
  )
37
 
 
 
 
 
 
 
 
 
38
  @app.websocket("/ws/transcribe")
39
  async def websocket_endpoint(websocket: WebSocket):
40
  await websocket.accept()
 
35
  min_silence_duration_ms=300,
36
  )
37
 
38
+ def pcm16_to_float32(pcm_data: bytes) -> np.ndarray:
39
+ """
40
+ Convert 16-bit PCM bytes into a float32 numpy array with values in [-1, 1].
41
+ """
42
+ int_data = np.frombuffer(pcm_data, dtype=np.int16)
43
+ float_data = int_data.astype(np.float32) / 32768.0
44
+ return float_data
45
+
46
  @app.websocket("/ws/transcribe")
47
  async def websocket_endpoint(websocket: WebSocket):
48
  await websocket.accept()