udaykumar351's picture
Update app.py
ce74472 verified
raw
history blame
696 Bytes
# audio_classification_app.py
import gradio as gr
from transformers import pipeline
# Load pipeline (pretrained model)
classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-ks")
def classify_audio(audio):
# audio is a tuple: (sample_rate, numpy array)
if audio is None:
return "No audio provided"
return classifier(audio)
with gr.Blocks() as demo:
gr.Markdown("## 🎵 Audio Classification (Keyword Spotting)")
with gr.Row():
audio_input = gr.Audio(sources=["microphone", "upload"], type="numpy")
output = gr.JSON()
audio_input.change(classify_audio, audio_input, output)
if __name__ == "__main__":
demo.launch()