webapp1 commited on
Commit
0a09b68
·
verified ·
1 Parent(s): a6b9c3e

Upload 2 files

Browse files
Files changed (1) hide show
  1. src/models/fusion_engine.py +12 -4
src/models/fusion_engine.py CHANGED
@@ -64,10 +64,16 @@ class LateDecisionFusion:
64
 
65
  # Determine primary stress origin
66
  t_cat = text_result.get("predicted_category", "Normal")
 
67
  if combined_stress_score < 40.0:
68
  final_category = "Normal"
69
  else:
70
- final_category = t_cat if t_cat != "Normal" else "Stress"
 
 
 
 
 
71
 
72
  # Determine clinical risk tier
73
  if combined_stress_score < 40.0:
@@ -141,14 +147,16 @@ class LateDecisionFusion:
141
  else:
142
  cat = "Calm / Normal"
143
 
 
 
144
  if score < 40.0:
145
  tier, color, summary = "Minimal / Normal", "green", "Vocal tone is calm and stable."
146
  elif score < 60.0:
147
- tier, color, summary = "Mild Stress", "blue", f"Slight vocal tension ({emotion.lower()}) observed."
148
  elif score < 80.0:
149
- tier, color, summary = "Moderate Stress", "orange", f"High vocal agitation ({emotion.lower()}) and spectral energy detected."
150
  else:
151
- tier, color, summary = "Severe Stress", "red", f"Severe acoustic stress and emotional agitation ({emotion.lower()}) recorded."
152
 
153
  return {
154
  "modality_status": "Single-Modality (Speech Only)",
 
64
 
65
  # Determine primary stress origin
66
  t_cat = text_result.get("predicted_category", "Normal")
67
+ a_cat = audio_result.get("predicted_emotion", "Neutral")
68
  if combined_stress_score < 40.0:
69
  final_category = "Normal"
70
  else:
71
+ if t_cat != "Normal":
72
+ final_category = t_cat
73
+ elif a_cat not in ["Normal", "Neutral", "Stress"]:
74
+ final_category = a_cat
75
+ else:
76
+ final_category = "Stress"
77
 
78
  # Determine clinical risk tier
79
  if combined_stress_score < 40.0:
 
147
  else:
148
  cat = "Calm / Normal"
149
 
150
+ emotion_str = emotion if emotion not in ["Neutral", "Normal", "Stress"] else "Stress"
151
+
152
  if score < 40.0:
153
  tier, color, summary = "Minimal / Normal", "green", "Vocal tone is calm and stable."
154
  elif score < 60.0:
155
+ tier, color, summary = f"Mild {emotion_str}", "blue", f"Slight vocal tension ({emotion.lower()}) observed."
156
  elif score < 80.0:
157
+ tier, color, summary = f"Moderate {emotion_str}", "orange", f"High vocal agitation ({emotion.lower()}) and spectral energy detected."
158
  else:
159
+ tier, color, summary = f"Severe {emotion_str}", "red", f"Severe acoustic stress and emotional agitation ({emotion.lower()}) recorded."
160
 
161
  return {
162
  "modality_status": "Single-Modality (Speech Only)",