thangtrungnguyen commited on
Commit
d5f2cb5
1 Parent(s): a3f84b1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline(task="audio-classification", model="thangtrungnguyen/vietnamese-female-male-voice-classification-model")
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
+ gradio_app = gr.Interface(
14
+ fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.Label()
15
+ )
16
+
17
+ if __name__ == "__main__":
18
+ gradio_app.launch(debug=True)