Skip to content

Commit

Permalink
fix vad detection (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrendt authored Jul 30, 2024
1 parent b2a320b commit 2fe0f67
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions esphome/components/micro_wake_word/streaming_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ VADModel::VADModel(const uint8_t *model_start, float probability_cutoff, size_t
};

bool VADModel::determine_detected() {
uint8_t max = 0;
int32_t sum = 0;
for (auto &prob : this->recent_streaming_probabilities_) {
max = std::max(prob, max);
sum += prob;
}

return max > this->probability_cutoff_;
float sliding_window_average = static_cast<float>(sum) / static_cast<float>(255 * this->sliding_window_size_);

return sliding_window_average > this->probability_cutoff_;
}

} // namespace micro_wake_word
Expand Down

0 comments on commit 2fe0f67

Please sign in to comment.