Julian Arango commited on
Commit
2ce5d1e
·
unverified ·
1 Parent(s): 93a0bd6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from models import infere_speech_emotion, infere_text_emotion, infere_voice2text
4
+
5
+ with gr.Blocks() as demo:
6
+ gr.HTML('''
7
+ <h1 style="text-align:center;">Speech and Text Emotion Recognition</h1>
8
+ <h2 style="text-align:center;">Determining someone's emotions can be challenging based solely on their tone or words <br> This app uses both to provide a more accurate analysis of emotional expression in a single audio recording</h2>
9
+ ''')
10
+ with gr.Row():
11
+ input = gr.Audio(label="Audio File", type="filepath")
12
+ with gr.Column():
13
+ output0 = gr.Textbox(label="Text from the audio")
14
+ output1 = gr.Textbox(label="Speech emotion")
15
+ output2 = gr.Textbox(label="Text emotion")
16
+ btn = gr.Button("Analyze audio")
17
+
18
+ btn.click(fn=infere_voice2text, inputs=input, outputs=output0)
19
+ btn.click(fn=infere_speech_emotion, inputs=input, outputs=output1)
20
+ output0.change(fn=infere_text_emotion, inputs=output0, outputs=output2)
21
+
22
+ gr.HTML('''
23
+ <br>
24
+ <h3 style="text-align:center;">View examples of how speech and words can convey different emotions by clicking below</h3>
25
+ ''')
26
+
27
+ gr.Examples(
28
+ [
29
+ os.path.join(os.path.dirname(__file__), "audio/a_good_dream.wav"),
30
+ os.path.join(os.path.dirname(__file__), "audio/hype_in_ai.wav"),
31
+ ],
32
+ input
33
+ )
34
+
35
+ demo.launch()