Add support for microphone recordings
Browse files
app.py
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from librosa import resample
|
|
|
4 |
|
5 |
def transcribe(input_audio):
|
6 |
sr, speech = input_audio
|
|
|
|
|
|
|
7 |
# Convert to mono if stereo
|
8 |
if speech.ndim > 1:
|
9 |
speech = speech.mean(axis=1)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from librosa import resample
|
4 |
+
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)
|