Skip to content

Commit

Permalink
handle internal state only in mWW
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrendt committed Oct 16, 2024
1 parent 24a2841 commit 108c539
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions esphome/components/micro_wake_word/micro_wake_word.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ void MicroWakeWord::preprocessor_task_(void *params) {
}
}

std::vector<WakeWordModel *> MicroWakeWord::get_wake_words() {
std::vector<WakeWordModel *> external_wake_word_models;
for (auto model : this->wake_word_models_) {
if (!model->get_internal_only()) {
external_wake_word_models.push_back(model);
}
}
return external_wake_word_models;
}

void MicroWakeWord::inference_task_(void *params) {
MicroWakeWord *this_mww = (MicroWakeWord *) params;

Expand Down
2 changes: 1 addition & 1 deletion esphome/components/micro_wake_word/micro_wake_word.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MicroWakeWord : public Component {

// Intended for the voice assistant component to know which wake words are available
// Since these are pointers to the WakeWordModel objects, the voice assistant component can enable or disable them
const std::vector<WakeWordModel *> &get_wake_words() const { return this->wake_word_models_; }
std::vector<WakeWordModel *> get_wake_words();

protected:
microphone::Microphone *microphone_{nullptr};
Expand Down
17 changes: 8 additions & 9 deletions esphome/components/voice_assistant/voice_assistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,17 @@ const Configuration &VoiceAssistant::get_configuration() {
this->config_.max_active_wake_words = 1;

for (auto &model : this->micro_wake_word_->get_wake_words()) {
if (!model->get_internal_only()) {
WakeWord wake_word;
wake_word.id = model->get_id();
wake_word.wake_word = model->get_wake_word();
for (const auto &lang : model->get_trained_languages()) {
wake_word.trained_languages.push_back(lang);
}
this->config_.available_wake_words.push_back(std::move(wake_word));
}
if (model->is_enabled()) {
this->config_.active_wake_words.push_back(model->get_id());
}

WakeWord wake_word;
wake_word.id = model->get_id();
wake_word.wake_word = model->get_wake_word();
for (const auto &lang : model->get_trained_languages()) {
wake_word.trained_languages.push_back(lang);
}
this->config_.available_wake_words.push_back(std::move(wake_word));
}
} else {
// No microWakeWord
Expand Down

0 comments on commit 108c539

Please sign in to comment.