arham061 commited on
Commit
fc5dd9a
1 Parent(s): 591a36f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1,6 +1,22 @@
1
  import gradio as gr
 
 
2
 
3
- demo = gr.Interface(
4
- fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs="label"
 
 
 
 
 
 
 
 
 
 
 
 
5
  )
6
- demo.launch(debug=True)
 
 
 
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()