File size: 498 Bytes
d5f2cb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from transformers import pipeline

pipe = pipeline(task="audio-classification", model="thangtrungnguyen/vietnamese-female-male-voice-classification-model")

def classify_audio(filepath):
    preds = pipe(filepath)
    outputs = {}
    for p in preds:
        outputs[p["label"]] = p["score"]
    return outputs

gradio_app = gr.Interface(
    fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.Label()
)

if __name__ == "__main__":
    gradio_app.launch(debug=True)