1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

[micro_wake_word] Avoid heap allocation for trigger

This commit is contained in:
J. Nick Koston
2026-02-02 05:12:18 +01:00
parent 18c152723c
commit 89cc20c423
2 changed files with 3 additions and 3 deletions

View File

@@ -325,7 +325,7 @@ void MicroWakeWord::loop() {
ESP_LOGD(TAG, "Detected '%s' with sliding average probability is %.2f and max probability is %.2f",
detection_event.wake_word->c_str(), (detection_event.average_probability / uint8_to_float_divisor),
(detection_event.max_probability / uint8_to_float_divisor));
this->wake_word_detected_trigger_->trigger(*detection_event.wake_word);
this->wake_word_detected_trigger_.trigger(*detection_event.wake_word);
if (this->stop_after_detection_) {
this->stop();
}

View File

@@ -60,7 +60,7 @@ class MicroWakeWord : public Component
void set_stop_after_detection(bool stop_after_detection) { this->stop_after_detection_ = stop_after_detection; }
Trigger<std::string> *get_wake_word_detected_trigger() const { return this->wake_word_detected_trigger_; }
Trigger<std::string> *get_wake_word_detected_trigger() { return &this->wake_word_detected_trigger_; }
void add_wake_word_model(WakeWordModel *model);
@@ -78,7 +78,7 @@ class MicroWakeWord : public Component
protected:
microphone::MicrophoneSource *microphone_source_{nullptr};
Trigger<std::string> *wake_word_detected_trigger_ = new Trigger<std::string>();
Trigger<std::string> wake_word_detected_trigger_;
State state_{State::STOPPED};
std::weak_ptr<RingBuffer> ring_buffer_;