{"id":265,"date":"2025-01-01T21:55:18","date_gmt":"2025-01-01T21:55:18","guid":{"rendered":"http:\/\/blog.ltzs.us\/?p=265"},"modified":"2025-01-01T21:55:18","modified_gmt":"2025-01-01T21:55:18","slug":"esphome-voice-assistant-yaml","status":"publish","type":"post","link":"http:\/\/blog.ltzs.us\/?p=265","title":{"rendered":"ESPHome Voice Assistant YAML"},"content":{"rendered":"\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-yaml\">esphome:\n  name: s3-voice-1\n  friendly_name: ESP32-S3-Wake-word\n  platformio_options:\n    board_build.flash_mode: dio\n  on_boot:\n    - light.turn_on:\n        id: led_ww\n        blue: 100%\n        brightness: 60%\n        effect: fast pulse\n\nesp32:\n  board: esp32-s3-devkitc-1\n  framework:\n    type: esp-idf\n\n    sdkconfig_options:\n      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: &quot;y&quot;\n      CONFIG_ESP32S3_DATA_CACHE_64KB: &quot;y&quot;\n      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: &quot;y&quot;\n      CONFIG_AUDIO_BOARD_CUSTOM: &quot;y&quot;\n   \npsram:\n  mode: octal # Please change this to quad for N8R2 and octal for N16R8\n  speed: 80MHz\n\n# Enable Home Assistant API\napi:\n  encryption:\n    key: &quot;specialkey&quot;\n  on_client_connected:\n        then:\n          - delay: 50ms\n          - light.turn_off: led_ww\n          - micro_wake_word.start:\n  on_client_disconnected:\n        then:\n          - voice_assistant.stop: \n\nlogger:\n\nota:\n  - platform: esphome\n    password: &quot;password&quot;\n\nwifi:\n  ssid: !secret wifi_ssid\n  password: !secret wifi_password\n\n  # Enable fallback hotspot (captive portal) in case wifi connection fails\n  ap:\n    ssid: &quot;s3-voice-1&quot;\n    password: &quot;password&quot;\n\ncaptive_portal:\n\n\n\nbutton:\n  - platform: restart\n    name: &quot;Restart&quot;\n    id: but_rest\n\nswitch:\n  - platform: template\n    id: mute\n    name: mute\n    optimistic: true\n    on_turn_on: \n      - micro_wake_word.stop:\n      - voice_assistant.stop:\n      - light.turn_on:\n          id: led_ww           \n          red: 100%\n          green: 0%\n          blue: 0%\n          brightness: 60%\n          effect: fast pulse \n          \n      - delay: 2s\n      - light.turn_off:\n          id: led_ww\n\n      - light.turn_on:\n          id: led_ww          \n          red: 100%\n          green: 0%\n          blue: 0%\n          brightness: 30%\n\n    on_turn_off:\n      - micro_wake_word.start:\n      - light.turn_on:\n          id: led_ww           \n          red: 0%\n          green: 100%\n          blue: 0%\n          brightness: 60%\n          effect: fast pulse \n      - delay: 2s\n      - light.turn_off:\n          id: led_ww\n\nbinary_sensor:\n  - platform: gpio\n    id: button01\n    name: &quot;Mute Button&quot; # Physical Mute switch\n    pin:\n      number: GPIO10  #Physical Button connected to this pin.\n      inverted: True\n      mode:\n        input: True\n        pullup: True\n    on_press: \n      then:\n        - switch.toggle: mute\n   \nlight:\n  - platform: esp32_rmt_led_strip\n    id: led_ww\n    rgb_order: GRB\n    pin: GPIO48\n    num_leds: 1\n    rmt_channel: 0\n    chipset: ws2812\n    name: &quot;On board light&quot;\n    effects:\n      - pulse:\n      - pulse:\n          name: &quot;Fast Pulse&quot;\n          transition_length: 0.5s\n          update_interval: 0.5s\n          min_brightness: 0%\n          max_brightness: 100%\n        \n # Audio and Voice Assistant Config          \ni2s_audio:\n  - id: i2s_in # For microphone\n    i2s_lrclk_pin: GPIO6  #WS \n    i2s_bclk_pin: GPIO7 #SCK\n\n  - id: i2s_speaker #For Speaker\n    i2s_lrclk_pin: GPIO3  #LRC \n    i2s_bclk_pin: GPIO18 #BLCK\n\nmicrophone:\n  - platform: i2s_audio\n    id: va_mic\n    adc_type: external\n    i2s_din_pin: GPIO4 #SD\n    channel: left\n    pdm: false\n    i2s_audio_id: i2s_in\n    bits_per_sample: 32bit\n    \nspeaker:\n    platform: i2s_audio\n    id: va_speaker\n    i2s_audio_id: i2s_speaker\n    dac_type: external\n    i2s_dout_pin: GPIO8   #  DIN Pin of the MAX98357A Audio Amplifier\n    channel: mono\n\nmicro_wake_word:\n  on_wake_word_detected:\n    \n    - voice_assistant.start:\n        wake_word: !lambda return wake_word;\n        silence_detection: true\n    - light.turn_on:\n        id: led_ww           \n        red: 30%\n        green: 30%\n        blue: 70%\n        brightness: 60%\n        effect: fast pulse \n  models:\n    - model: alexa\n    \nvoice_assistant:\n  id: va\n  microphone: va_mic\n  auto_gain: 31dBFS\n  noise_suppression_level: 0\n  volume_multiplier: 2.5\n  speaker: va_speaker\n  on_stt_end:\n       then: \n         - light.turn_off: led_ww\n  on_error:\n          - micro_wake_word.start:  \n  on_end:\n        then:\n          - light.turn_off: led_ww\n          - wait_until:\n              not:\n                voice_assistant.is_running:\n          - micro_wake_word.start: <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-265","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=265"}],"version-history":[{"count":1,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":266,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/265\/revisions\/266"}],"wp:attachment":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}