File size: 1,713 Bytes
ce85da2
713e80d
0e5871d
713e80d
ce85da2
 
91d7849
3fb5e78
a92da65
3fb5e78
 
3e1fc67
 
0e5871d
3fb5e78
52deb65
0e5871d
23ac7a2
 
e3ad1ca
83f4f65
33da826
df80ac8
b571c89
a450122
2d81ba2
 
ce85da2
2d81ba2
afa09af
 
2d81ba2
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
from reader import get_article
import gradio as gr
from transformers import pipeline

info = get_article()


#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 ################################

description = """ Gradio demo for Sentiment Classification of Spanish audios using Wav2Vec2. We have fine-tuned two models for the aforementioned task i) [Model A](https://huggingface.co./hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD) ii) [Model B](https://huggingface.co./hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd)

Link to Processed MESD dataset: [Please Click Here](https://huggingface.co./datasets/hackathon-pln-es/MESD)

Note: The Audio examples provided for testing this app were randomly picked from the **TEST set**.
"""


# 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=description)
interface.launch() 

#info['description']