Skip to content
A nodejs + typescript implementation of the Google(tm) Assistant.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
spec
.gitignore
README.adoc
config.json
package.json
raspberry.adoc
tsconfig.json

README.adoc

node-assistant

overview

NB: there is a much more interesting implementation on the dev branch

This is a nodejs + typescript version of the Assistant from Google (tm). It uses the alpha sdk to talk to it, so it may stop working with major revision changes.

Note

If you haven’t come across Typescript before, it is just sugar on ES.next. If you compile this, it comes down to es6, so you can just use that and start modifying it if you like.

Particularly, this uses hotword detection. That is, it must use hotword detection. On starting it, you say "snowboy" and it will start listening to you, stream it to Google (tm) and stream the resulting audio.

Want to use your own hotword? Go to Snowboy and record your own, replace it in the config file. At the moment, you can even have multiple hotwords. They all trigger the assistant.

installation

I use yarn, but you should be able to use npm.

so

npm|yarn install
export VOICE_CONFIG=../../config.json

building

with yarn use:

yarn build

with npm use

npm run copy-js && npm run tsc

debugging

This uses node-debug - so set the environment variable

DEBUG=node-assistant node index

which tells it to turn debugging on.

configuration

Edit the config.json with your own client id + secret key as per the assistant website.

Then you need to cd into the target/app folder

running

cd target/app
node index

You will get a url, which will give you a code. Enter that code on the command line and it will generate a file and save it.

You can override the location of your credentials.json - it’s location is in the config.json file. I would recommend having both of them outside the folder you are using for this code.

There are a lot more configurable fields, it is based off the Java implementation of the Assistant. Go have a look at the client-config.ts file to see what you can change.

hotwords

The hotword stuff makes a 'ding' if it triggers. Its one of the missing things on Home that annoys me (the lack of the audible acknowledgement). You can turn it off by leaving out the sound file. That also makes it more reliable on MacOS.

what else?

  • I haven’t tested this outside of MacOS, I will test it on a Raspberry Pi next.

  • node-speaker appears to have a bug on MacOS, it will occasionally seg-fault. Since this isn’t a sensible deploy scenario, i’m not too worried.

  • I want to add in support for the Google Speech API and hand-off to api.ai. It supports multiple hotwords, so this is sensible.

  • Obviously I’d love to write spec tests for this, but I was more keen on getting it actually working.

finally

Really appreciate the team at Google for making this available, and the Snowboy team for making such a great library for hotword detection. If I ever make something commercial (and believe me, I only don’t have the backing!) I would use you guys and pay in a heart beat.

You can’t perform that action at this time.