Spaces:
Sleeping
Sleeping
Created app file
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
pipe = pipeline(
|
5 |
+
"audio-classification", model="ceefax/distilhubert-finetuned-gtzan"
|
6 |
+
)
|
7 |
+
|
8 |
+
model_id = "ceefax/distilhubert-finetuned-gtzan"
|
9 |
+
pipe = pipeline("audio-classification", model=model_id)
|
10 |
+
title = "Genre Classifier"
|
11 |
+
description = "Genre classifier trained on GTZAN"
|
12 |
+
# examples = ['/content/Trumpet_to_ambient_music.wav']
|
13 |
+
interpretation='default'
|
14 |
+
enable_queue=True
|
15 |
+
|
16 |
+
def classify_audio(filepath):
|
17 |
+
preds = pipe(filepath)
|
18 |
+
outputs = {}
|
19 |
+
for p in preds:
|
20 |
+
outputs[p["label"]] = p["score"]
|
21 |
+
return outputs
|
22 |
+
|
23 |
+
demo = gr.Interface(
|
24 |
+
fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label(), title=title,description=description
|
25 |
+
# ,examples=examples
|
26 |
+
,interpretation=interpretation,enable_queue=enable_queue
|
27 |
+
).launch()
|