Remember how we, humans, interact with computers in sci-fi movies? Computer do this, computer stop that. Why we still do not see all this voice interface awesomeness in our homes? Why we can’t just say “Computer, give me coffee” and get the coffee? It is not that difficult to implement and today we will do it.
Here is what we need:
- SSC-32 servo controller -- $40
- Standard Servo -- $13
- USB-to-RS-232 interface adapter -- $2 (ebay)
- Power source (for instance a 9V battery with clip)
Start with configuring the servo controller. Make sure these 3 groups of jumpers are set like it is shown on this picture. Refer to the regular user manual if necessary.
Plug the servo to the controller port 0 paying attention to the polarity: black wire goes to ground.
Now connect the controller to the PC and power it up. Anything between 6 and 9 volts will work fine, like this 9V battery for instance.
Download and install utility called LynxTerm to test if we assembled everything correctly. Run it, select the serial port and hit connect button: Now if you move the slider in the LynxTerm the servo should move too. You can also control the servo by sending commands via terminal.
It’s up to you what your robot will do. I attached a cart built from lego parts to the servo so it can move a cup of coffee upon a voice command.
The hardware part is ready, let’s proceed with the software. Make sure your computer has Java Runtime Environment installed. If not, download and install it.
Also download and uncompress this 37Mb archive from this site. It includes all you need to interact with your robot using voice interface and extend its capabilities if necessary.
Running the software is easy – just run the file called run.bat. It will list all available voices and serial ports. Rerun the same script with the voice and serial interface parameters that match your taste and system configuration. Now you can control your robot using two voice commands: “Computer give me coffee” and “Computer thank you”.
What if you want this robot to support more commands? Let me show you how.
Install Eclipse IDE and create new project with source files and libraries included in the package. You will need to modify two files.
givemecoffee.gram defines all phrases your robot should recognize. Just add new commands here.
GiveMeCoffe.java defines what robot does when the voice command is recognized. This code sends commands to the servo controller and synthesizes some speech. You can add your own command processing here, compile the project and have a robot with new capabilities in no time.
The program is quite small for the functionality it provides. This is because it utilizes the power of these 5 awesome components of which I’d like to highlight the speech recognition library called Sphinx4 from Carnegie Mellon University. It even can recognize my accent. Great Job, Sphinx team!!
- JSAPI – Java speech API by Sun Microsystems
- Sphinx4 – speech recognition library from Carnegie Mellon University
- Mbrola – a free speech synthesizer, we are using just its voices
- The voice synthesis is actually implemented with FreeTTS
- And commands are sent to robot using RxTx
All these libraries are free.
Own project is ready to amaze your friends, but it has one serious problem: quite steep price for relatively rare model of servo controller. In the following episodes of RTFMS video blog we will discuss how to reduce it significantly.