Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,10 @@ def transcribe(stream, new_chunk):
|
|
| 9 |
y = y.astype(np.float32)
|
| 10 |
y /= np.max(np.abs(y))
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
if stream is not None:
|
| 13 |
stream = np.concatenate([stream, y])
|
| 14 |
else:
|
|
|
|
| 9 |
y = y.astype(np.float32)
|
| 10 |
y /= np.max(np.abs(y))
|
| 11 |
|
| 12 |
+
# Check if the audio is stereo and convert to mono by averaging the channels
|
| 13 |
+
if y.ndim > 1 and y.shape[1] > 1: # More than one channel
|
| 14 |
+
y = np.mean(y, axis=1, keepdims=True) # Convert to mono
|
| 15 |
+
|
| 16 |
if stream is not None:
|
| 17 |
stream = np.concatenate([stream, y])
|
| 18 |
else:
|