Spaces:
Sleeping
Sleeping
Update app.py
Browse filesTranscribe func fixed
app.py
CHANGED
|
@@ -2,15 +2,18 @@ import gradio as gr
|
|
| 2 |
import time
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
def transcribe(audio):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
demo = gr.Interface(
|
| 12 |
transcribe,
|
| 13 |
gr.Audio(sources=["microphone"]),
|
| 14 |
-
|
| 15 |
)
|
| 16 |
demo.launch()
|
|
|
|
| 2 |
import time
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
transcriber = pipeline('automatic-speech-recognition',model = "openai/whisper-tiny")
|
| 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 |
demo = gr.Interface(
|
| 15 |
transcribe,
|
| 16 |
gr.Audio(sources=["microphone"]),
|
| 17 |
+
"text"
|
| 18 |
)
|
| 19 |
demo.launch()
|