from transformers import pipeline import gradio as gr import os model_id = "burraco135/ast-finetuned-audioset-10-10-0.4593-finetuned-gtzan" 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(type="filepath"), outputs=gr.outputs.Label(), examples=[ ["around_the_world-atc.wav"], ["mambo_no_5-lou_bega.wav"], ], ) demo.launch(debug=True)