This commit is contained in:
radu
2026-12-02 15:13:55 +07:00
parent a751659462
commit 76caa0fb40
+34 -9
View File
@@ -58,10 +58,11 @@ voice_assistant:
on_stt_vad_start: on_stt_vad_start:
# Turn off the script if speech is detected # Turn off the script if speech is detected
- lambda: id(stt_vad_started) = true; - lambda: id(stt_vad_started) = true;
on_stt_vad_end: on_stt_vad_end:
- lambda: id(voice_assistant_phase) = 3; # recording finished, HA is processing
#- logger.log: "===============================VAD is the END ==================================" #- logger.log: "===============================VAD is the END =================================="
- script.stop: listening_timeout - script.stop: listening_timeout
- light.turn_on: - light.turn_on:
@@ -72,6 +73,8 @@ voice_assistant:
effect: none effect: none
on_stt_end: on_stt_end:
- lambda: id(voice_assistant_phase) = 3;
- script.stop: listening_timeout
- logger.log: - logger.log:
format: "STT text: %s" format: "STT text: %s"
args: ["x.c_str()"] args: ["x.c_str()"]
@@ -96,6 +99,17 @@ voice_assistant:
announce: "false" announce: "false"
on_end: on_end:
# No local speaker/media_player, so ESPHome never reports playback as finished
# and HA keeps the satellite in "responding". Report it ourselves.
- lambda: |-
auto *conn = id(va).get_api_connection();
if (conn != nullptr) {
api::VoiceAssistantAnnounceFinished msg;
msg.success = true;
if (!conn->send_message(msg)) {
ESP_LOGW("va", "Could not send announce-finished to HA");
}
}
- lambda: id(voice_assistant_phase) = 1; - lambda: id(voice_assistant_phase) = 1;
- lambda: id(stt_vad_started) = false; - lambda: id(stt_vad_started) = false;
- script.execute: start_wake_word - script.execute: start_wake_word
@@ -164,14 +178,25 @@ script:
- if: - if:
condition: condition:
lambda: |- lambda: |-
return id(voice_assistant_phase) == 2 && !id(stt_vad_started); return id(voice_assistant_phase) == 2;
then: then:
- logger.log: "+++++++++++++++++++++++++ reset ==========================================" - if:
- light.turn_off: condition:
id: led lambda: 'return id(stt_vad_started);'
- voice_assistant.stop: then:
- delay: 1s # Speech is still going after the max time: stop the mic.
- script.execute: start_wake_word # HA processes the audio received so far; on_end restarts the wake word.
- logger.log: "Max listen time reached, stopping audio stream"
- lambda: id(voice_assistant_phase) = 3;
- voice_assistant.stop:
else:
# No speech at all: abort and return to wake word listening
- logger.log: "No speech detected, back to wake word"
- light.turn_off:
id: led
- voice_assistant.stop:
- delay: 1s
- script.execute: start_wake_word
- id: start_wake_word - id: start_wake_word
then: then: