Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to use AS ESP32-S3 voice assistant in home assistant
#11
Ok, maybe someone can help me on 2 issues


1. I added volume control and still sounds really low. no mater on if I set it to 100 or not
2. I tried to add continuous conversation and that is not working

Code:
esphome:
  name: sarah
  friendly_name: SARAH
  platformio_options:
    board_build.flash_mode: dio
  on_boot:
    - light.turn_on:
        id: led_ww
        red: 100%
        green: 0.15
        blue: 0.85
        brightness: 50%

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
      CONFIG_AUDIO_BOARD_CUSTOM: "y"
  
psram:
  mode: octal  # quad for N8R2 and octal for N16R8
  speed: 80MHz

# Enable logging
logger:
  hardware_uart: USB_SERIAL_JTAG

# Enable Home Assistant API
api:
  encryption:
    key: "*********************"
  on_client_connected:
        then:
          - delay: 50ms
          - light.turn_on:
              id: led_ww
              red: 100%
              green: 0.15
              blue: 0.85
              brightness: 50%
          - micro_wake_word.start:
  on_client_disconnected:
        then:
          - voice_assistant.stop:

ota:
  - platform: esphome
    password: "****************"

wifi:
  ssid: "********"
  password: "************"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-S3-Wake-Word"
    password: "***********"

captive_portal:

button:
  - platform: restart
    name: "Restart"
    id: but_rest

# Updated Volume Control
number:
  - platform: template
    name: "Speaker Volume"
    id: speaker_volume
    optimistic: true
    min_value: 0
    max_value: 100
    step: 1
    restore_value: true
    initial_value: 80  # Higher default volume
    mode: slider
    on_value:
      then:
        - speaker.volume_set:
            id: va_speaker
            volume: !lambda "return (x / 100.0) * 8.0;"


switch:
  - platform: template
    id: mute
    name: mute
    optimistic: true
    on_turn_on:
      - speaker.volume_set:
          id: va_speaker
          volume: 0%
      - micro_wake_word.stop:
      - voice_assistant.stop:
      - light.turn_on:
          id: led_ww          
          red: 100%
          green: 0%
          blue: 0%
          brightness: 60%
          effect: fast pulse
      - delay: 2s
      - light.turn_off:
          id: led_ww
      - light.turn_on:
          id: led_ww          
          red: 100%
          green: 0%
          blue: 0%
          brightness: 30%
    on_turn_off:
      - speaker.volume_set:
          id: va_speaker
          volume: 50%
      - micro_wake_word.start:
      - light.turn_on:
          id: led_ww          
          red: 0%
          green: 100%
          blue: 0%
          brightness: 60%
          effect: fast pulse
      - delay: 2s
      - light.turn_off:
          id: led_ww

light:
  - platform: esp32_rmt_led_strip
    id: led_ww
    rgb_order: RGB
    pin: GPIO16
    num_leds: 1
    rmt_channel: 0
    chipset: ws2812
    name: "on board light"
    effects:
      - pulse:
      - pulse:
          name: "Fast Pulse"
          transition_length: 0.5s
          update_interval: 0.5s
          min_brightness: 0%
          max_brightness: 100%
         
# Audio and Voice Assistant Config         
i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO3  #WS
    i2s_bclk_pin: GPIO2 #SCK
  - id: i2s_speaker
    i2s_lrclk_pin: GPIO6  #LRC
    i2s_bclk_pin: GPIO7 #BLCK

microphone:
  - platform: i2s_audio
    id: va_mic
    adc_type: external
    i2s_din_pin: GPIO4 #SD pin on the INMP441
    channel: left
    pdm: false
    i2s_audio_id: i2s_in
    bits_per_sample: 32 bit
   
speaker:
  - platform: i2s_audio
    id: va_speaker
    i2s_audio_id: i2s_speaker
    dac_type: external
    i2s_dout_pin: GPIO8   #  DIN Pin of the MAX98357A Audio Amplifier
    channel: mono

micro_wake_word:
  on_wake_word_detected:
    - voice_assistant.start:
        wake_word: !lambda return wake_word;
    - light.turn_on:
        id: led_ww          
        red: 30%
        green: 30%
        blue: 70%
        brightness: 60%
        effect: fast pulse
  models:
    - model: hey_jarvis

voice_assistant:
  id: va
  microphone: va_mic
  noise_suppression_level: 2.0
  speaker: va_speaker
  conversation_timeout: 10s  # Time to wait for follow-up questions
  on_tts_start:
    then:
      - speaker.volume_set:
          id: va_speaker
          volume: !lambda "return (id(speaker_volume).state / 100.0) * 8.0;"
  on_stt_end:
    then:
      - light.turn_on:
          id: led_ww          
          red: 100%
          green: 0.15
          blue: 0.85
          brightness: 50%
          effect: none
  on_end:
    then:
      - speaker.volume_set:
          id: va_speaker
          volume: !lambda "return (id(speaker_volume).state / 100.0) * 8.0;"
      - light.turn_on:
          id: led_ww          
          red: 100%
          green: 0.15
          blue: 0.85
          brightness: 50%
          effect: none
      - wait_until:
          not:
            voice_assistant.is_running:
      - micro_wake_word.start:
Reply
#12
Is there a way to use the wakeword on the system and not the micro wakeword. I have created my own and would like to use it
Reply
#13
about the volume issue, you can try to download this internet radio arduino code to test:
https://www.kincony.com/forum/showthread.php?tid=6896
only need replace your router's wifi ssid and password. check whether volume can be changed with different value.
Reply
#14
I somehow messed up, is there a way to factory reset it? I have no lights, no mic, I can see it on my network.This morning my internet went out and I moved the device from a USB port to a power dongle but after that the mic stopped working and listening. I figured Ill look tonight and the install failed with
Linking .pioenvs/sarah/firmware.elf
RAM: [= ] 9.9% (used 32488 bytes from 327680 bytes)
Flash: [====== ] 62.0% (used 1138185 bytes from 1835008 bytes)
Building .pioenvs/sarah/firmware.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
esp32_create_combined_bin([".pioenvs/sarah/firmware.bin"], [".pioenvs/sarah/firmware.elf"])
Wrote 0x125f70 bytes to file /config/.esphome/build/sarah/.pioenvs/sarah/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/sarah/firmware.bin"], [".pioenvs/sarah/firmware.elf"])
========================= [SUCCESS] Took 55.25 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of sarah.local in mDNS
INFO Connecting to 192.168.1.217 port 3232...
INFO Connected to 192.168.1.217
INFO Uploading /config/.esphome/build/sarah/.pioenvs/sarah/firmware.bin (1138544 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 9.06 seconds, waiting for result...
ERROR Error Update end: Error: Finishing update failed. See the MQTT/USB logs for more information.

I would like to reset and start from scratch please
Reply
#15
(12-19-2024, 03:07 AM)biofects Wrote: I somehow messed up, is there a way to factory reset it? I have no lights, no mic, I can see it on my network.This morning my internet went out and I moved the device from a USB port to a power dongle but after that the mic stopped working and listening. I figured Ill look tonight and the install failed with
Linking .pioenvs/sarah/firmware.elf
RAM:  [=        ]  9.9% (used 32488 bytes from 327680 bytes)
Flash: [======    ]  62.0% (used 1138185 bytes from 1835008 bytes)
Building .pioenvs/sarah/firmware.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
esp32_create_combined_bin([".pioenvs/sarah/firmware.bin"], [".pioenvs/sarah/firmware.elf"])
Wrote 0x125f70 bytes to file /config/.esphome/build/sarah/.pioenvs/sarah/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/sarah/firmware.bin"], [".pioenvs/sarah/firmware.elf"])
========================= [SUCCESS] Took 55.25 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of sarah.local in mDNS
INFO Connecting to 192.168.1.217 port 3232...
INFO Connected to 192.168.1.217
INFO Uploading /config/.esphome/build/sarah/.pioenvs/sarah/firmware.bin (1138544 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 9.06 seconds, waiting for result...
ERROR Error Update end: Error: Finishing update failed. See the MQTT/USB logs for more information.

I would like to reset and start from scratch please

NM I have figured it out. I had to go back and plug back into server and start from scratch
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)