3 mb ch
This commit is contained in:
@@ -62,6 +62,7 @@ voice_assistant:
|
||||
|
||||
|
||||
on_stt_vad_end:
|
||||
- lambda: id(voice_assistant_phase) = 3; # recording finished, HA is processing
|
||||
#- logger.log: "===============================VAD is the END =================================="
|
||||
- script.stop: listening_timeout
|
||||
- light.turn_on:
|
||||
@@ -72,6 +73,8 @@ voice_assistant:
|
||||
effect: none
|
||||
|
||||
on_stt_end:
|
||||
- lambda: id(voice_assistant_phase) = 3;
|
||||
- script.stop: listening_timeout
|
||||
- logger.log:
|
||||
format: "STT text: %s"
|
||||
args: ["x.c_str()"]
|
||||
@@ -96,6 +99,17 @@ voice_assistant:
|
||||
announce: "false"
|
||||
|
||||
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(stt_vad_started) = false;
|
||||
- script.execute: start_wake_word
|
||||
@@ -164,9 +178,20 @@ script:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
return id(voice_assistant_phase) == 2 && !id(stt_vad_started);
|
||||
return id(voice_assistant_phase) == 2;
|
||||
then:
|
||||
- logger.log: "+++++++++++++++++++++++++ reset =========================================="
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(stt_vad_started);'
|
||||
then:
|
||||
# Speech is still going after the max time: stop the mic.
|
||||
# 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:
|
||||
|
||||
Reference in New Issue
Block a user