jfforero commited on
Commit
424b15f
·
verified ·
1 Parent(s): 15be55e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -19,7 +19,7 @@ def load_emotion_model(model_path):
19
  print("Error loading emotion prediction model:", e)
20
  return None
21
 
22
- model_path = 'mymodel2_SER_LSTM_AUG_RAVDESS.h5'
23
  model = load_emotion_model(model_path)
24
 
25
  # Initialize WhisperModel
@@ -46,7 +46,7 @@ def extract_mfcc(wav_file_name):
46
  return None
47
 
48
  # Emotions dictionary
49
- emotions = {1: 'neutral', 2: 'calm', 3: 'happy', 4: 'sad', 5: 'angry', 6: 'fearful', 7: 'disgust', 8: 'surprised'}
50
 
51
  # Function to predict emotion from audio
52
  def predict_emotion_from_audio(wav_filepath):
@@ -58,7 +58,7 @@ def predict_emotion_from_audio(wav_filepath):
58
  if test_point is not None:
59
  test_point = np.reshape(test_point, newshape=(1, 40, 1))
60
  predictions = model.predict(test_point)
61
- predicted_emotion_label = np.argmax(predictions[0]) + 1 # Adding 1 to match your emotion dictionary
62
  return emotions.get(predicted_emotion_label, "Unknown emotion")
63
  else:
64
  return "Error: Unable to extract features"
 
19
  print("Error loading emotion prediction model:", e)
20
  return None
21
 
22
+ model_path = 'mymodel_SER_LSTM_RAVDESS.h5'
23
  model = load_emotion_model(model_path)
24
 
25
  # Initialize WhisperModel
 
46
  return None
47
 
48
  # Emotions dictionary
49
+ emotions = {0: 'neutral', 1: 'calm', 2: 'happy', 3: 'sad', 4: 'angry', 5: 'fearful', 6: 'disgust', 7: 'surprised'}
50
 
51
  # Function to predict emotion from audio
52
  def predict_emotion_from_audio(wav_filepath):
 
58
  if test_point is not None:
59
  test_point = np.reshape(test_point, newshape=(1, 40, 1))
60
  predictions = model.predict(test_point)
61
+ predicted_emotion_label = np.argmax(predictions[0]) #
62
  return emotions.get(predicted_emotion_label, "Unknown emotion")
63
  else:
64
  return "Error: Unable to extract features"