File size: 479 Bytes
0ad9e83
 
 
aedb206
0ad9e83
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from transformers import pipeline

model_id = "SeyedAli/Musical-genres-Classification-Hubert-V1"
pipe = pipeline("audio-classification", model=model_id)

def classify_audio(filepath):
    preds = pipe(filepath)
    outputs = {}
    for p in preds:
        outputs[p["label"]] = p["score"]
    return outputs

demo = gr.Interface(
    fn=classify_audio, inputs=gr.Audio(label="Input Music",type="filepath"), outputs=gr.outputs.Label()
)
demo.launch(debug=True)