Spaces:
Sleeping
Sleeping
Eric Guan
commited on
Commit
·
a6a9161
1
Parent(s):
3608b5d
Updated app.py
Browse files- app.py +4 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -2,7 +2,9 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
|
5 |
-
|
|
|
|
|
6 |
|
7 |
def transcribe(audio):
|
8 |
sr, y = audio
|
@@ -14,7 +16,7 @@ def transcribe(audio):
|
|
14 |
y = y.astype(np.float32)
|
15 |
y /= np.max(np.abs(y))
|
16 |
|
17 |
-
return
|
18 |
|
19 |
demo = gr.Interface(
|
20 |
transcribe,
|
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
|
5 |
+
model = "openai/whisper-base.en"
|
6 |
+
|
7 |
+
pipe = pipeline("automatic-speech-recognition", model=model)
|
8 |
|
9 |
def transcribe(audio):
|
10 |
sr, y = audio
|
|
|
16 |
y = y.astype(np.float32)
|
17 |
y /= np.max(np.abs(y))
|
18 |
|
19 |
+
return pipe({"sampling_rate": sr, "raw": y})["text"]
|
20 |
|
21 |
demo = gr.Interface(
|
22 |
transcribe,
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers
|
2 |
torch
|
|
|
3 |
numpy
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
+
torchaudio
|
4 |
numpy
|