Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
modelo = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish")
|
5 |
+
classificador = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
|
6 |
+
image_clasificacion = pipeline("image-classification", model="microsoft/swin-tiny-patch4-window7-224",)
|
7 |
+
|
8 |
+
def audio_text(audio):
|
9 |
+
text = modelo(audio)["text"]
|
10 |
+
return text
|
11 |
+
|
12 |
+
def texto_sentimiento(text):
|
13 |
+
return classificador(text)[0]["label"]
|
14 |
+
|
15 |
+
def clasificacion_imagen(image):
|
16 |
+
label = image_clasificacion(image)[0]["label"]
|
17 |
+
return label
|
18 |
+
|
19 |
+
|
20 |
+
demo = gr.Blocks()
|
21 |
+
|
22 |
+
with demo:
|
23 |
+
gr.Markdown("Este es el sengundo demo con Block")
|
24 |
+
|
25 |
+
with gr.Tabs():
|
26 |
+
with gr.TabItem("Transcribe audio en español"):
|
27 |
+
with gr.Row():
|
28 |
+
audio = gr.Audio(source="microphone", type="filepath")
|
29 |
+
transcripcion = gr.Textbox()
|
30 |
+
b1 = gr.Button("Transcribe porfis")
|
31 |
+
|
32 |
+
with gr.TabItem("Análisis de sentimientos en español"):
|
33 |
+
with gr.Row():
|
34 |
+
texto = gr.Textbox()
|
35 |
+
label = gr.Label()
|
36 |
+
b2 = gr.Button("Sentimiento porfa")
|
37 |
+
|
38 |
+
with gr.TabItem("Clasificación de imagenes"):
|
39 |
+
with gr.Row():
|
40 |
+
image = gr.Image()
|
41 |
+
label_img = gr.Label()
|
42 |
+
b3 = gr.Button("Clasifica por fa")
|
43 |
+
b1.click(audio_text, inputs = audio, outputs = transcripcion)
|
44 |
+
b2.click(texto_sentimiento, inputs=texto, outputs=label)
|
45 |
+
b3.click(clasificacion_imagen, inputs=image, outputs=label_img)
|
46 |
+
|
47 |
+
|
48 |
+
demo.launch()
|