File size: 723 Bytes
0e77125
 
 
 
 
 
 
 
 
 
5908601
0e77125
 
 
 
bd2ddd9
 
0e77125
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

import gradio as gr
from speechbrain.pretrained.interfaces import foreign_class



def main_note(filepath):
    classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
    # out_prob, score, index, text_lab = classifier.classify_file("speechbrain/emotion-recognition-wav2vec2-IEMOCAP/anger.wav")
    out_prob, score, index, text_lab = classifier.classify_file(filepath)
    return f"classifer predicts this wave as {text_lab[0]} ; also out_prob is {out_prob}"


demo = gr.Interface(
    fn= main_note,
    inputs = gr.Audio(type="filepath"),
    outputs= "text"
)

if __name__ == "__main__":
    demo.launch()