From c23ea384fb53562e8431eb34c155bf74cf40cae4 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Thu, 22 May 2025 14:19:16 -0500 Subject: [PATCH] [micro_wake_word] avoid duplicated detections from same event (#8877) --- esphome/components/micro_wake_word/streaming_model.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/micro_wake_word/streaming_model.cpp b/esphome/components/micro_wake_word/streaming_model.cpp index ce3d8c2e4c..38b88557e6 100644 --- a/esphome/components/micro_wake_word/streaming_model.cpp +++ b/esphome/components/micro_wake_word/streaming_model.cpp @@ -147,7 +147,11 @@ bool StreamingModel::perform_streaming_inference(const int8_t features[PREPROCES this->recent_streaming_probabilities_[this->last_n_index_] = output->data.uint8[0]; // probability; this->unprocessed_probability_status_ = true; } - this->ignore_windows_ = std::min(this->ignore_windows_ + 1, 0); + if (this->recent_streaming_probabilities_[this->last_n_index_] < this->probability_cutoff_) { + // Only increment ignore windows if less than the probability cutoff; this forces the model to "cool-off" from a + // previous detection and calling ``reset_probabilities`` so it avoids duplicate detections + this->ignore_windows_ = std::min(this->ignore_windows_ + 1, 0); + } } return true; }