SeyedAli commited on
Commit
0ad9e83
1 Parent(s): 372a37e

Create app.txt

Browse files
Files changed (1) hide show
  1. app.txt +17 -0
app.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ model_id = "sanchit-gandhi/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(label="Input Music",type="filepath"), outputs=gr.outputs.Label()
16
+ )
17
+ demo.launch(debug=True)