Use numpy for average

This commit is contained in:
Dale 2023-04-30 14:11:44 +02:00
parent a586de99c6
commit e08dc45fb9

View file

@ -143,8 +143,8 @@ class Prediction(threading.Thread):
Filter so that a wakeword is only triggered once per utterance. Filter so that a wakeword is only triggered once per utterance.
When simple moving average (of length `activation_samples`) crosses the `activation_threshold` When simple moving average (of length `activation_samples`) crosses the `activation_threshold`
then trigger Rhasspy. Only "re-arm" the wakeword when the moving average drops below for the first time, then trigger Rhasspy. Only "re-arm" the wakeword when the moving average
the `deactivation_threshold`. drops below the `deactivation_threshold`.
""" """
try: try:
self.filters[wakeword]["samples"].append(confidence) self.filters[wakeword]["samples"].append(confidence)
@ -155,9 +155,7 @@ class Prediction(threading.Thread):
), ),
"active": False, "active": False,
} }
moving_average = ( moving_average = np.average(self.filters[wakeword]["samples"])
sum(self.filters[wakeword]["samples"]) / config["oww"]["activation_samples"]
)
activated = False activated = False
if ( if (
not self.filters[wakeword]["active"] not self.filters[wakeword]["active"]