119 lines
2.6 KiB
YAML
119 lines
2.6 KiB
YAML
substitutions:
|
|
device_name: "voiceassist1"
|
|
friendly_name: "ESP32 voice Assist 1"
|
|
comment: "esp32, mic, dac, Btn"
|
|
api_password: !secret voiceassist1_api
|
|
ota_password: !secret ota_password
|
|
wifi_ssid: !secret wifi_ssid
|
|
wifi_password: !secret wifi_password
|
|
gateway: !secret ip_gateway
|
|
subnet: !secret ip_subnet
|
|
ip: !secret voiceassist1_ip
|
|
pin_lrclk: GPIO19
|
|
pin_bclk: GPIO18
|
|
pin_i2sdin: GPIO23
|
|
pin_i2sdout: GPIO5
|
|
pin_button: GPIO14
|
|
pin_LEDS: GPIO27
|
|
|
|
packages:
|
|
connection: !include common/wifi.yaml
|
|
logger: !include templates/logger.yaml
|
|
|
|
|
|
esphome:
|
|
name: ${device_name}
|
|
friendly_name: ${friendly_name}
|
|
project:
|
|
name: esp32.voice-assistant
|
|
version: "1.0"
|
|
min_version: 2023.10.0
|
|
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
|
|
|
|
improv_serial:
|
|
|
|
i2s_audio:
|
|
i2s_lrclk_pin: ${pin_lrclk}
|
|
i2s_bclk_pin: ${pin_bclk}
|
|
|
|
microphone:
|
|
- platform: i2s_audio
|
|
id: mic
|
|
i2s_din_pin: ${pin_i2sdin}
|
|
adc_type: external
|
|
pdm: false
|
|
|
|
speaker:
|
|
- platform: i2s_audio
|
|
id: big_speaker
|
|
i2s_dout_pin: ${pin_i2sdout}
|
|
dac_type: external
|
|
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
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: ${pin_button}
|
|
inverted: true
|
|
name: Button
|
|
disabled_by_default: true
|
|
entity_category: diagnostic
|
|
id: echo_button
|
|
on_click:
|
|
- if:
|
|
condition:
|
|
switch.is_off: use_wake_word
|
|
then:
|
|
- if:
|
|
condition: voice_assistant.is_running
|
|
then:
|
|
- voice_assistant.stop:
|
|
else:
|
|
- voice_assistant.start:
|
|
else:
|
|
- voice_assistant.stop
|
|
- delay: 1s
|
|
|
|
- voice_assistant.start_continuous:
|
|
|
|
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); |