Claude esdited
This commit is contained in:
+39
-13
@@ -39,9 +39,7 @@ voice_assistant:
|
||||
gain_factor: 2
|
||||
noise_suppression_level: 2
|
||||
auto_gain: 20dBFS
|
||||
# wakeword_config:
|
||||
# threshold: 0.8
|
||||
# pause_seconds: 2.0
|
||||
|
||||
on_start:
|
||||
|
||||
- light.turn_on:
|
||||
@@ -51,7 +49,7 @@ voice_assistant:
|
||||
blue: 0%
|
||||
brightness: 15%
|
||||
effect: none
|
||||
- script.execute: listening_timeout
|
||||
|
||||
|
||||
on_listening:
|
||||
- light.turn_on:
|
||||
@@ -62,12 +60,16 @@ voice_assistant:
|
||||
effect: none
|
||||
- lambda: id(voice_assistant_phase) = 2;
|
||||
- lambda: id(stt_vad_started) = false;
|
||||
# Wake word detected, command recording starts -> start the max-length timer
|
||||
- script.execute: listening_timeout
|
||||
|
||||
on_stt_vad_start:
|
||||
# Turn off the script if speech is detected
|
||||
- lambda: id(stt_vad_started) = true;
|
||||
|
||||
on_stt_vad_end:
|
||||
- lambda: id(voice_assistant_phase) = 3; # recording finished, HA is processing
|
||||
- script.stop: listening_timeout
|
||||
#- logger.log: "===============================VAD is the END =================================="
|
||||
- light.turn_on:
|
||||
id: led
|
||||
@@ -77,6 +79,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()"]
|
||||
@@ -108,10 +112,21 @@ 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
|
||||
#- voice_assistant.start:
|
||||
|
||||
|
||||
on_error:
|
||||
- if:
|
||||
@@ -166,7 +181,7 @@ script:
|
||||
then:
|
||||
- switch.turn_on:
|
||||
id: rbt
|
||||
- id: listening_timeout
|
||||
- id: listening_timeout
|
||||
mode: restart
|
||||
then:
|
||||
- delay: ${listenTimeout}
|
||||
@@ -176,14 +191,25 @@ script:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
return id(voice_assistant_phase) == 2 && !id(stt_vad_started);
|
||||
return id(voice_assistant_phase) == 2;
|
||||
then:
|
||||
- logger.log: "+++++++++++++++++++++++++ reset =========================================="
|
||||
- light.turn_off:
|
||||
id: led
|
||||
- voice_assistant.stop:
|
||||
- delay: 1s
|
||||
- script.execute: start_wake_word
|
||||
- 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:
|
||||
- delay: 1s
|
||||
- script.execute: start_wake_word
|
||||
|
||||
- id: start_wake_word
|
||||
then:
|
||||
|
||||
Reference in New Issue
Block a user