Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
model_id = "Ryukijano/distilhubert-finetuned-gtzan"
|
| 4 |
+
pipe = pipeline("audio-classification", model=model_id)
|
| 5 |
+
|
| 6 |
+
def classify_audio(filepath):
|
| 7 |
+
preds = pipe(filepath)
|
| 8 |
+
outputs = {}
|
| 9 |
+
for p in preds:
|
| 10 |
+
outputs[p["label"]] = p["score"]
|
| 11 |
+
return outputs
|
| 12 |
+
|
| 13 |
+
import gradio as gr
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
|
| 17 |
+
)
|
| 18 |
+
demo.launch(debug=True)
|
| 19 |
+
|