mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
[micro_wake_word] Fix VAD detection and modify detection computation (#7164)
This commit is contained in:
parent
d7231fadb1
commit
dff6884bed
1 changed files with 6 additions and 4 deletions
|
@ -148,7 +148,7 @@ WakeWordModel::WakeWordModel(const uint8_t *model_start, float probability_cutof
|
|||
};
|
||||
|
||||
bool WakeWordModel::determine_detected() {
|
||||
int32_t sum = 0;
|
||||
uint32_t sum = 0;
|
||||
for (auto &prob : this->recent_streaming_probabilities_) {
|
||||
sum += prob;
|
||||
}
|
||||
|
@ -175,12 +175,14 @@ VADModel::VADModel(const uint8_t *model_start, float probability_cutoff, size_t
|
|||
};
|
||||
|
||||
bool VADModel::determine_detected() {
|
||||
uint8_t max = 0;
|
||||
uint32_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
|
||||
|
|
Loading…
Reference in a new issue