Spaces:
Sleeping
Sleeping
File size: 654 Bytes
b165631 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
# Load audio classification pipeline
classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-ks")
def classify_audio(file_path):
# Hugging Face audio pipeline works best with a filepath
return classifier(file_path)
# Gradio UI
demo = gr.Interface(
fn=classify_audio,
inputs=gr.Audio(type="filepath", label="Upload or Record Audio"),
outputs=gr.Label(num_top_classes=5),
title="Audio Classification App",
description="Upload or record an audio file (mp3, wav, flac, etc.) and classify the sound."
)
if __name__ == "__main__":
demo.launch()
|