raffaelsiregar commited on
Commit
19be4d5
·
verified ·
1 Parent(s): fc7fc7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -10
app.py CHANGED
@@ -150,13 +150,38 @@ def predict(wave):
150
  return f"Predicted emotion: {predicted_emotion} (Confidence: {confidence:.2f})"
151
 
152
  # Gradio Interface
153
- iface = gr.Interface(
154
- fn=predict,
155
- inputs=gr.Audio(sources="microphone", type="filepath"),
156
- outputs="text",
157
- live=True,
158
- title="Speech Emotion Recognition",
159
- description="Record your voice and get the predicted emotion."
160
- )
161
-
162
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  return f"Predicted emotion: {predicted_emotion} (Confidence: {confidence:.2f})"
151
 
152
  # Gradio Interface
153
+ # iface = gr.Interface(
154
+ # fn=predict,
155
+ # inputs=gr.Audio(sources="microphone", type="filepath"),
156
+ # outputs="text",
157
+ # live=True,
158
+ # title="Speech Emotion Recognition",
159
+ # description="Record your voice and get the predicted emotion."
160
+ # )
161
+
162
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
163
+ gr.Markdown("# Emotion Recognition App")
164
+ gr.Markdown("Upload an audio file or record directly to get a prediction")
165
+
166
+ with gr.Row():
167
+ audio_input = gr.Audio(sources="microphone", type="filepath")
168
+ audio_output = gr.Audio(label="Processed Audio")
169
+
170
+ with gr.Row():
171
+ submit_btn = gr.Button("Get Prediction", variant="primary")
172
+ clear_btn = gr.Button("Clear")
173
+
174
+ prediction_output = gr.Textbox(label="Prediction")
175
+
176
+ submit_btn.click(
177
+ fn=predict,
178
+ inputs=[audio_input],
179
+ outputs=[audio_output, prediction_output]
180
+ )
181
+
182
+ clear_btn.click(
183
+ fn=lambda: (None, None, ""),
184
+ outputs=[audio_input, audio_output, prediction_output]
185
+ )
186
+
187
+ demo.launch()