voice-emotion-api / app /classifier.py
PsalmsJava's picture
Create classifier.py
f7c744d verified
raw
history blame contribute delete
428 Bytes
import numpy as np
EMOTIONS = ["angry", "happy", "sad", "neutral"]
def simple_rule_classifier(features):
pitch = features[-2]
energy = features[-1]
# Basic heuristics (you can improve later)
if energy > 0.1 and pitch > 150:
return "happy", 0.7
elif energy > 0.15 and pitch < 120:
return "angry", 0.7
elif energy < 0.05:
return "sad", 0.7
else:
return "neutral", 0.6