Metantropia's picture
Create app.py
b4f686e verified
raw
history blame
768 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 para la clase de Platzi")
audio=gr.Audio(sources="microphone",type="filepath")
texto=gr.Textbox()
b1=gr.Button("Transcribe")
b1.click(audio2text,inputs=audio,outputs=texto)
label=gr.Label()
b2=gr.Button("Clasifica el sentimiento")
b2.click(text2sentimiento,inputs=texto,outputs=label)
demo.launch()