Robot App Store Developer Program

robots-app-store-developer-program

Knowledge Base

Lego NXT Pre- Defined Text to Speech

  By Anna Sandler

This is an advanced topic, please make sure you've read the:
"What is a NXT Bluetooth Telegram",
"Lego NXT File Handling- Introduction",
"Create Files",
"Write To Files",
"Save and Close" and
"Play a Sound"
tutorials before you continue reading this chapter.

NXT doesn’t have a build in text to speech mechanism,
However, there is still some cool stuff that we can do with the pre-defined text to speech.

How does it work?

The following is a summary of the action steps (each step is described below):
  • Use a text to speech software on your computer to create a WAV file;
  • Convert the WAV file to the RSO- NXT sound file format;
  • Alternatively, to the steps above, you can use the audio editor that is built in Mindstorm's official software.
    It created RSO files from recording or a WAV file;
  • Transfer the RSO file to NXT’s brick using the FileOpenWriteCreate command -> FileWrite command and FileClose command or manually using Bluetooth file transfer;
  • When the time comes, use the PlaySoundFile command to make the robot “say” the pre-defined text;

Numeric speech

For pre- defined numeric speech all you need to do is to prepare the speech of:
  • First 10 digits 0-9;
  • The numbers: 10, 11, 12, 13, 15;
  • The suffix “teen”;
  • Twenty, thirty…
Now you have the combination for every number you want the robot to pronounce;

Preparations

Create a WAV file from text

  • Open the Free Audio Editor software that you’ve installed in the Preparations section;
  • Press the “Text to Speech” button as shown in this screenshot;
Free Audio Editor Text to Speech
  • Select 8000 in the Sample Rate drop-down list, Mono in “Channels” section and press OK;
Free Audio Editor Text to Speech Minimum Configuration
Free Audio Editor Text to Speech Minimum Configuration
  • In the Synthesize Speech window that is opened, type the text that you want the robot to say for later use,
    and press the Synthesize Speech button;
Free Audio Editor Synthesize Speech
Free Audio Editor Text Synthesize Speech
  • Save the file;
  • In the Wave File Setup window that is opened, select the Specify Settings option and press the Configure button;
Free Audio Editor Wave File Setup
Free Audio Editor Wave File Setup
  • In the Configure Wave Settings window that is opened,
    select the 8000 Hz as Sample Rate, 8 bits as Bit Depth and Mono as Channels and press OK;
Free Audio Editor Configure Wave Settings
Free Audio Editor Configure Wave Settings
  • Make sure that the wave file’s size does not exceed the 64k;

Convert the WAV file to RSO

  • Open the wav2rso freeware that you’ve installed in the Preparations section;
  • Click the Directory button, to select the working directory for the output of the converted RSO file;
  • Click the Select button, to select your wave file you just made, ready for conversion;
  • Select Linear from the list and set Rate to 8000;
  • Select the Compress check box;
  • Press the Convert button to finish;
wav2rso Converter
wav2rso Converter

Transfer / download the RSO file to NXT’s brick programmatically

  • Create an empty rso file on the NXT using FileOpenWriteCreate command;
  • In your code open the rso file for reading purposes;
  • Read file bytes;
  • Use the FileWrite command to write every 61 bytes to the empty file that has just been created;
  • Use the FileClose command to save the changes in the file;

Make the robot say a predefined text

Use the PlaySoundFile command to play the sound file;

wifes who cheat online affair women who cheat on their husband







Related Robot-Apps™

Comments