Spaces:
Running
Running
File size: 503 Bytes
80600ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
import librosa
from transformers import pipeline
pipe = pipeline("audio-classification", model="lewtun/distilhubert-finetuned-gtzan-og")
def classify_audio(filepath):
audio, sampling_rate = librosa.load(filepath, sr=16_000)
preds = pipe(audio)
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)
demo.launch() |