Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,18 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
examples = [["Adventurer is approached by a mysterious stranger in the tavern for a new quest."]]
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
|
3 |
+
model_id = "sanchit-gandhi/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)
|