Spaces:
Runtime error
Runtime error
File size: 789 Bytes
e532a54 b1444b4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
from transformers import pipeline
import gradio as gr
#jonatasgrosman/wav2vec2-large-xlsr-53-spanish
asr = pipeline("automatic-speech-recognition", "jonatasgrosman/wav2vec2-large-xlsr-53-spanish")
classifier = pipeline("text-classification", "finiteautomata/beto-sentiment-analysis")
def speech_to_text(speech):
text = asr(speech)["text"]
return text
def text_to_sentiment(text):
return classifier(text)[0]["label"]
demo = gr.Blocks()
with demo:
audio_file = gr.Audio(type="filepath")
text = gr.Textbox()
label = gr.Label()
b1 = gr.Button("Recognize Speech")
b2 = gr.Button("Classify Sentiment")
b1.click(speech_to_text, inputs=audio_file, outputs=text)
b2.click(text_to_sentiment, inputs=text, outputs=label)
demo.launch()
#inline=false |