Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
modelo = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish") | |
classificador = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis") | |
image_clasificacion = pipeline("image-classification", model="microsoft/swin-tiny-patch4-window7-224",) | |
def audio_text(audio): | |
text = modelo(audio)["text"] | |
return text | |
def texto_sentimiento(text): | |
return classificador(text)[0]["label"] | |
def clasificacion_imagen(image): | |
label = image_clasificacion(image)[0]["label"] | |
return label | |
demo = gr.Blocks() | |
with demo: | |
gr.Markdown("Este es el sengundo demo con Block") | |
with gr.Tabs(): | |
with gr.TabItem("Transcribe audio en español"): | |
with gr.Row(): | |
audio = gr.Audio(source="microphone", type="filepath") | |
transcripcion = gr.Textbox() | |
b1 = gr.Button("Transcribe porfis") | |
with gr.TabItem("Análisis de sentimientos en español"): | |
with gr.Row(): | |
texto = gr.Textbox() | |
label = gr.Label() | |
b2 = gr.Button("Sentimiento porfa") | |
with gr.TabItem("Clasificación de imagenes"): | |
with gr.Row(): | |
image = gr.Image(label="Carga una imagen aquí",type="pil") | |
label_img = gr.Label() | |
b3 = gr.Button("Clasifica por fa") | |
b1.click(audio_text, inputs = audio, outputs = transcripcion) | |
b2.click(texto_sentimiento, inputs=texto, outputs=label) | |
b3.click(clasificacion_imagen, inputs=image, outputs=label_img) | |
demo.launch() |