cagucor commited on
Commit
de7a838
·
verified ·
1 Parent(s): e3f927b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ model_id = "pollner/distilhubert-finetuned-ravdess"
5
+ classifier = pipeline("audio-classification", model=model_id)
6
+
7
+ def classify_audio(audio_file):
8
+ # audio_file is path or file object
9
+ result = classifier(audio_file)
10
+ return result
11
+
12
+ iface = gr.Interface(
13
+ fn=classify_audio,
14
+ inputs=gr.Audio(source="upload", type="filepath"),
15
+ outputs=gr.JSON(label="Classification result"),
16
+ title="Emotion recognition from speech (RAVDESS)",
17
+ description="Classifies emotion from audio using distilhubert-finetuned-ravdess"
18
+ )
19
+
20
+ iface.launch()