Use numpy for average
This commit is contained in:
parent
a586de99c6
commit
e08dc45fb9
1 changed files with 3 additions and 5 deletions
|
@ -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"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue