Spaces:
Sleeping
Sleeping
Create classifier.py
Browse files- app/classifier.py +17 -0
app/classifier.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
EMOTIONS = ["angry", "happy", "sad", "neutral"]
|
| 4 |
+
|
| 5 |
+
def simple_rule_classifier(features):
|
| 6 |
+
pitch = features[-2]
|
| 7 |
+
energy = features[-1]
|
| 8 |
+
|
| 9 |
+
# Basic heuristics (you can improve later)
|
| 10 |
+
if energy > 0.1 and pitch > 150:
|
| 11 |
+
return "happy", 0.7
|
| 12 |
+
elif energy > 0.15 and pitch < 120:
|
| 13 |
+
return "angry", 0.7
|
| 14 |
+
elif energy < 0.05:
|
| 15 |
+
return "sad", 0.7
|
| 16 |
+
else:
|
| 17 |
+
return "neutral", 0.6
|