Year of the Voice - Chapter 4: Wake words

I noticed stutter when using en-GB. En-US was fine

This is how I did it.

  openwakeword:
    container_name: openwakeword
    image: rhasspy/wyoming-openwakeword
    volumes:
      - ./config/openWakeWord/config:/config
      - ./config/openWakeWord/data:/data
      - ./config/openWakeWord/custom:/custom
    environment:
      - TZ=America/Los_Angeles
    restart: unless-stopped
    command: --preload-model 'ok_nabu' --custom-model-dir /custom
    ports:
      - 10400:10400
      - 10400:10400/udp

Then as @Fraddles says, enter the IP address of your Docker container. I couldn’t get it to work with the non-default port, fwiw, but there’s no conflict with 10400 on my host.

Do you mean here

I have tried changing options there but I am finding the stutter isn’t consistent so hard to test. This is why I thought it might be a hardware resource constraint that was coming and going?

Same problem here. Did you find a solution?

INFO ESPHome 2023.10.1
INFO Reading configuration /config/esphome/m5stack-atom-echo-8a1468.yaml...
INFO Updating https://github.com/esphome/esphome.git@pull/5230/head
INFO Generating C++ source...
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
  File "/esphome/esphome/__main__.py", line 1036, in main
    return run_esphome(sys.argv)
  File "/esphome/esphome/__main__.py", line 1023, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
  File "/esphome/esphome/__main__.py", line 454, in command_run
    exit_code = write_cpp(config)
  File "/esphome/esphome/__main__.py", line 190, in write_cpp
    return write_cpp_file()
  File "/esphome/esphome/__main__.py", line 208, in write_cpp_file
    writer.write_cpp(code_s)
  File "/esphome/esphome/writer.py", line 342, in write_cpp
    copy_src_tree()
  File "/esphome/esphome/writer.py", line 295, in copy_src_tree
    copy_files()
  File "/esphome/esphome/components/esp32/__init__.py", line 593, in copy_files
    repo_dir, _ = git.clone_or_update(
  File "/esphome/esphome/git.py", line 95, in clone_or_update
    old_sha = run_git_command(["git", "rev-parse", "HEAD"], str(repo_dir))
  File "/esphome/esphome/git.py", line 32, in run_git_command
    raise cv.Invalid(err_str)
voluptuous.error.Invalid: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I did actually. I just tried again a day or so later and it worked fine. I think there was just an issue with it accessing the github repo

Wake word being detected and sound playin from the speaker.
How do I activate an LED for the start event and switch it off once its done.
Visual indication that the wakeword was detected and not just sound.
Also, what event to use to switch and led on while piper is speaking?
Thanks

1 Like

I’ve tested openwakeword with both the Jabra 410 speakerphone and the Avaya B109 attached to the RPi4. Both appear to work well.

1 Like

I had… but I noticed, it was somehow random…

Sometimes, the external ressource could not be loaded during the compilation - and then I got errors.
When I tried it again, after a few minutes, it was working well…

Yep, I tried again a few days later and all went smoothly. Odd.

Also, your error shows an issue with strapping pins.
I remember, that I read something about this in one of the release notes recently…

I just looked at that PR which states that GPIO4 should actually be 5, but GPIO4 or GPIO5 aren’t used in the config for the ESP-box so I don’t know why it would throw that error, unless the code has been updated to remove either of those.

You can try this:

esphome:
  name: esp32-voice
  friendly_name: esp32-voice
  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: lolin32_lite
  framework:
    type: esp-idf
    version: recommended

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Mic-Speaker"
    password: "9vYvAFzzPjuc"

i2s_audio:
  i2s_lrclk_pin: GPIO2
  i2s_bclk_pin: GPIO14

microphone:
  - platform: i2s_audio
    id: mic
    adc_type: external
    i2s_din_pin: GPIO15
    pdm: false

speaker:
  - platform: i2s_audio
    id: big_speaker
    dac_type: external
    i2s_dout_pin: GPIO25
    mode: mono

voice_assistant:
  microphone: mic
  use_wake_word: false
  noise_suppression_level: 2
  auto_gain: 31dBFS
  volume_multiplier: 2.0
  speaker: big_speaker
  id: assist

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);
1 Like

I currently have a wake word in training which you might be interested in. It’ll be in my fork of the wake work repo ready for a PR to the main repo once it completes.

Give my a little while for the file to be in that folder :slight_smile:

4 Likes

For the possibility of a Raspberry Pi satellite, it is also possible for a Raspberry Pi Zero 2 W
Or is it possible to only have Raspberry Pi 4?

Hi Don,

May I ask how did you get your raspberry Pi to integrate with Home Assistant, I have followed Synesthesiam GIT instructions (GitHub - synesthesiam/homeassistant-satellite: Streaming audio satellite for Home Assistant) , but it don’t seem to be connected to home assistant after creating the token and then run the script as settings in Voice Assistant (select pipeline, and debug) - Run Audio with Wake Word Detection is still greyed out - so what makes the connection, adding this as a device in home assistant is not an option?

Thanks in advance.

I have a few windows laptops spread around the house for viewing security camera feeds. Anyway I can use laptop mic/speaker as voice satellites?

Good day.
In this chapter it is written that it is possible to create voice satellites using the RPi.
I just bought a new ZERO 2W and I’m looking for a procedure to turn it into a satellite.
I run HA on RPi4 with SSD and hassos.
I found a link here in the chapter GitHub - synesthesiam/homeassistant-satellite: Streaming audio satellite for Home Assistant.
Unfortunately, I don’t know how to use it.
Would someone please be patient enough to help me turn the RPi Zero into a 2W satellite for my HA on the RPi4, or please provide a link to a step-by-step tutorial.

Many thanks in advance to anyone who lends a helping hand.
J.

The git hub is here for a test you just install and play with the test code.

GitHub - dscripka/openWakeWord: An open-source audio wake word (or phrase) detection framework with a focus on performance and simplicity. as its a pretty simple bit of Python.
I am not sure though if it runs on a Pi3 or its derivative Zero2, due to load though.
Would be good for someone to test.

You can the pip package sounddevice as

def sd_callback(rec, frames, time, status):
   frame = rec

   # Get predictions for the frame
   prediction = model.predict(frame)

# Start streaming from microphone
with sd.InputStream(channels=num_channels,
                    samplerate=sample_rate,
                    blocksize=int(sample_rate * rec_duration),
                    callback=sd_callback):
    threading.Event().wait()

A bit simplistic but gives you the base if you can hack a bit of Python code
I am just having a look myself and you can use https://github.com/dscripka/openWakeWord/blob/main/examples/detect_from_microphone.py

HI !

Just use changing state for porcupine1, openwakeword or snowboy