The miniDSP UMA-8 microphone array, with onboard direction detection, echo cancellation, and noise reduction, has a wide variety of applications. In this app note we'll run through its use with Watson, the "intelligent virtual assistant" from IBM to build a ChatBot. For those of you wondering what is a chatbot? It is a service, powered by rules that you interact with via a chat interface.
Why use the UMA-8?[Top]
By default, a chatbot requires a microphone to capture audio and one could say you could use a random 2 dollar plugin mic. This is fine if you are sitting at the computer, but for use of these programs as a "far field" hands-free assistant a more sophisticated microphone is needed. The UMA-8 has:
-
Beam-forming running across an array of 7 microphones to improve voice detection and eliminate extraneous noises.
-
Echo cancellation and noise reduction to reduce the effects of non-voice sounds (like music playing) and noise (traffic, kitchen noises etc).
The UMA-8 is "plug and play" – you do not have to configure anything to make it work with RPi. If you wish, however, you can use the miniDSP plugin to tweak the processing parameters of the microphone array (recommended for advanced users only!)
What you need:
- 1 x Raspberry Pi 2 or 3 along with a USB power supply for your Pi
- 1 x Keyboard
- 1 x HDMI Display
- An internet connection
- 1 x pair of Headphones (if your HDMI display doesn’t have inbuilt speakers)
- 1 x miniDSP UMA-8 USB Microphone Array
- An IBM BlueMix Account (see below details for registration)
As for skill-set required to put this demo together, you'll need:
- Some basic experience with the Raspberry Pi platform
- Some basic Bash skills (cd, ls, etc.)
- Basic Nano text editor skills (opening and saving)
- An eager mind, ready to learn how to make a Watson chat-bot!
Connecting Everything Up
First up, let’s build our bot! Take your Raspberry Pi and connect up the keyboard, HDMI display and headphones (if you need them). Next, you’ll need to plug in the UMA-8 USB Microphone Array, simply plug it into a USB port! That’s all there is to it as the UMA-8 is plug&play with RPi.
Preparing the Pi
Before powering on the Pi, you’ll need to download Raspbian Jessie LITE from the Raspberry Pi Foundation. Ensure you get the LITE version which doesn’t include a desktop. Burn the downloaded image onto a micro-SD card. Plug the micro-SD card into the Pi and plug in the power. You will see your monitor or TV come up with the a login prompt.
To log in, use the default Raspberry Pi login details.
Username: pi
Password: raspberry
If you have an Ethernet (wired) internet connection available, you're all set. Otherwise, you’ll need to setup the Wifi. Follow this guide to configure the Wifi on your Pi.
Downloading and Installing NodeJS
Once you’ve hacked your way into the pi, it’s time to start installing the brains of our bot. First up we need to install NodeJS. We can easily download node from our inbuilt package manager. . Run these commands to get NodeJS downloaded and installed:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs
Getting the Bot’s Brains Connected Up
Next up, we need to install the application that NodeJS will run to allow our bot to hear (via the UMA-8) and speak (via the speakers in your display, or headphones). First download the repository which contains the code:
git clone https://github.com/minidsp/uma8-watson-chatbot mic-array
cd mic-array
Now, let’s install all of the extra bits and bobs this application requires to run:
sudo apt-get install libasound2-dev npm install
Once the installation is complete, you’ll be ready to jump into IBM Watson
Configuring IBM Watson
Now that our Pi is completely ready to go, let’s put it aside for a second, we need to configure our bot’s brain so he knows how we’d like him to respond to our questions! If you haven’t already, sign up for IBM BlueMix. Once you’re logged in, navigate to the BlueMix Services Dashboard.
Click the big “Create Watson service” button in the middle of the screen.
Next, you’ll be presented with a catalogue of all the service IBM BlueMix has to offer. Let’s skip down to the “Watson” section in the sidebar.
We now need to add all 3 of these Watson services, one at a time:
- Conversation
- Speech to Text
- Text to Speech
First up, let’s install the Conversation service. Click the tile (outlined in red above). Once the page has loaded, we can leave the default settings and choose the “Create” button in the bottom left corner.
Lastly, we need to get the “Service credentials”. There details are used by our app will to connect to Watson.
Click the “View credentials” button to expand the tile and then copy the lines which contain the “username” and “password” into a text document on your computer. We’ll need these later, so make sure that they’re clearly labelled as “Conversation Creds” or similar.
Once you’ve got those detailed stored on your computer, we can move on to adding the other two services. Repeat this process and copy the credentials for the other 2 services too. NOTE: You will need all 3 pairs of credentials in order for the app to work.
Programming our Bot with Watson Conversation
Now that your BlueMix account is setup and you have all of the required services created, it’s time to write the logic for your chat bot. IBM have written an excellent blog to explain the basics and get you started. Check it out from this link.
Once you have created a bot you’re happy with, you’ll need to note down it’s workspace ID so you can tell your Pi which bot to use. To get your workspace ID, navigate to the conversation homepage by clicking the “Watson Conversation” link in the top-left of the bot configuration page.
Next, select the three dots in the top-right corner of the workspace tile you’d like to do and choose “View details”
Finally, copy down the “Workspace ID”. There’s a small, handy button next to the workspace ID which allows you to copy it to your clipboard.
Telling our Pi how to talk with Watson
Now that we have finished the process of retrieving our Watson credentials, we need to let our bot know to login to Watson. Jump back in front of your Pi, and ensure you’re in the mic-array directory which contains the app. We need to edit the “settings.js” file to include these details. Open the file with this command:
sudo nano settings.js
Now, replace each of the settings outlined in this file, with the settings you recorded earlier. You will also notice the workspace ID setting under the “Conversation”. Type in the workspace ID which we saved earlier here.
You’ll also see a setting to include a name for your bot. By default, his name is Duncan and he will respond when ever you address him by his name. You can change these names if you like!
Once your app is configured, it’s ready to run!
node app.js
Wrapping up[Top]
That's it for this app note! Have fun, and please let us know about your UMA-8 and Watson Chatbot experience in our forum.