rodragon737 commited on
Commit
d2eab53
β€’
1 Parent(s): abdad46

SentimientosUBA

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Sentimientos y Tabs")
18
+ with gr.Tabs():
19
+ with gr.TabItem("escribiendo en EspaΓ±ol"):
20
+ with gr.Row():
21
+ audio = gr.Audio(source="microphone", type="filepath")
22
+ escrito = gr.Textbox()
23
+ b1 = gr.Button("Escribe lo hablado")
24
+
25
+ with gr.TabItem("Grado de Satisfaccion"):
26
+ with gr.Row():
27
+ texto=gr.Textbox()
28
+ label=gr.Label()
29
+ b2=gr.Button("ΒΏComo se Sintio?")
30
+
31
+ b1.click(audio_a_text, inputs=audio, outputs=escrito)
32
+ b2.click(texto_a_sentimiento, inputs=texto, outputs=label)
33
+
34
+ demo.launch()