Download app.py from BOENE/boene: direct link, hf CLI and curl.
- Browser
- Download file 453 Bytes
-
https://huggingface.co/spaces/BOENE/boene/resolve/main/app.py
- Command line
-
hf download hf://spaces/BOENE/boene/app.py
-
curl -L -o app.py https://huggingface.co/spaces/BOENE/boene/resolve/main/app.py
453 Bytes
| 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() | |