sanrapi commited on
Commit
7232952
1 Parent(s): 7229964

subir demo

Browse files

model: facebook/wav2vec2-large-xlsr-53-spanish")
model : "pysentimiento/robertuito-sentiment-analysis")

Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ trans = pipeline("automatic-speech-recognition", model = "facebook/wav2vec2-large-xlsr-53-spanish")
5
+ clasificador = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
6
+
7
+ def audio_a_text(audio):
8
+ text = trans(audio)["text"]
9
+ return text
10
+
11
+ def texto_a_sentimiento(text):
12
+ return clasificador(text)[0]["label"]
13
+
14
+ demo = gr.Blocks()
15
+
16
+ with demo:
17
+ gr.Markdown("Demo para la clase de Platzi")
18
+ audio = gr.Audio(sources="microphone", type="filepath")
19
+ texto = gr.Textbox()
20
+ b1 = gr.Button("Transcribe porfa")
21
+ b1.click(audio_a_text, inputs=audio, outputs=texto)
22
+
23
+ b2 = gr.Button("Clasifica porfa el sentimiento")
24
+ label = gr.Label()
25
+ b2.click(texto_a_sentimiento, inputs=texto, outputs=label)
26
+
27
+ demo.launch()