1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-07 22:02:22 +01:00

Add wake word phrase to voice assistant start command (#6290)

This commit is contained in:
Jesse Hills
2024-03-06 07:41:18 +13:00
committed by GitHub
parent 96446446b2
commit 01fc0578bd
7 changed files with 30 additions and 2 deletions

View File

@@ -124,6 +124,8 @@ class VoiceAssistant : public Component {
void client_subscription(api::APIConnection *client, bool subscribe);
api::APIConnection *get_api_connection() const { return this->api_client_; }
void set_wake_word(const std::string &wake_word) { this->wake_word_ = wake_word; }
protected:
int read_microphone_();
void set_state_(State state);
@@ -175,6 +177,8 @@ class VoiceAssistant : public Component {
std::string conversation_id_{""};
std::string wake_word_{""};
HighFrequencyLoopRequester high_freq_;
#ifdef USE_ESP_ADF
@@ -200,8 +204,13 @@ class VoiceAssistant : public Component {
};
template<typename... Ts> class StartAction : public Action<Ts...>, public Parented<VoiceAssistant> {
TEMPLATABLE_VALUE(std::string, wake_word);
public:
void play(Ts... x) override { this->parent_->request_start(false, this->silence_detection_); }
void play(Ts... x) override {
this->parent_->set_wake_word(this->wake_word_.value(x...));
this->parent_->request_start(false, this->silence_detection_);
}
void set_silence_detection(bool silence_detection) { this->silence_detection_ = silence_detection; }