|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline("audio-classification", model="MIT/ast-finetuned-audioset-10-10-0.4593") |
|
|
|
|
|
def classify_audio(audio): |
|
result = pipe(audio) |
|
return {label['label']: label['score'] for label in result} |
|
|
|
|
|
app = gr.Interface( |
|
fn=classify_audio, |
|
inputs=gr.Audio(type="filepath"), |
|
outputs=gr.Label(num_top_classes=3), |
|
title="Audio Classification", |
|
description="Upload an audio file to classify it using MIT's fine-tuned AudioSet model." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
app.launch() |
|
|