Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
)
|
6 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
# Load the model from Hugging Face space
|
6 |
+
model = pipeline(task="audio-classification", model="your-username/model-name")
|
7 |
+
|
8 |
+
def classify_audio(audio_file):
|
9 |
+
# Perform inference using the Hugging Face model
|
10 |
+
result = model(audio_file.read())
|
11 |
+
return result[0]["label"]
|
12 |
+
|
13 |
+
# Gradio Interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=classify_audio,
|
16 |
+
inputs=gr.Audio(type="file", label="Upload or Record Audio"),
|
17 |
+
outputs=gr.Textbox(),
|
18 |
+
live=True,
|
19 |
)
|
20 |
+
|
21 |
+
# Launch the Gradio interface
|
22 |
+
iface.launch()
|