Update app.py
Browse files
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 = '
|
| 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 = {
|
| 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])
|
| 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"
|