Compile Error adding ReSpeakerv3

I’m trying to add a ReSpeakerv3 to Home Assistant, yaml file below, but when I click install it gives this compile error:

INFO ESPHome 2024.12.2
INFO Reading configuration /config/esphome/respeaker-s3.yaml...
INFO Generating C++ source...
INFO Updating https://github.com/espressif/[email protected]
INFO Compiling app...
Processing esp32s3 (board: esp32-s3-devkitc-1; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32.git#51.03.07)
--------------------------------------------------------------------------------
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
 - framework-espidf @ 3.50105.0 (5.1.5) 
 - tool-cmake @ 3.21.3 
 - tool-esptoolpy @ 4.8.1 
 - tool-mklittlefs @ 3.2.0 
 - tool-ninja @ 1.10.2 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 12.2.0+20230208 
 - toolchain-xtensa-esp32s3 @ 12.2.0+20230208
Reading CMake configuration...
No dependencies
Compiling .pioenvs/esp32s3/src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.cpp.o
Compiling .pioenvs/esp32s3/src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.cpp.o
In file included from src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.h:5,
                 from src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.cpp:1:
/data/cache/platformio/packages/framework-espidf/components/driver/deprecated/driver/i2s.h:27:2: warning: #warning "This set of I2S APIs has been deprecated, please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. if you want to keep using the old APIs and ignore this warning, you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" [-Wcpp]
   27 | #warning "This set of I2S APIs has been deprecated, \
      |  ^~~~~~~
Compiling .pioenvs/esp32s3/src/esphome/components/light/addressable_light.cpp.o
Compiling .pioenvs/esp32s3/src/esphome/components/light/automation.cpp.o
In file included from src/esphome/components/i2s_audio_xiao/speaker/../i2s_audio_xiao.h:5,
                 from src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.h:5,
                 from src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.cpp:1:
/data/cache/platformio/packages/framework-espidf/components/driver/deprecated/driver/i2s.h:27:2: warning: #warning "This set of I2S APIs has been deprecated, please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. if you want to keep using the old APIs and ignore this warning, you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" [-Wcpp]
   27 | #warning "This set of I2S APIs has been deprecated, \
      |  ^~~~~~~
src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.cpp: In member function 'virtual void esphome::i2s_audio_xiao::I2SAudioComponent::setup()':
src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.cpp:15:24: error: 'I2S_NUM_MAX' was not declared in this scope; did you mean 'I2S_NUM_1'?
   15 |   if (next_port_num >= I2S_NUM_MAX) {
      |                        ^~~~~~~~~~~
      |                        I2S_NUM_1
*** [.pioenvs/esp32s3/src/esphome/components/i2s_audio_xiao/i2s_audio_xiao.cpp.o] Error 1
src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.cpp: In static member function 'static void esphome::i2s_audio_xiao::I2SAudioSpeaker::player_task(void*)':
src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.cpp:54:24: error: 'I2S_MCLK_MULTIPLE_DEFAULT' was not declared in this scope; did you mean 'I2S_MCLK_MULTIPLE_512'?
   54 |       .mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                        I2S_MCLK_MULTIPLE_512
*** [.pioenvs/esp32s3/src/esphome/components/i2s_audio_xiao/speaker/i2s_audio_speaker.cpp.o] Error 1
========================== [FAILED] Took 6.17 seconds ==========================

This my yaml file, mostly a copy paste from the install page (https://wiki.seeedstudio.com/respeaker_lite_ha/)


esphome:
  name: esp32s3
  friendly_name: ReSpeakerv3
  platformio_options:
    board_build.flash_mode: dio
    board_build.mcu: esp32s3
  # on_boot:
  #   then:
  #     - if:
  #            condition:
  #              switch.is_on: 
  #            then:
  #              - voice_assistant.start_continuous:


esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf
    version: recommended

logger:
  level: VERY_VERBOSE

api:

wifi:
  networks:
  - ssid: ZONE0
    password: !secret wifi_password
  - ssid: ZONE1
    password: !secret wifi_password
  - ssid: ZONE2
    password: !secret wifi_password
  ap:
    ssid: "Respeaker-S3 Fallback Hotspot"
    password: ""

captive_portal:

external_components:
  - source: github://QingWind6/ESPHome_XIAO-ESP32S3

i2s_audio_xiao:
  i2s_lrclk_pin: GPIO7
  i2s_bclk_pin: GPIO8
  i2s_mclk_pin: GPIO9

microphone:
  - platform: i2s_audio_xiao
    id: xiao_mic
    adc_type: external
    i2s_din_pin: GPIO44
    pdm: false
    bits_per_sample: 32bit
    channel: left

speaker:
  - platform: i2s_audio_xiao
    id: xiao_speaker
    dac_type: external
    i2s_dout_pin: GPIO43
    mode: stereo

voice_assistant:
  microphone: xiao_mic
  use_wake_word: true
  noise_suppression_level: 0
  auto_gain: 0dBFS
  volume_multiplier: 1
  speaker: xiao_speaker
  id: assist
  on_listening:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        effect: "Slow Pulse"
  on_stt_vad_end:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        effect: "Fast Pulse"
  on_tts_start:
    - light.turn_on:
        id: led
        blue: 100%
        red: 0%
        green: 0%
        brightness: 100%
        effect: none
  on_end:
    - delay: 100ms
    - wait_until:
        not:
          speaker.is_playing:
    - script.execute: reset_led
  on_error:
    - light.turn_on:
        id: led
        red: 100%
        green: 0%
        blue: 0%
        brightness: 100%
        effect: none
    - delay: 1s
    - script.execute: reset_led
  on_client_connected:
    - if:
        condition:
          switch.is_on: use_wake_word
        then:
          - voice_assistant.start_continuous:
          - script.execute: reset_led
  on_client_disconnected:
    - if:
        condition:
          switch.is_on: use_wake_word
        then:
          - voice_assistant.stop:
          - light.turn_off: led

light:
  - platform: esp32_rmt_led_strip
    id: led
    name: None
    disabled_by_default: true
    entity_category: config
    pin: GPIO1
    default_transition_length: 0s
    chipset: ws2812
    num_leds: 1
    rgb_order: grb
    rmt_channel: 0
    effects:
      - pulse:
          name: "Slow Pulse"
          transition_length: 250ms
          update_interval: 250ms
          min_brightness: 50%
          max_brightness: 100%
      - pulse:
          name: "Fast Pulse"
          transition_length: 100ms
          update_interval: 100ms
          min_brightness: 50%
          max_brightness: 100%

output:
  - platform: ledc
    id: light_output
    pin: GPIO21
    inverted: true


script:
  - id: reset_led
    then:
      - if:
          condition:
            - switch.is_on: use_wake_word
            - switch.is_on: use_listen_light
          then:
            - light.turn_on:
                id: led
                effect: none

          else:
            - light.turn_off: 
               id: led

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: template
    name: Use Listen Light
    id: use_listen_light
    optimistic: true
    restore_mode: RESTORE_DEFAULT_ON
    entity_category: config
    on_turn_on:
      - script.execute: reset_led
    on_turn_off:
      - script.execute: reset_led

Did you get this sorted? I’m having the same issue.

The issue is in the upstream repo. You should try using @formatBCE implementation, thats what I am using (48 kHz audio out with the microphone resampled to 16 kHz) and it works great. I’ll edit this comment with the link shortly.

There are 2 versions of the most recent (1.0.9) respeaker XMOS firmware, not to be confused with the esphome firmware for the esp32-S3. One has 16 kHz input/output and the other has 48 kHz input/output.

Depending on which firmware you flash to the respeaker board, you need to choose between the 2 different esphome YAML files in the repo. The 48 kHz output XMOS firmware needs to have the microphone input respamled down to 16 kHz because thats what the code expects. So, if you flash the 16 kHz 1.0.9 firmware to XMOS you need to use the 16 khz YAML file, likewise for the 48 kHz firmware.

1 Like

Great explanation!

I guess I will remove 16kHz versions to avoid confusing. 48kHz works good for several months for me.

Have you got a link to that please? I’ve flashed the device with the I2S firmware ver 1.0.9, man that was a steep learning curve :grimacing: but the device is not even connected when the download fails. I went to the upstream repo and copied the yaml directly from there. That made no difference so I’ve opened an issue.

If @formatBCE has a better version I’m happy to try.

GitHub - formatBCE/Respeaker-Lite-ESPHome-integration - this is the repo.

I recommend skipping through the thread "ReSpeaker Lite" - new Seeed Studio Voice Assistant Development Kit hardware combine ESP32 with XMOS XU316 DSP chip for advanced audio processing as a ESPHome-based Home Assistant Assist Satellite voice devkit for understanding why that or this was done.

1 Like

Thanks I’ll have a look…

Okay, I’ve had a skip through the entire thread you linked to, man that’s a lot of work.

I also looked through your repo, linked above. As far as I can tell, I have already updated the XMOS firmware to the latest I2S version 1.0.9, so does that mean all I need to do is copy the yaml file esphome-respeaker-lite.yaml into ESPHome and download it to the device?

If this works, I’ll certainly be buying you a few coffees :grin:.

UPDATE

Okay, so I decided to go ahead and insert the esphome-respeaker-lite.yaml, which took a while to compile, but I got there. After downloading and installing onto the device, the device is now online with a pulsing (quickly) blue LED and is now showing in Home Assistant. However, it doesn’t seem to be listening. The Assist satellite stays idle no matter which wake word I try.

1 Like

Most probably you didn’t install 48kHz version of firmware. There’s two 1.0.9 files in Seeed repo. The YAML in repository won’t work with default 16kHz firmware.

Ah righto. Can I reflash it with the 48kHz firmware in your repo?

Yes, it’s same file.

OMG it works! Thank you so much. Coffees incoming :grinning:

1 Like

Thank you :slight_smile:

Interestingly, I set up 2 Respeaker kits and when I connected the second one to HA it took me through the HA Voice PE wizard :thinking:.

This wizard is for all satellites now.
New YAML that I updated yesterday has all requirements intact to get that wizard.
If you want wizard for first device (but it’s already added), go to device and click “setup assistant” there.

1 Like