import gradio as gr from transformers import pipeline # This links your Space to your specific AST model repository pipe = pipeline("audio-classification", model="aarya030402/ast_messy_mashup") def classify_audio(filepath): # The pipeline automatically handles the AST feature extraction and 16kHz resampling preds = pipe(filepath) outputs = {p["label"]: p["score"] for p in preds} return outputs # Build the Gradio Interface demo = gr.Interface( fn=classify_audio, inputs=gr.Audio(type="filepath", label="Upload Music Mashup (.wav)"), outputs=gr.Label(num_top_classes=5), title="AST Music Genre Classifier", description="Upload a 20-second audio clip to identify the genre using your fine-tuned Audio Spectrogram Transformer." ) if __name__ == "__main__": demo.launch()