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
- ReSpeaker Lite Voice Assistant Kit
- Home Assistant Device
- Sonoff BASICR2
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
.
Install Add-ons
Go to Settings > Add-ons.
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
.
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
.
Navigate to Settings
-> Devices & Services
, you will find these integrations under the Discovered
.
Click CONFIGURE
and SUBMIT
.
There should be 3 entities in your Wyoming Protocol
.
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
.
Navigate to Settings
-> Devices & services
, click ADD INTEGRATION
, add Sonoff
.
Enter your eWeLink
account credentials.
When it connected, you will see an entity.
Add Voice Asssitant
Navigate to Settings
-> Voice Assistant
.
Enter a name and select:
Speech to text: Whisper
Text to speech: Piper
Wake word engine: openwakeword
Choose a wakeword you preferred.
Add XIAO ESP32S3 to ESPHome
Navigate to ESPHome
, and click + NEW DEVICE
.
Enter a Name for your device, then click NEXT
.
Select ESP32-S3
.
Click SKIP
, we will configure this file manually.
Click EDIT
and copy the following code:
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
.
Choose Manual Download
-> Modern-format
.
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.
Select the .bin
file we just downloaded, and click INSTALL
.
Wait for a few minutes for the installation. After the installation is successful, you will see the following prompt.
Navigate to Settings
and select Devices & Services
.
You will see ESPHome
as a discovered integration. Click CONFIGURE
.
Click SUBMIT
.
Now you are all set, try waking it up with hey jarvis
and talking to it!
Project Sharing
- From Smart Home Circle - Create LOCAL Voice Assistant w/ Home Assistant | NO Soldering | On Device Wake Word🔥| ReSpeaker Lite