boene / app.py
BOENE's picture
Update app.py
36b6249 verified
raw
history blame
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()