Spaces:
Runtime error
Runtime error
Commit
·
fa3b519
1
Parent(s):
644e4ef
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,15 @@
|
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
def classify_sentiment(audio):
|
9 |
pipe = pipeline("audio-classification", model="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD")
|
10 |
pred = pipe(audio)
|
11 |
return {dic["label"]: dic["score"] for dic in pred}
|
12 |
|
13 |
-
input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"),
|
14 |
label = gr.outputs.Label(num_top_classes=5)
|
15 |
|
16 |
################### Gradio Web APP ################################
|
@@ -36,6 +36,6 @@ gr.Interface(
|
|
36 |
fn = classify_sentiment,
|
37 |
inputs = input_audio,
|
38 |
outputs = label,
|
39 |
-
examples=[["basta_neutral.wav"], ["detras_disgust.wav"], ["mortal_sadness.wav"], ["respiracion_happiness.wav"], ["robo_fear.wav"]],
|
40 |
theme="grass").launch()
|
41 |
|
|
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
Model_1 = "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD"
|
6 |
+
Model_2 ="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"
|
7 |
|
8 |
def classify_sentiment(audio):
|
9 |
pipe = pipeline("audio-classification", model="hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD")
|
10 |
pred = pipe(audio)
|
11 |
return {dic["label"]: dic["score"] for dic in pred}
|
12 |
|
13 |
+
input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), gr.inputs.Dropdown([Model_1, Model_2], label="Model Name")]
|
14 |
label = gr.outputs.Label(num_top_classes=5)
|
15 |
|
16 |
################### Gradio Web APP ################################
|
|
|
36 |
fn = classify_sentiment,
|
37 |
inputs = input_audio,
|
38 |
outputs = label,
|
39 |
+
examples=[["basta_neutral.wav", Model_1], ["detras_disgust.wav", Model_1], ["mortal_sadness.wav", Model_1], ["respiracion_happiness.wav", Modle_1], ["robo_fear.wav", Model_1]],
|
40 |
theme="grass").launch()
|
41 |
|