I have a ESP32 with a INMP441 microphone that I have flashed with ESPHome, using the following config:
esphome:
name: esp32-voice-assist-2
friendly_name: "ESP32 Voice Assist 2"
on_boot:
- priority: -100
then:
- wait_until: api.connected
- delay: 1s
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
esp32:
board: esp32dev
framework:
type: esp-idf
version: recommended
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: mywifi
password: password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Voice-Assist-2"
password: "password"
i2s_audio:
i2s_lrclk_pin: GPIO25
i2s_bclk_pin: GPIO14
microphone:
- platform: i2s_audio
id: mic
adc_type: external
i2s_din_pin: GPIO26
pdm: false
speaker:
- platform: i2s_audio
id: big_speaker
dac_type: external
i2s_dout_pin: GPIO27
mode: mono
voice_assistant:
microphone: mic
use_wake_word: false
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
speaker: big_speaker
id: assist
on_start:
- switch.turn_on:
id: notif_light
on_end:
- switch.turn_off:
id: notif_light
switch:
- platform: template
name: Use wake word
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- lambda: id(assist).set_use_wake_word(true);
- if:
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
on_turn_off:
- voice_assistant.stop
- lambda: id(assist).set_use_wake_word(false);
- platform: gpio
id: notif_light
pin:
number: GPIO2
mode: OUTPUT
name: "Notification Light"
restore_mode: ALWAYS_OFF
Based on the yaml created by Everything Smart Home (https://www.youtube.com/watch?v=zhlIaBG3Ldo)
This works. However, every five seconds the pipeline shuts down and restarts, which interrupts listening for wake words significantly. Log from the ESP device:
[18:07:04][D][voice_assistant:418]: Desired state set to IDLE
[18:07:04][D][voice_assistant:412]: State changed from IDLE to START_PIPELINE
[18:07:04][D][voice_assistant:418]: Desired state set to START_MICROPHONE
[18:07:04][D][voice_assistant:118]: microphone not running
[18:07:05][D][voice_assistant:200]: Requesting start...
[18:07:05][D][voice_assistant:412]: State changed from START_PIPELINE to STARTING_PIPELINE
[18:07:05][D][voice_assistant:118]: microphone not running
[18:07:05][D][voice_assistant:433]: Client started, streaming microphone
[18:07:05][D][voice_assistant:412]: State changed from STARTING_PIPELINE to START_MICROPHONE
[18:07:05][D][voice_assistant:418]: Desired state set to STREAMING_MICROPHONE
[18:07:05][D][voice_assistant:153]: Starting Microphone
[18:07:05][D][voice_assistant:412]: State changed from START_MICROPHONE to STARTING_MICROPHONE
[18:07:05][D][esp-idf:000]: I (711516) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4
[18:07:05][D][voice_assistant:519]: Event Type: 1
[18:07:05][D][voice_assistant:522]: Assist Pipeline running
[18:07:05][D][voice_assistant:412]: State changed from STARTING_MICROPHONE to STREAMING_MICROPHONE
[18:07:05][D][switch:012]: 'Notification Light' Turning ON.
[18:07:05][D][switch:055]: 'Notification Light': Sending state ON
[18:07:05][D][voice_assistant:519]: Event Type: 9
[18:07:10][D][voice_assistant:519]: Event Type: 0
[18:07:10][D][voice_assistant:519]: Event Type: 2
[18:07:10][D][voice_assistant:609]: Assist Pipeline ended
[18:07:10][D][voice_assistant:412]: State changed from STREAMING_MICROPHONE to IDLE
[18:07:10][D][voice_assistant:418]: Desired state set to IDLE
[18:07:10][D][voice_assistant:412]: State changed from IDLE to START_PIPELINE
[18:07:10][D][voice_assistant:418]: Desired state set to START_MICROPHONE
[18:07:10][D][switch:016]: 'Notification Light' Turning OFF.
[18:07:10][D][switch:055]: 'Notification Light': Sending state OFF
[18:07:10][D][voice_assistant:200]: Requesting start...
[18:07:10][D][voice_assistant:412]: State changed from START_PIPELINE to STARTING_PIPELINE
[18:07:10][D][voice_assistant:433]: Client started, streaming microphone
[18:07:10][D][voice_assistant:412]: State changed from STARTING_PIPELINE to STREAMING_MICROPHONE
[18:07:10][D][voice_assistant:418]: Desired state set to STREAMING_MICROPHONE
[18:07:10][D][voice_assistant:519]: Event Type: 1
[18:07:10][D][voice_assistant:522]: Assist Pipeline running
[18:07:10][D][switch:012]: 'Notification Light' Turning ON.
[18:07:10][D][switch:055]: 'Notification Light': Sending state ON
[18:07:10][D][voice_assistant:519]: Event Type: 9
[18:07:15][D][voice_assistant:519]: Event Type: 0
[18:07:15][D][voice_assistant:519]: Event Type: 2
[18:07:15][D][voice_assistant:609]: Assist Pipeline ended
[18:07:15][D][voice_assistant:412]: State changed from STREAMING_MICROPHONE to IDLE
[18:07:15][D][voice_assistant:418]: Desired state set to IDLE
[18:07:15][D][voice_assistant:412]: State changed from IDLE to START_PIPELINE
[18:07:15][D][voice_assistant:418]: Desired state set to START_MICROPHONE
[18:07:15][D][switch:016]: 'Notification Light' Turning OFF.
[18:07:15][D][switch:055]: 'Notification Light': Sending state OFF
[18:07:15][D][voice_assistant:200]: Requesting start...
[18:07:15][D][voice_assistant:412]: State changed from START_PIPELINE to STARTING_PIPELINE
[18:07:15][D][voice_assistant:433]: Client started, streaming microphone
[18:07:15][D][voice_assistant:412]: State changed from STARTING_PIPELINE to STREAMING_MICROPHONE
[18:07:15][D][voice_assistant:418]: Desired state set to STREAMING_MICROPHONE
[18:07:15][D][voice_assistant:519]: Event Type: 1
[18:07:15][D][voice_assistant:522]: Assist Pipeline running
[18:07:15][D][switch:012]: 'Notification Light' Turning ON.
[18:07:15][D][switch:055]: 'Notification Light': Sending state ON
[18:07:15][D][voice_assistant:519]: Event Type: 9
I would expect the pipeline to just stay open, like the Pi Zero 2 W does. Is the above expected behavior? Can I change something in the yaml to prevent it?