from reader import get_article import gradio as gr from transformers import pipeline info = get_article() #Model_1 = "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD" #Model_2 ="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd" #model_name2id = {"Model A": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD", "Model B": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"} def classify_sentiment(audio): pipe = pipeline("audio-classification", model="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD") pred = pipe(audio) return {dic["label"]: dic["score"] for dic in pred} input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio")] label = gr.outputs.Label(num_top_classes=5) ################### Gradio Web APP ################################ #title = "Audio Sentiment Classifier" description = """

This application classifies the sentiment of the audio input provided by the user. #
#

#
#logo #
""" #gr.Interface( #fn = classify_sentiment, #inputs = input_audio, #outputs = label, #examples=[["basta_neutral.wav"], ["detras_disgust.wav"], ["mortal_sadness.wav"], ["respiracion_happiness.wav"], ["robo_fear.wav"]], #title = "🔊 Audio Sentiment Classifier", #description = "Demostración de Gradio para la clasificación de sentimientos de audios usando Wav2Vec2", #theme="huggingface").launch() # generate and launch interface interface = gr.Interface(fn=classify_sentiment, inputs=input_audio, outputs=label, examples=[["basta_neutral.wav"], ["detras_disgust.wav"], ["mortal_sadness.wav"], ["respiracion_happiness.wav"], ["robo_fear.wav"]], article=info['article'], css=info['css'], theme='huggingface', title=info['title'], allow_flagging='never', description=info['description']) interface.launch()