Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| model_id = "Ihssane123/distilhubert-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.Label() | |
| ) | |
| demo = gr.Interface( | |
| fn=classify_audio, | |
| inputs=gr.Audio(type="filepath"), | |
| outputs=gr.Label(), | |
| title="Music Genre Classifier", | |
| description="""<div style="text-align: center; margin-bottom: 10px"> | |
| <p style="font-size: 16px; color: #555; font-style: italic;"> | |
| This demo is based on the <span style="color: #007bff; font-weight: bold;"><a href="https://huggingface.co/learn/audio-course/en/chapter4/demo">Hugging Face audio course Unit 4</a></span>, | |
| demonstrating a music genre classifier built with Gradio. | |
| </p> | |
| </div>""" | |
| ) | |
| demo.launch(debug=True) |