Spaces:
Runtime error
Runtime error
Added comments
Browse files
app.py
CHANGED
|
@@ -2,11 +2,14 @@ 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():
|
|
@@ -15,6 +18,7 @@ with gr.Blocks() as demo:
|
|
| 15 |
output2 = gr.Textbox(label="Text emotion")
|
| 16 |
btn = gr.Button("Analyze audio")
|
| 17 |
|
|
|
|
| 18 |
gr.Examples(
|
| 19 |
[
|
| 20 |
os.path.join(os.path.dirname(__file__), "audio/a_good_dream.wav"),
|
|
@@ -24,6 +28,7 @@ with gr.Blocks() as demo:
|
|
| 24 |
label="Examples of cases in which speech and words can convey different"
|
| 25 |
)
|
| 26 |
|
|
|
|
| 27 |
btn.click(fn=infere_voice2text, inputs=input, outputs=output0)
|
| 28 |
btn.click(fn=infere_speech_emotion, inputs=input, outputs=output1)
|
| 29 |
output0.change(fn=infere_text_emotion, inputs=output0, outputs=output2)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from models import infere_speech_emotion, infere_text_emotion, infere_voice2text
|
| 4 |
|
| 5 |
+
# Create a Gradio app object
|
| 6 |
with gr.Blocks() as demo:
|
| 7 |
+
# HTML titles
|
| 8 |
gr.HTML('''
|
| 9 |
<h1 style="text-align:center;">Speech and Text Emotion Recognition</h1>
|
| 10 |
<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>
|
| 11 |
''')
|
| 12 |
+
# Input and output fields
|
| 13 |
with gr.Row():
|
| 14 |
input = gr.Audio(label="Audio File", type="filepath")
|
| 15 |
with gr.Column():
|
|
|
|
| 18 |
output2 = gr.Textbox(label="Text emotion")
|
| 19 |
btn = gr.Button("Analyze audio")
|
| 20 |
|
| 21 |
+
# Examples to be used as input
|
| 22 |
gr.Examples(
|
| 23 |
[
|
| 24 |
os.path.join(os.path.dirname(__file__), "audio/a_good_dream.wav"),
|
|
|
|
| 28 |
label="Examples of cases in which speech and words can convey different"
|
| 29 |
)
|
| 30 |
|
| 31 |
+
# Input-output logic based on button click
|
| 32 |
btn.click(fn=infere_voice2text, inputs=input, outputs=output0)
|
| 33 |
btn.click(fn=infere_speech_emotion, inputs=input, outputs=output1)
|
| 34 |
output0.change(fn=infere_text_emotion, inputs=output0, outputs=output2)
|