franco1102 commited on
Commit
d300616
1 Parent(s): 829e3db

create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ classificador = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
6
+
7
+ def audio_a_texto(audio):
8
+ text = trans(audio)['text']
9
+ return text
10
+
11
+
12
+ def texto_a_sentimiento(text):
13
+ return classificador(text)[0]["label"]
14
+
15
+
16
+
17
+ demo = gr.Blocks()
18
+
19
+ with demo:
20
+ gr.Markdown("Second demo with Blocks")
21
+ with gr.Tabs():
22
+ with gr.TabItem("Transcribe audio"):
23
+ with gr.Row():
24
+ audio = gr.Audio(source="microphone", type = "filepath")
25
+ transcription = gr.Textbox()
26
+ b1 = gr.Button("Transcribe Audio")
27
+ #b1.click(fn=)
28
+ with gr.TabItem("Sentiment Analysis"):
29
+ with gr.Row():
30
+ text = gr.Textbox()
31
+ label = gr.Label()
32
+ b2 = gr.Button('Classify')
33
+
34
+ b1.click(audio_a_texto, inputs = audio, outputs = transcription)
35
+ b2.click(texto_a_sentimiento, inputs = text, outputs = label)
36
+
37
+ demo.launch()