Terps commited on
Commit
97598cb
1 Parent(s): 29dd32b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ model_id = "terps/distilhubert-finetuned-gtzan"
5
+ pipe = pipeline("audio-classification", model=model_id)
6
+
7
+ def classify_audio(filepath):
8
+ preds = pipe(filepath)
9
+ outputs = {}
10
+ for p in preds:
11
+ outputs[p["label"]] = p["score"]
12
+ return outputs
13
+
14
+ demo = gr.Interface(
15
+ fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
16
+ )
17
+ demo.launch(debug=True)