Gztavo commited on
Commit
3ac7f3e
1 Parent(s): a740b38

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_to_text(audio):
8
+ text = trans(audio)["text"]
9
+ return text
10
+
11
+ def text_to_feel(text):
12
+ return clasificador(text)[0]["label"]
13
+
14
+ demo = gr.Blocks()
15
+ with demo:
16
+ gr.Markdown("Demo de blocks")
17
+ with gr.Tabs():
18
+ with gr.TabItem("trans"):
19
+ with gr.Row():
20
+ audio = gr.Audio(source="microphone", type="filepath")
21
+ transcription = gr.Textbox()
22
+ b1 = gr.Button("Transcribe pf")
23
+ with gr.TabItem("sent"):
24
+ with gr.Row():
25
+ texto = gr.Textbox()
26
+ label = gr.Label()
27
+ b2 = gr.Button("Sent porfa")
28
+
29
+ b1.click(audio_to_text, inputs=audio, outputs=transcription)
30
+ b2.click(text_to_feel, inputs=texto, outputs=label)
31
+
32
+ demo.launch()