rodragon737's picture
SentimientosUBA
d2eab53
raw
history blame
994 Bytes
import gradio as gr
from transformers import pipeline
trans = pipeline("automatic-speech-recognition", model = "facebook/wav2vec2-large-xlsr-53-spanish")
clasificador = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
def audio_a_text(audio):
text = trans(audio)["text"]
return text
def texto_a_sentimiento(text):
return clasificador(text)[0]["label"]
demo = gr.Blocks()
with demo:
gr.Markdown("Demo Sentimientos y Tabs")
with gr.Tabs():
with gr.TabItem("escribiendo en EspaΓ±ol"):
with gr.Row():
audio = gr.Audio(source="microphone", type="filepath")
escrito = gr.Textbox()
b1 = gr.Button("Escribe lo hablado")
with gr.TabItem("Grado de Satisfaccion"):
with gr.Row():
texto=gr.Textbox()
label=gr.Label()
b2=gr.Button("ΒΏComo se Sintio?")
b1.click(audio_a_text, inputs=audio, outputs=escrito)
b2.click(texto_a_sentimiento, inputs=texto, outputs=label)
demo.launch()