Skip to main content

Voice Assistant System for Home Assitant

Say 'hello' to effortless control and 'goodbye' to tapping on screens with our voice assistant system.

Picture this: you're cozied up on your couch, and with just a simple shout-out to the ReSpeaker Lite, you can switch up the lights, crank up the tunes, or even ask about the weather – all without lifting a finger. Thanks to a nifty little Seeed XIAO ESP32S3 chip, you've got a mini-but-mighty brain that hooks up your voice to Home Assistant, making your smart home smarter and your life a whole lot easier.

This chapter we will use the ReSpeaker Lite Voice Assistant Kit to connect the Sonoff smart switch to realize voice control of the light switch.

Hardware Required

Getting Started

Navigate to your Home Assistant web interface.

To unlock the full potential of Home Assistant and gain access to advanced features, it's recomended to enable the Advanced mode in the user interface.

Click on your profile, and enable the Advanced mode.

pir

Install Add-ons

Go to Settings > Add-ons.

pir

Under the Official add-ons section, search and install the following add-ons:

  • ESPHome
  • Whisper
  • Piper
  • openWakeWord

Enable Start on boot and Watchdog, and click Start.

pir

tip

After the installation script has finished, restart Home Assistant to apply the changes.

After this add-on is installed and running, it will be automatically discovered by the Wyoming integration.

Go to Settings > System > Restart.

pir

Navigate to Settings -> Devices & Services, you will find these integrations under the Discovered.

pir

Click CONFIGURE and SUBMIT.

pir

There should be 3 entities in your Wyoming Protocol.

pir

Add your smart device

Here we use BASICR2 as a reference example.

Setup the device according to the manual.

Search and install Sonoff LAN in HACS.

pir

Navigate to Settings -> Devices & services, click ADD INTEGRATION, add Sonoff.

pir

Enter your eWeLink account credentials.

pir

When it connected, you will see an entity.

pir

Add Voice Asssitant

Navigate to Settings -> Voice Assistant.

pir

Enter a name and select:

Speech to text: Whisper

Text to speech: Piper

Wake word engine: openwakeword

pir

Choose a wakeword you preferred.

pir

Add XIAO ESP32S3 to ESPHome

Navigate to ESPHome, and click + NEW DEVICE.

pir

Enter a Name for your device, then click NEXT.

pir

Select ESP32-S3.

pir

Click SKIP, we will configure this file manually.

pir

Click EDIT and copy the following code:

pir

Remember to replace the Wi-Fi info:

wifi:
ssid: "Wi-Fi name"
password: "Wi-Fi password"
.yaml
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:
ssid: "Wi-Fi name"
password: "Wi-Fi 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

Click SAVE and then INSTALL.

pir

Choose Manual Download -> Modern-format.

pir

Connect the XIAO ESP32S3 to your PC via a USB Type-C cable.

Navigate to Web-ESPHome, click CONNECT, then choose the port and connect it.

pir

Select the .bin file we just downloaded, and click INSTALL.

pir

Wait for a few minutes for the installation. After the installation is successful, you will see the following prompt.

pir

Navigate to Settings and select Devices & Services.

pir

You will see ESPHome as a discovered integration. Click CONFIGURE.

pir

Click SUBMIT.

pir

pir

Now you are all set, try waking it up with hey jarvis and talking to it!

Project Sharing

Loading Comments...