Ashish08 commited on
Commit
b0d7c96
1 Parent(s): f5cecbb

Upload app.py

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