raffaelsiregar commited on
Commit
d5fa086
·
verified ·
1 Parent(s): 49cd5f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -147,18 +147,26 @@ def predict(wave):
147
  with torch.no_grad():
148
  prediction = model(wave)
149
  predicted_emotion, confidence = decode_emotion_prediction(prediction, le)
150
- return f"Predicted emotion: {predicted_emotion} (Confidence: {confidence:.2f})"
151
  except Exception as e:
152
  return f'Error in processing audio: {str(e)}'
153
 
154
  # Gradio Interface
 
 
 
 
 
 
 
155
  iface = gr.Interface(
156
  fn=predict,
157
  inputs=gr.Audio(sources="microphone", type="filepath"),
158
  outputs="text",
159
  live=True,
160
  title="Speech Emotion Recognition",
161
- description="Record your voice and get the predicted emotion."
 
162
  )
163
 
164
  iface.launch()
 
147
  with torch.no_grad():
148
  prediction = model(wave)
149
  predicted_emotion, confidence = decode_emotion_prediction(prediction, le)
150
+ return f"Predicted emotion: {predicted_emotion} (Confidence: {confidence*100:.4f})"
151
  except Exception as e:
152
  return f'Error in processing audio: {str(e)}'
153
 
154
  # Gradio Interface
155
+ article = """
156
+ ### How It Works
157
+ - The model classifies the speech emotion given into 6 emotions (Angry, Happy, Sad, Disgusting, Fear, Neutral)
158
+ - It returns the highest chance of the emotion and its confidence level.
159
+ - This tool is built with CNN Architecture combined with LSTM Architecture.
160
+ """
161
+
162
  iface = gr.Interface(
163
  fn=predict,
164
  inputs=gr.Audio(sources="microphone", type="filepath"),
165
  outputs="text",
166
  live=True,
167
  title="Speech Emotion Recognition",
168
+ description="Record your voice and get the predicted emotion.",
169
+ article=article
170
  )
171
 
172
  iface.launch()