Spaces:
Runtime error
Runtime error
DrishtiSharma
commited on
Commit
•
a92da65
1
Parent(s):
c6ac9ff
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,17 @@
|
|
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 |
-
|
9 |
-
|
|
|
|
|
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([
|
14 |
label = gr.outputs.Label(num_top_classes=5)
|
15 |
|
16 |
################### Gradio Web APP ################################
|
@@ -36,6 +38,6 @@ gr.Interface(
|
|
36 |
fn = classify_sentiment,
|
37 |
inputs = input_audio,
|
38 |
outputs = label,
|
39 |
-
examples=[["basta_neutral.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 |
+
model_name2id = {"Model A": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-classification-MESD", "Model B": "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"}
|
9 |
+
|
10 |
+
def classify_sentiment(audio, model_name):
|
11 |
+
pipe = pipeline("audio-classification", model=model_name2id[model_name])
|
12 |
pred = pipe(audio)
|
13 |
return {dic["label"]: dic["score"] for dic in pred}
|
14 |
|
15 |
+
input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), gr.inputs.Dropdown([model_name2id[model_name], model_name2id[model_name]], label="Model Name")]
|
16 |
label = gr.outputs.Label(num_top_classes=5)
|
17 |
|
18 |
################### Gradio Web APP ################################
|
|
|
38 |
fn = classify_sentiment,
|
39 |
inputs = input_audio,
|
40 |
outputs = label,
|
41 |
+
examples=[["basta_neutral.wav", model_name2id[model_name]], ["detras_disgust.wav", model_name2id[model_name]], ["mortal_sadness.wav", model_name2id[model_name]], ["respiracion_happiness.wav", model_name2id[model_name]], ["robo_fear.wav", model_name2id[model_name]]],
|
42 |
theme="grass").launch()
|
43 |
|