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