This repository contains examples of how I set up my Matrix Voice to record speech via Node-RED running on the Raspberry Pi. There are a few Node-RED flows which demonstrate the evolution of my experiments.
Before you can use these examples, upgrade Node-RED on your Raspberry Pi. Older versions of Node.js and Node-RED are pre-installed on the default Raspbian image. I started with Raspbian Stretch, applied distro updates, then installed Matrix Core only. I also used npm to install node-red-dashboard, node-red-contrib-microPi, node-red-contrib-snowboy, node-red-node-weather-underground and node-red-node-watson
I started at the command line and made certain that I could record audio.
/usr/bin/arecord -d 5 --device=mic_channel0 -r 16000 -c 1 -f S16_LE /home/pi/test.wav
Node-RED flows and screenshots included in this repository:
- arecord with Matrix Voice - Simple flow which records a .wav file via the Matrix Voice 8 MEMs microphones and sends it to Watson Speech to Text for transcription.
- arecord with Matrix Voice controlled by a Node-RED Dashboard - Same flow but controlled by a Node-RED dashboard.
- MicroPi with Watson Speech to Text - Replace the arecord exec node with a hacked MicroPi node.
- Snowboy wake word example - Use the Matrix Voice speaker to listen for a wake word "Hey Watson" using Snowboy
- Full example of Matrix Voice with a wake word and Watson Cognitive API to implement a ChatBot - A bit more sophisticated example that lets you talk with your Raspberry Pi . I pass the streaming speech to node-red-contrib-snowboy to listen for a wake word. In my case “Hey Watson”. That wakes up a Node-RED flow that uses Watson Speech to Text, Watson Conversation (in another version) and Watson Text to Speech to interact with the user.
Since configuring Node-RED nodes and wiring them together requires many steps to document in screenshots, there is an easier way to build a flow by importing a prebuilt flow into your Node-RED editor.
-
Some of the sections below will have a Get the Code link.
-
When instructed, open the Get the Code github URL, mark or Ctrl-A to select all of the text, and copy the text for the flow to your Clipboard.
-
Click on the Node-RED Menu (6), then Import (7), then Clipboard (8).
-
Paste the text of the flow into the Import nodes dialog and press the red Import button.
-
The new flow will be imported into new tabs in the Node-RED Editor.
As a first step, copy the code from GitHub to your Clipboard and import it into your Node-RED editor.
Get the Code - Node-RED Matrix Voice flows
arecord with Matrix Voice - Simple flow which records a .wav file via the Matrix Voice 8 MEMs microphones and sends it to Watson Speech to Text for transcription.
arecord with Matrix Voice controlled by a Node-RED Dashboard - Same flow but controlled by a Node-RED dashboard.
MicroPi with Watson Speech to Text - Replace the arecord exec node with a hacked MicroPi node.
Snowboy wake word example - Use the Matrix Voice speaker to listen for a wake word "Hey Watson" using Snowboy
Full example of Matrix Voice with a wake word and Watson Cognitive API to implement a ChatBot
The node-red-contrib-micropi node expects to record USB Audio via
arecord -D plughw:1,0
Matrix Voice outputs audio on mic_channel0. You can test with
$ /usr/bin/arecord -d 5 --device=mic_channel0 -r 16000 -c 1 -f S16_LE /home/pi/test.wav
I had installed node-red-contrib-micropi into /usr/lib/node_modules, so as root, edit /usr/lib/node_modules/node-red-contrib-micropi/micropi/nodes/micropi/lib/mic.js and change
_device = options.device || 'plughw:1,0';
into
_device = options.device || 'mic_channel0';
I'll propose a formal patch to node-red-contrib-microPi