Spaces:
Sleeping
Sleeping
File size: 816 Bytes
7f8cb6d |
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 |
import gradio as gr
from transformers import pipeline
transcription = pipeline("automatic-speech-recognition", model = "facebook/wav2vec2-large-xlsr-53-spanish")
clasification = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
def audio_a_text(audio):
text = transcription(audio)["text"]
return text
def text_to_sentimient(audio):
text = transcription(audio)["text"]
return clasification(text)[0]["label"]
demo = gr.Blocks()
with demo:
gr.Markdown("Speech analyzer")
audio = gr.Audio(type="filepath", label = "Upload a file")
text = gr.Textbox()
b1 = gr.Button("convert to text")
b1.click(audio_a_text, inputs=audio, outputs=text)
b2 = gr.Button("Classification of speech")
b2.click(text_to_sentimient, inputs=audio, outputs=text)
demo.launch()
|