Spaces:
Sleeping
Sleeping
Primera version
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers import pipeline
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
pipe = pipeline(
|
7 |
+
"automatic-speech-recognition", model="openai/whisper-base"
|
8 |
+
)
|
9 |
+
|
10 |
+
def transcribe(audio):
|
11 |
+
sr, y = audio
|
12 |
+
# Pasamos el array de muestras a tipo NumPy de 32 bits
|
13 |
+
y = y.astype(np.float32)
|
14 |
+
y /= np.max(np.abs(y))
|
15 |
+
|
16 |
+
return pipe({"sampling_rate": sr, "raw": y})["text"]
|
17 |
+
|
18 |
+
demo = gr.Interface(
|
19 |
+
transcribe,
|
20 |
+
gr.Audio(sources=["microphone"]),
|
21 |
+
"text",
|
22 |
+
)
|
23 |
+
|
24 |
+
demo.launch()
|