Text_analyzer / app.py
NeerAbhy's picture
Update app.py
7f8cb6d verified
raw
history blame
816 Bytes
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()