mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Voice assist improvement - configurable conversation_id timeout (#7385)
Some checks are pending
CI / CI Status (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Some checks are pending
CI / CI Status (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
This commit is contained in:
parent
a7fd3b34aa
commit
e882cea47e
4 changed files with 17 additions and 1 deletions
|
@ -43,6 +43,8 @@ CONF_VOLUME_MULTIPLIER = "volume_multiplier"
|
|||
|
||||
CONF_WAKE_WORD = "wake_word"
|
||||
|
||||
CONF_CONVERSATION_TIMEOUT = "conversation_timeout"
|
||||
|
||||
CONF_ON_TIMER_STARTED = "on_timer_started"
|
||||
CONF_ON_TIMER_UPDATED = "on_timer_updated"
|
||||
CONF_ON_TIMER_CANCELLED = "on_timer_cancelled"
|
||||
|
@ -100,6 +102,9 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.float_with_unit("decibel full scale", "(dBFS|dbfs|DBFS)"),
|
||||
cv.int_range(0, 31),
|
||||
),
|
||||
cv.Optional(
|
||||
CONF_CONVERSATION_TIMEOUT, default="300s"
|
||||
): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_VOLUME_MULTIPLIER, default=1.0): cv.float_range(
|
||||
min=0.0, min_included=False
|
||||
),
|
||||
|
@ -182,6 +187,7 @@ async def to_code(config):
|
|||
cg.add(var.set_noise_suppression_level(config[CONF_NOISE_SUPPRESSION_LEVEL]))
|
||||
cg.add(var.set_auto_gain(config[CONF_AUTO_GAIN]))
|
||||
cg.add(var.set_volume_multiplier(config[CONF_VOLUME_MULTIPLIER]))
|
||||
cg.add(var.set_conversation_timeout(config[CONF_CONVERSATION_TIMEOUT]))
|
||||
|
||||
if CONF_ON_LISTENING in config:
|
||||
await automation.build_automation(
|
||||
|
|
|
@ -171,6 +171,11 @@ void VoiceAssistant::deallocate_buffers_() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void VoiceAssistant::reset_conversation_id() {
|
||||
this->conversation_id_ = "";
|
||||
ESP_LOGD(TAG, "reset conversation ID");
|
||||
}
|
||||
|
||||
int VoiceAssistant::read_microphone_() {
|
||||
size_t bytes_read = 0;
|
||||
if (this->mic_->is_running()) { // Read audio into input buffer
|
||||
|
@ -299,7 +304,8 @@ void VoiceAssistant::loop() {
|
|||
break;
|
||||
}
|
||||
this->set_state_(State::STARTING_PIPELINE);
|
||||
this->set_timeout("reset-conversation_id", 5 * 60 * 1000, [this]() { this->conversation_id_ = ""; });
|
||||
this->set_timeout("reset-conversation_id", this->conversation_timeout_,
|
||||
[this]() { this->reset_conversation_id(); });
|
||||
break;
|
||||
}
|
||||
case State::STARTING_PIPELINE: {
|
||||
|
|
|
@ -147,6 +147,8 @@ class VoiceAssistant : public Component {
|
|||
}
|
||||
void set_auto_gain(uint8_t auto_gain) { this->auto_gain_ = auto_gain; }
|
||||
void set_volume_multiplier(float volume_multiplier) { this->volume_multiplier_ = volume_multiplier; }
|
||||
void set_conversation_timeout(uint32_t conversation_timeout) { this->conversation_timeout_ = conversation_timeout; }
|
||||
void reset_conversation_id();
|
||||
|
||||
Trigger<> *get_intent_end_trigger() const { return this->intent_end_trigger_; }
|
||||
Trigger<> *get_intent_start_trigger() const { return this->intent_start_trigger_; }
|
||||
|
@ -262,6 +264,7 @@ class VoiceAssistant : public Component {
|
|||
uint8_t noise_suppression_level_;
|
||||
uint8_t auto_gain_;
|
||||
float volume_multiplier_;
|
||||
uint32_t conversation_timeout_;
|
||||
|
||||
uint8_t *send_buffer_;
|
||||
int16_t *input_buffer_;
|
||||
|
|
|
@ -33,6 +33,7 @@ speaker:
|
|||
voice_assistant:
|
||||
microphone: mic_id_external
|
||||
speaker: speaker_id
|
||||
conversation_timeout: 60s
|
||||
on_listening:
|
||||
- logger.log: "Voice assistant microphone listening"
|
||||
on_start:
|
||||
|
|
Loading…
Reference in a new issue