Esp32 wake word not working and noise from speaker

Hello everybody,
I need an help to solve this issue.

I am trying to enable voice assistant on an esp32, but everytime I enable the wake word switch I constantly get a static noise (like something is frying) from the speaker.
How can I solve?

This is really annoying because it seems an easy process to complete… where is the mistake? :cry:

I have already tried changing the mike as well as the wiring and the esp32 and separate the BCLK/LRCLK for input and output but I always get the same problem.

These are the device I am using:

this is the code I am using:

esphome:
  name: zero-test
  friendly_name: zero-test
  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: wemos_d1_mini32 # esp32dev # nodemcu-32s # az-delivery-devkit-v4 #wemos_d1_mini32 <= I tried all these but none works fine
  framework:
    type: esp-idf
    version: recommended

logger:

api:
  encryption:
    key: "myBase64api"

ota:
  password: "ota_password"

wifi:
  ssid: !secret wifi_iot_ssid
  password: !secret wifi_iot_password   
  ap:
    ssid: "zero-test-wifi"
    password: "IC2-CC-C=3xkJX"   

  manual_ip:
    static_ip: 192.168.207.42
    gateway: 192.168.207.254
    subnet: 255.255.255.0
    dns1: 192.168.207.254
  domain: .mydomain.cloud

# captive_portal:

# i2s_audio:
#   i2s_lrclk_pin: GPIO19
#   i2s_bclk_pin: GPIO23

i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO19 # ws 
    i2s_bclk_pin: GPIO23  # sck
  - id: i2s_out
    i2s_lrclk_pin: GPIO22 # 
    i2s_bclk_pin: GPIO21  # 

microphone:
  - platform: i2s_audio
    id: mic
    adc_type: external
    i2s_din_pin: GPIO5 # 
    pdm: false
    channel: right
    bits_per_sample: 32bit
    i2s_audio_id: i2s_in
    
speaker:
  - platform: i2s_audio
    id: big_speaker
    dac_type: external
    i2s_dout_pin: GPIO26 # 
    mode: mono
    i2s_audio_id: i2s_out

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_error: 
   - if:
        condition:
          switch.is_on: use_wake_word
        then:
          - switch.turn_off: use_wake_word
          - switch.turn_on: use_wake_word      

  on_client_connected:
    - if:
        condition:
          switch.is_on: use_wake_word
        then:
          - voice_assistant.start_continuous:

  on_client_disconnected:
    - if:
        condition:
          switch.is_on: use_wake_word
        then:
          - voice_assistant.stop:  

binary_sensor:
  - platform: status
    name: API Connection
    id: api_connection
    filters:
      - delayed_on: 1s
    on_press:
      - if:
          condition:
            switch.is_on: use_wake_word
          then:
            - voice_assistant.start_continuous:
    on_release:
      - if:
          condition:
            switch.is_on: use_wake_word
          then:
            - voice_assistant.stop:
switch:
  - platform: template
    name: attiva 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);
1 Like

Hi,
I have the same issue with ESP32 S3 board.
I also enabled a button on the board to send a sample directly to the speaker, but not really working.
Have you found any solution?
I also tried to change the config using media_player instead of speaker, the control appears in HA, but nothing happens when I click on the play icon.

Welcome to HA, its your first post!

Seems some people have fixed it by using different gpio pins for their sound in- and output.
You seem to already have this set up, and still be experiencing the noise.
I am in the same boat, and following this github gist thread closely too. Until now I haven’t found a solution either. Hope someone can shed some light on it.

I had exactly the same symptoms when I messed up the pinout. The advice to change the pins used in your configuration also makes sense.
Maybe this discussion will help you, I have already built two speakers using this circuit.

Some update to my post.
I could stop the noise by enabling the DOUT pin as output (applying the solution from this topic: ESP32 Voice Assistant - Static Noise on Startup)

i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO6    # INMP441 WS
    i2s_bclk_pin: GPIO5     # INMP441 SCK
  - id: i2s_out
    i2s_lrclk_pin: GPIO10   # MAX98357A LRC
    i2s_bclk_pin: GPIO11    # MAX98357A BCLK

microphone:
  - platform: i2s_audio
    id: external_microphone
    adc_type: external
    bits_per_sample: 32bit
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO4      # INMP441 SD
    pdm: false
    channel: left           # L/R pin pulled high

#speaker:
#  - platform: i2s_audio
#    id: external_speaker
#    dac_type: external
#    i2s_audio_id: i2s_out
#    i2s_dout_pin:           # MAX98357A DIN
#      number: GPIO12
#      allow_other_uses: true
#    mode: mono 

media_player:
  - platform: i2s_audio
    name: "esp_mplayer"
    id: esp_media_player
    i2s_audio_id: i2s_out
    dac_type: external
    i2s_dout_pin:           # MAX98357A DIN
      number: GPIO12
      allow_other_uses: true
    mode: mono

output:
  - platform: gpio
    pin: 
      number: GPIO12
      allow_other_uses: true
    id: set_low_speaker

Configuring the speaker as media_player seems working, if the voice assistant function is disabled. In this case HA can play sound though ESP32. When I enable the voice assistant feature, nothing else can be played.
Regarding the microphone, I’m still trying to figure out, how to get it working…

1 Like