create app.y
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load model
|
| 5 |
+
classifier = pipeline("audio-classification", model="yourusername/keyword-spotting-model")
|
| 6 |
+
|
| 7 |
+
def predict(audio):
|
| 8 |
+
preds = classifier(audio)
|
| 9 |
+
return {p["label"]: p["score"] for p in preds}
|
| 10 |
+
|
| 11 |
+
# Gradio UI
|
| 12 |
+
gr.Interface(
|
| 13 |
+
fn=predict,
|
| 14 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
| 15 |
+
outputs=gr.Label(num_top_classes=3),
|
| 16 |
+
title="🔊 Keyword Spotting",
|
| 17 |
+
examples=["example1.wav", "example2.wav"]
|
| 18 |
+
).launch()
|