Update app.py
Browse files
app.py
CHANGED
@@ -4,23 +4,18 @@ import numpy as np
|
|
4 |
|
5 |
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
6 |
|
7 |
-
def transcribe(
|
8 |
-
sr, y =
|
9 |
y = y.astype(np.float32)
|
10 |
y /= np.max(np.abs(y))
|
11 |
|
12 |
-
|
13 |
-
stream = np.concatenate([stream, y])
|
14 |
-
else:
|
15 |
-
stream = y
|
16 |
-
return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"]
|
17 |
|
18 |
|
19 |
demo = gr.Interface(
|
20 |
transcribe,
|
21 |
-
|
22 |
-
|
23 |
-
live=True,
|
24 |
)
|
25 |
|
26 |
demo.launch()
|
|
|
4 |
|
5 |
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
6 |
|
7 |
+
def transcribe(audio):
|
8 |
+
sr, y = audio
|
9 |
y = y.astype(np.float32)
|
10 |
y /= np.max(np.abs(y))
|
11 |
|
12 |
+
return transcriber({"sampling_rate": sr, "raw": y})["text"]
|
|
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
demo = gr.Interface(
|
16 |
transcribe,
|
17 |
+
gr.Audio(sources=["microphone"]),
|
18 |
+
"text",
|
|
|
19 |
)
|
20 |
|
21 |
demo.launch()
|