import gradio as gr import librosa from transformers import pipeline pipe = pipeline("audio-classification", model="lewtun/distilhubert-finetuned-gtzan") def classify_audio(filepath): audio, sampling_rate = librosa.load(filepath, sr=16_000) preds = pipe(audio) outputs = {} for p in preds: outputs[p["label"]] = p["score"] return outputs label = gr.outputs.Label() demo = gr.Interface(fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=label, examples=[["song1.ogg"], ["song2.ogg"], ["song3.ogg"], ["song4.ogg"]],) demo.launch()