ceefax/GenreClassification
0
1from transformers import pipeline2import gradio as gr3 4pipe = pipeline(5 "audio-classification", model="ceefax/distilhubert-finetuned-gtzan"6)7 8model_id = "ceefax/distilhubert-finetuned-gtzan"9pipe = pipeline("audio-classification", model=model_id)10title = "Genre Classifier"11description = "Genre classifier trained on GTZAN"12examples = ['Fleshy.mp3', 'Kombucha.mp3']13interpretation='default'14enable_queue=True15 16def classify_audio(filepath):17 preds = pipe(filepath)18 outputs = {}19 for p in preds:20 outputs[p["label"]] = p["score"]21 return outputs22 23demo = gr.Interface(24 fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label(), title=title,description=description25 ,examples=examples26 ,interpretation=interpretation,enable_queue=enable_queue27).launch()28 