Gabriel C commited on
Commit
48c53a8
1 Parent(s): ddcc364

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -14,7 +14,14 @@ def transcribe(stream, new_chunk):
14
  Transcribes using whisper
15
  """
16
  sr, y = new_chunk
 
 
 
 
 
17
  y = y.astype(np.float32)
 
 
18
  y /= np.max(np.abs(y))
19
 
20
  if stream is not None:
 
14
  Transcribes using whisper
15
  """
16
  sr, y = new_chunk
17
+
18
+ # Convert stereo to mono if necessary
19
+ if y.ndim == 2 and y.shape[1] == 2:
20
+ y = y.mean(axis=1) # Averaging both channels if stereo
21
+
22
  y = y.astype(np.float32)
23
+
24
+ # Normalization
25
  y /= np.max(np.abs(y))
26
 
27
  if stream is not None: