Spaces:
Running
Running
File size: 519 Bytes
80600ce 1b12cb6 80600ce 1b12cb6 80600ce f8c567c 80600ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from transformers import pipeline
model_id = "lewtun/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
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() |