When building NXT models, I like to get feedback on the state of the program or the state of sensors to make sure they are working as intended. The matrix display on the front of the NXT brick is great for some types of output and has some neat features. These include - showing up to 7 lines of text, drawing shapes and images, and doing simple animations. Some projects have used this to great effect. However, it has its limitations. The display is not very big, so you can’t read it from across the room. You need to be directly in front of it, so it can’t be covered or facing away. And finally it only shows black or white pixels.
Your other options for outputing state include; the motors (a precious resource), the red led on the light sensor (only good for binary output), and the speaker. Of these, the speaker is the best suited to fill the gaps where the display is lacking. It it quite loud, can be heard in any direction and can quicky convey different types of information.
Since the NXT can play sound files, we can use the speaker to play short spoken phrases. I use these to provide feedback in my models. So – where do get the spoken phrases from? One option is to record your own voice. For me, I prefer to use one of the text-to-speech web sites that convert written text into wave files you can download. I quite like the voices at the AT&T Text-to-Speech Demo site. You just follow these simple steps –
- Choose a voice (mens/womans/regional etc.)
- Enter the phrase to speak. Keep it down to a couple of words.
- Download it to your PC
The downloaded phrase is in a wave file that needs to be converted to an RSO file format which the NXT can play. There’s a nifty program written by John Hansen called wav2rso which does this conversion for you. It can convert a number of files at a time. You can set the quality of the conversion which effects the size of the file produced (higher frequency = better quality = larger files)
Now upload the RSO file into your NXT. You can do this with either; the standard NXT programming environment using the Memory Tab on the connection window, or one of the file managers in either RobotC or the BricxCC development environment.
Finally, you add code to your program to play the file at the appropriate time (e.g. when changing program state, or detecting an object). In NXT-G you use the Sound block to play the file. In RobotC you use the PlaySoundFile function. In either case, you specify the name of the sound file to be played.
And that’s it! With a few simple steps your model is speaking!
Here are some examples of my projects that have speech in them - OneMotorNXT, NXTShot