I build Google Home Assistant for Armbian (S905x) based on NodeJS (because Python eating more resources)
For installation you need:
- NodeJS 14 and PM2
- Microphone and Speaker
- Device ID and Device Model ID (Create it on Google Cloud Console)
PM2 monitoring (Start -> Mic -> Detector -> Google Home Assist -> Audio -> Terminate)
- PM2 started the app
- Detecting wakeword/hotword
- If wakeword/hotword detected, send your voice to Google Assistant API
- Google Assistant will respons your voice
- App terminated and PM2 will restart this app
I don't know the efficient way to run this app.
The logic with systemd is same as pm2
. You can see on gassist.service
file
StartLimitIntervalSec=1m
StartLimitBurst=100
Restart=always
RestartSec=1
I use gassist.service
run on user instance because of when the armbian rebooted, pm2
run before pulseaudio
run, so it will got error Connection refused
This documentation is based on FreeBSD documentation (only documentation, not the apps). Shell user-prompt use $
in codeblock and root-prompt use #
in codeblock avoiding user confusion who directly use root account, using sudo instead of doas or vice versa.
Example
# nano
is equivalent with
$ sudo nano or doas nano
Add all of your configuration on .env file
DEVICE_ID=YOUR_DEVICE_ID // Obtained from GCP
DEVICE_MODEL_ID=YOUR_DEVICE_MODEL_ID // Obtained from GCP
LATITUDE=YOUR_LATITUDE //
LONGITUDE=YOUR_LONGITUDE //
MIC_HW='plughw:1,0'
For MIC_HW, you can get from arecord
command
$ arecord -l
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice # 350: subdevice #350
You can see is the card number is 1 and device is 0 so your plughw is plughw:1,0
Clone this repo
$ git clone https://github.com/icaksh/armbian-gassist $HOME/.config/gassist
Chdir to repo dir
$ cd $HOME/.config/gassist
Install audio dependencies
# apt install libmagic-dev libatlas-base-dev sox libsox-fmt-all build-essential
Install alsalib
or pulseaudio lib
for compiling backend
# apt install libasound2/pulseaudio-libs-devel
Install speaker-arm64
with your audio backend (example pulseaudio)
$ npm install speaker-arm64 --mpg123-backend=pulse/alsa
Install all dependencies
$ npm install
Move the gassist.service
file
$ mv gassist.service $HOME/.config/systemd/user/gassist.service
Enable the gassist.service
$ systemctl --user daemon-reload
$ systemctl --user enable gassist.service
$ systemctl --user start gassist.service
Check if gassist.service
is running
$ systemctl --user status gassist.service
● gassist.service - Google Home Assistant
Loaded: loaded (/home/icaksh/.config/systemd/user/gassist.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-03-20 03:01:11 UTC; 16min ago
Main PID: 10637 (node)
CGroup: /user.slice/user-1000.slice/user@1000.service/gassist.service
├─10637 /usr/bin/node /home/icaksh/.config/gassist/index.js
└─10645 arecord -q -r 16000 -c 1 -t wav -f S16_LE -
Install pm2
# npm install -g pm2
Run with pm2
$ pm2 start index.js
This repo is only for personal use. You cannot create a commercial product with this repo because of Google Assistant Policy.
This script was based on / modified from:
Copyright (c) 2023 Palguno Wicaksono
The copyright holders grant the freedom to copy, modify, convey, adapt, and/or redistribute this work under the terms of the Massachusetts Institute of Technology License.
A copy of that license is available at LICENSE