From 09e83ff6709a016bba3b7a7add2c6d19f1676a6e Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 12 Sep 2023 10:39:53 -0500 Subject: [PATCH] Use webrtc --- openwakeword/CHANGELOG.md | 4 +++ openwakeword/DOCS.md | 27 +++++++++++++++---- openwakeword/Dockerfile | 3 +-- openwakeword/build.yaml | 2 +- openwakeword/config.yaml | 12 ++++++--- .../etc/s6-overlay/s6-rc.d/openwakeword/run | 10 ++++--- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/openwakeword/CHANGELOG.md b/openwakeword/CHANGELOG.md index 3105d90..a8074cf 100644 --- a/openwakeword/CHANGELOG.md +++ b/openwakeword/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.4.0 + +- Add noise suppression/auto gain with webrtc + ## 1.1.0 - Initial release diff --git a/openwakeword/DOCS.md b/openwakeword/DOCS.md index df6da31..79f245d 100644 --- a/openwakeword/DOCS.md +++ b/openwakeword/DOCS.md @@ -26,7 +26,8 @@ for more information. Name of wake word model to use. Available models are: -* `hey_jarvis` (default) +* `ok_nabu` (default) +* `hey_jarvis` * `alexa` * `hey_mycroft` * `hey_rhasspy` @@ -43,13 +44,29 @@ means fewer detections. ### Option: `noise_suppression` -Enable noise suppression using speexdsp. This should be used for low quality -microphones, or in noisy environments where noise suppression is not available -on the voice satellite. +Noise suppression level with +[webrtc](https://github.com/rhasspy/webrtc-noise-gain), where 0 is disabled +(default) and 4 is the max. Suppresses common sources of noise, such as fans, +but may distort audio. This should be used for low quality microphones, or in +noisy environments where noise suppression is not available on the voice +satellite. + +### Option: `auto_gain` + +Automatic gain control target dBFS with +[webrtc](https://github.com/rhasspy/webrtc-noise-gain), where 0 is disabled +(default) and 31 is the max. Raises the volume when someone is speaking too +quietly, but may distort audio. This should be used for low quality microphones, +or if the voice satellite is far away and does not have auto-gain functionality. + +### Option: `save_audio` + +Enable recording of audio to `/share/openwakeword` as WAV files. +**WARNING**: All audio is saved, including before the wake word is spoken, so this option should be disabled to preserve disk space. ### Option: `debug_logging` -Enable debug logging. Useful for seeing each wake word detection in the logs. +Enable debug logging. Useful for seeing satellite connections and each wake word detection in the logs. ## Support diff --git a/openwakeword/Dockerfile b/openwakeword/Dockerfile index dbbe9e2..fefc758 100644 --- a/openwakeword/Dockerfile +++ b/openwakeword/Dockerfile @@ -20,8 +20,7 @@ RUN \ setuptools \ wheel \ && pip3 install --no-cache-dir \ - "wyoming-openwakeword==${OPENWAKEWORD_LIB_VERSION}" \ - 'speexdsp-ns==0.1.2' \ + "wyoming-openwakeword[webrtc]==${OPENWAKEWORD_LIB_VERSION}" \ \ && rm -rf /var/lib/apt/lists/* diff --git a/openwakeword/build.yaml b/openwakeword/build.yaml index 1d8b3da..e41e797 100644 --- a/openwakeword/build.yaml +++ b/openwakeword/build.yaml @@ -6,4 +6,4 @@ codenotary: signer: notary@home-assistant.io base_image: notary@home-assistant.io args: - OPENWAKEWORD_LIB_VERSION: 1.3.0 + OPENWAKEWORD_LIB_VERSION: 1.4.0 diff --git a/openwakeword/config.yaml b/openwakeword/config.yaml index 503d309..80dd569 100644 --- a/openwakeword/config.yaml +++ b/openwakeword/config.yaml @@ -1,5 +1,5 @@ --- -version: 1.3.1 +version: 1.4.0-2 slug: openwakeword name: openWakeWord description: openWakeWord using the Wyoming protocol @@ -17,16 +17,20 @@ map: options: model: "ok_nabu" threshold: 0.5 - trigger_level: 2 - noise_suppression: false + trigger_level: 1 + noise_suppression: 0 + auto_gain: 0 debug_logging: false + save_audio: false schema: model: | list(ok_nabu|alexa|hey_jarvis|hey_mycroft|hey_rhasspy) threshold: float trigger_level: int - noise_suppression: bool + noise_suppression: int + auto_gain: int debug_logging: bool + save_audio: bool ports: "10400/tcp": null homeassistant: 2023.9.0.dev20230809 diff --git a/openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run b/openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run index c2dc7ab..e85aa07 100755 --- a/openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run +++ b/openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run @@ -4,17 +4,19 @@ # Start openWakeWord service # ============================================================================== flags=() -if bashio::config.true 'noise_suppression'; then - flags+=('--noise-suppression') -fi if bashio::config.true 'debug_logging'; then flags+=('--debug') fi +if bashio::config.true 'save_audio'; then + flags+=('--output-dir' '/share/openwakeword') +fi + exec python3 -m wyoming_openwakeword \ --uri 'tcp://0.0.0.0:10400' \ --model "$(bashio::config 'model')" \ --threshold "$(bashio::config 'threshold')" \ --trigger-level "$(bashio::config 'trigger_level')" \ - --output-dir /share/openwakeword ${flags[@]} + --noise-suppression "$(bashio::config 'noise_suppression')" \ + --auto-gain "$(bashio::config 'auto_gain')" ${flags[@]}