Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 audio2text(audio):
|
8 |
+
text = trans(audio)["text"]
|
9 |
+
return text
|
10 |
+
|
11 |
+
def text2sentiment(text):
|
12 |
+
return clasificador(text)[0]["label"]
|
13 |
+
|
14 |
+
demo=gr.Blocks()
|
15 |
+
with demo:
|
16 |
+
gr.Markdown("Gradio + Blocks + TabItem")
|
17 |
+
with gr.Tabs():
|
18 |
+
with gr.TabItem("Transcribe audio en espanol"):
|
19 |
+
with gr.Row():
|
20 |
+
audio=gr.Audio(sources="microphone",type="filepath")
|
21 |
+
transcripcion=gr.Textbox()
|
22 |
+
b1=gr.Button("Transcribe")
|
23 |
+
|
24 |
+
with gr.TabItem("Analisis de sentimiento en espanol"):
|
25 |
+
with gr.Row():
|
26 |
+
text=gr.Textbox()
|
27 |
+
label=gr.Label()
|
28 |
+
b2=gr.Button("Sentimiento")
|
29 |
+
|
30 |
+
b1.click(audio2text,inputs=audio,outputs=transcripcion)
|
31 |
+
b2.click(text2sentiment,inputs=text,outputs=label)
|
32 |
+
|
33 |
+
demo.launch()
|