Spaces:
Runtime error
Runtime error
DrishtiSharma
commited on
Commit
•
3e1fc67
1
Parent(s):
dafd3fc
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,12 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
|
5 |
-
|
6 |
def classify_sentiment(audio, model):
|
7 |
pipe = pipeline("audio-classification", model=model)
|
8 |
-
|
9 |
-
return
|
10 |
-
|
11 |
-
#def classify_sentiment(audio, model):
|
12 |
-
#pipe = pipeline("audio-classification", model=model)
|
13 |
-
#sentiment_classifier = pipe(audio)
|
14 |
-
|
15 |
-
#preds_dict={}
|
16 |
-
#for sentiment_classifier in preds[0]:
|
17 |
-
#preds_dict[pred['label']] = pred['score']
|
18 |
-
|
19 |
-
return preds_dict
|
20 |
|
21 |
input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), gr.inputs.Dropdown(["DrishtiSharma/wav2vec2-base-finetuned-sentiment-mesd-v11", "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"], label="Model Name")]
|
22 |
label = gr.outputs.Label(num_top_classes=5)
|
@@ -27,3 +17,4 @@ gr.Interface(
|
|
27 |
outputs = label,
|
28 |
#examples=[["test1.wav", "DrishtiSharma/wav2vec2-base-finetuned-sentiment-mesd-v11"], ["test2.wav", "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"]],
|
29 |
theme="grass").launch()
|
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
|
|
|
6 |
def classify_sentiment(audio, model):
|
7 |
pipe = pipeline("audio-classification", model=model)
|
8 |
+
pred = pipe(audio)
|
9 |
+
return {dic["label"]: dic["score"] for dic in pred}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
input_audio = [gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), gr.inputs.Dropdown(["DrishtiSharma/wav2vec2-base-finetuned-sentiment-mesd-v11", "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"], label="Model Name")]
|
12 |
label = gr.outputs.Label(num_top_classes=5)
|
|
|
17 |
outputs = label,
|
18 |
#examples=[["test1.wav", "DrishtiSharma/wav2vec2-base-finetuned-sentiment-mesd-v11"], ["test2.wav", "hackathon-pln-es/wav2vec2-base-finetuned-sentiment-mesd"]],
|
19 |
theme="grass").launch()
|
20 |
+
|