Tirath5504
commited on
Commit
•
54f3543
1
Parent(s):
f6a5198
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_id = "Tirath5504/distilhubert-finetuned-gtzan"
|
5 |
+
pipe = pipeline("audio-classification", model=model_id)
|
6 |
+
|
7 |
+
def classify_audio(filepath):
|
8 |
+
preds = pipe(filepath)
|
9 |
+
outputs = {}
|
10 |
+
for p in preds:
|
11 |
+
outputs[p["label"]] = p["score"]
|
12 |
+
return outputs
|
13 |
+
|
14 |
+
demo = gr.Interface(
|
15 |
+
fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
|
16 |
+
)
|
17 |
+
demo.launch(debug=True)
|