hp1318 commited on
Commit
f44f3a3
·
1 Parent(s): 2cb6d8a

Added Gradio app

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