Spaces:
Running
Running
Add support for microphone recordings
Browse files
app.py
CHANGED
|
@@ -5,12 +5,12 @@ import numpy as np
|
|
| 5 |
|
| 6 |
def transcribe(input_audio):
|
| 7 |
sr, speech = input_audio
|
| 8 |
-
# Convert to float32 if needed
|
| 9 |
-
if speech.dtype != "float32":
|
| 10 |
-
speech = speech.astype(np.float32)
|
| 11 |
# Convert to mono if stereo
|
| 12 |
if speech.ndim > 1:
|
| 13 |
speech = speech.mean(axis=1)
|
|
|
|
|
|
|
|
|
|
| 14 |
# Resample if sampling rate is not 16kHz
|
| 15 |
if sr!=16000:
|
| 16 |
speech = resample(speech, orig_sr=sr, target_sr=16000)
|
|
|
|
| 5 |
|
| 6 |
def transcribe(input_audio):
|
| 7 |
sr, speech = input_audio
|
|
|
|
|
|
|
|
|
|
| 8 |
# Convert to mono if stereo
|
| 9 |
if speech.ndim > 1:
|
| 10 |
speech = speech.mean(axis=1)
|
| 11 |
+
# Convert to float32 if needed
|
| 12 |
+
if speech.dtype != "float32":
|
| 13 |
+
speech = speech.astype(np.float32)
|
| 14 |
# Resample if sampling rate is not 16kHz
|
| 15 |
if sr!=16000:
|
| 16 |
speech = resample(speech, orig_sr=sr, target_sr=16000)
|