import os import gradio as gr from models import infere_speech_emotion, infere_text_emotion, infere_voice2text with gr.Blocks() as demo: gr.HTML('''

Speech and Text Emotion Recognition

Determining someone's emotions can be challenging based solely on their tone or words
This app uses both to provide a more accurate analysis of emotional expression in a single audio recording

''') with gr.Row(): input = gr.Audio(label="Audio File", type="filepath") with gr.Column(): output0 = gr.Textbox(label="Text from the audio") output1 = gr.Textbox(label="Speech emotion") output2 = gr.Textbox(label="Text emotion") btn = gr.Button("Analyze audio") btn.click(fn=infere_voice2text, inputs=input, outputs=output0) btn.click(fn=infere_speech_emotion, inputs=input, outputs=output1) output0.change(fn=infere_text_emotion, inputs=output0, outputs=output2) gr.HTML('''

View examples of how speech and words can convey different emotions by clicking below

''') gr.Examples( [ os.path.join(os.path.dirname(__file__), "audio/a_good_dream.wav"), os.path.join(os.path.dirname(__file__), "audio/hype_in_ai.wav"), ], input ) demo.launch()