Spaces:
Running on Zero
Running on Zero
File size: 2,437 Bytes
f1ef7e2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | """
Configuration constants for the audio-only sentiment analysis module.
This file keeps labels, thresholds, and scoring weights in one place so the
classifier, feature extraction code, backend, and dashboard all use consistent
definitions.
"""
from enum import Enum
class EmotionLabel(str, Enum):
"""Supported emotion labels used by the sentiment module."""
ANGER = "anger"
SADNESS = "sadness"
FEAR = "fear"
DISGUST = "disgust"
HAPPY = "happy"
NEUTRAL = "neutral"
UNKNOWN = "unknown"
class OverallSentiment(str, Enum):
"""High-level audio sentiment categories."""
POSITIVE = "Positive"
NEGATIVE = "Negative"
NEUTRAL = "Neutral"
MIXED = "Mixed"
UNKNOWN = "Unknown"
class IntensityLevel(str, Enum):
"""Categorical level used for audio features."""
LOW = "Low"
MEDIUM = "Medium"
HIGH = "High"
UNKNOWN = "Unknown"
class SentimentShift(str, Enum):
"""Direction of emotional change across the call."""
IMPROVED = "Improved"
WORSENED = "Worsened"
UNCHANGED = "Unchanged"
MIXED = "Mixed"
UNKNOWN = "Unknown"
class RiskLevel(str, Enum):
"""Risk level derived from the audio escalation score."""
LOW = "Low"
MEDIUM = "Medium"
HIGH = "High"
CRITICAL = "Critical"
UNKNOWN = "Unknown"
class ConfidenceLevel(str, Enum):
"""Confidence level for model predictions."""
LOW = "Low"
MEDIUM = "Medium"
HIGH = "High"
UNKNOWN = "Unknown"
NEGATIVE_EMOTIONS = {
EmotionLabel.ANGER,
EmotionLabel.SADNESS,
EmotionLabel.FEAR,
EmotionLabel.DISGUST,
}
POSITIVE_EMOTIONS = {
EmotionLabel.HAPPY,
}
CALM_EMOTIONS = {
EmotionLabel.NEUTRAL,
}
# CREMA-D filename emotion codes.
# Example filename:
# 1001_DFA_ANG_XX.wav
CREMAD_EMOTION_MAP = {
"ANG": EmotionLabel.ANGER,
"SAD": EmotionLabel.SADNESS,
"FEA": EmotionLabel.FEAR,
"DIS": EmotionLabel.DISGUST,
"HAP": EmotionLabel.HAPPY,
"NEU": EmotionLabel.NEUTRAL,
}
# These weights will be used later when calculating audio_escalation_score.
# Defining them now makes the scoring method explainable and consistent.
ESCALATION_SCORE_WEIGHTS = {
"anger_probability": 0.25,
"stress_probability": 0.20,
"negative_emotion_probability": 0.20,
"vocal_intensity_score": 0.10,
"pitch_variability_score": 0.10,
"speech_rate_score": 0.05,
"pause_score": 0.05,
"overlap_score": 0.05,
} |