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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user