Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 6a07ce0

Browse files
committed
Initial commit
0 parents  commit 6a07ce0

29 files changed

+1149
-0
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
.idea
3+
*.log
4+
tmp/
5+
6+
*.py[cod]
7+
*.egg
8+
*.egg-info/
9+
build
10+
htmlcov
11+
12+
/.venv/
13+
.mypy_cache/
14+
__pycache__/
15+
16+
/output/
17+
/token.txt

.isort.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[settings]
2+
multi_line_output=3
3+
include_trailing_comma=True
4+
force_grid_wrap=0
5+
use_parentheses=True
6+
line_length=88

.projectile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- /.venv/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Michael Hansen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include requirements.txt
2+
include homeassistant_satellite/models/*.onnx
3+
include homeassistant_satellite/sounds/*.wav
4+
include VERSION

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Home Assistant Satellite
2+
3+
Python-based satellite for [Assist](https://www.home-assistant.io/voice_control/) that streams audio to Home Assistant from a microphone.
4+
5+
You must have the [openWakeWord add-on](https://my.home-assistant.io/redirect/supervisor_addon/?addon=47701997_openwakeword&repository_url=https%3A%2F%2Fgithub.com%2Frhasspy%2Fhassio-addons) installed.
6+
7+
8+
## Requirements
9+
10+
* Python 3.9 or higher
11+
* ffmpeg
12+
* libportaudio2 (for [sounddevice](https://python-sounddevice.readthedocs.io))
13+
14+
15+
## Installation
16+
17+
Install Python and the required system dependencies:
18+
19+
``` sh
20+
apt-get install python3 python3-pip python3-venv \
21+
ffmpeg libportaudio2
22+
```
23+
24+
Clone the repository and run the setup script:
25+
26+
``` sh
27+
git clone https://github.com/synesthesiam/homeassistant-satellite.git
28+
cd homeassistant-satellite
29+
script/setup
30+
```
31+
32+
This will create a virtual environment and install the package.
33+
34+
## Long-Lived Access Token
35+
36+
You must create a long-lived access token in Home Assistant for the satellite to access the websocket API.
37+
38+
1. Go to your profile page in Home Assistant
39+
2. Scroll down to "Long-lived access tokens"
40+
3. Click "Create token"
41+
4. Enter a name and click "OK"
42+
5. Copy the **entire token** using the copy button provided
43+
6. Save the token somewhere you can paste from later
44+
45+
46+
## Running
47+
48+
``` sh
49+
script/run --host <IP> --token <TOKEN>
50+
```
51+
52+
where `<IP>` is the IP address of your Home Assistant server and `<TOKEN>` is the long-lived access token.
53+
54+
This will stream audio from the default microphone to your preferred pipeline in Home Assistant.
55+
56+
See `--help` for more options
57+
58+
### Feedback Sounds
59+
60+
Use `--awake-sound <WAV>` and `--done-sound <WAV>` to play sounds when the wake word is detected and when a voice command is finished.
61+
62+
For example:
63+
64+
``` sh
65+
script/run ... --awake-sound sounds/awake.wav --done.wav sounds/done.wav
66+
```
67+
68+
### Change Microphone/Speaker
69+
70+
Use `--mic-device <NUMBER>` and `--snd-device <NUMBER>` to change the microphone and speaker. Get a list of devices with:
71+
72+
``` sh
73+
python3 -m sounddevice
74+
```
75+
76+
### Voice Activity Detection
77+
78+
Use `--vad webrtcvad` to only stream audio when speech is detected.
79+
80+
### Audio Enhancements
81+
82+
Use `--noise-suppression <NS>` suppress background noise, such as fans (0-4 with 4 being max suppression).
83+
84+
Use`--auto-gain <AG>` to automatically increase the microphone volume (0-31 with 31 being the loudest).
85+
86+
87+
## Troubleshooting
88+
89+
Add `--debug` to get more information about the messages being exchanged with Home Assistant.
90+
91+
Add `--debug-recording-dir <DIR>` to save recorded audio to a directory `<DIR>`.

homeassistant_satellite/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

homeassistant_satellite/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Streaming satellite for Home Assistant."""

0 commit comments

Comments
 (0)