File size: 453 Bytes
36b6249
a7bbfe2
 
 
 
 
a0d3885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

from transformers import pipeline

model_id = "BOENE/distilhubert-finetuned-gtzan"
pipe = pipeline("audio-classification", model=model_id)

import gradio as gr

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(type="filepath"),
    outputs=gr.Label(),
    live=True
)
demo.launch()