aitor-medrano commited on
Commit
1c4b4a8
·
verified ·
1 Parent(s): c9eb42b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ pipe = pipeline(
4
+ "automatic-speech-recognition", model="openai/whisper-base"
5
+ )
6
+
7
+ def greet(modelo, grabacion):
8
+ sr, y = grabacion
9
+ # Pasamos el array de muestras a tipo NumPy de 32 bits
10
+ y = y.astype(np.float32)
11
+ y /= np.max(np.abs(y))
12
+
13
+ return modelo + ":" + pipe({"sampling_rate": sr, "raw": y})["text"]
14
+
15
+ demo = gr.Interface(fn=greet,
16
+ inputs=[
17
+ gr.Dropdown(
18
+ ["Base", "Small"], label="Modelo", info="Modelos de Lara entrenados"
19
+ ),
20
+ gr.Audio()
21
+ ],
22
+ outputs="text")
23
+ demo.launch()