Home‎ > ‎DroidBuilder's Tutorials‎ > ‎

Programming the SpeakJet Shield TTS


Programming the SpeakJet Shield TTS to speak English text is fairly easy; a minimal program requires only several lines of code!

Configure the SpeakJet Shield TTS for use:

The photo below shows where the post shunts are pushed onto the board for normal use of the SpeakJet Shield TTS.

Settings for SpeakJet Shield TTS v1,0-1.2 (Click on photo to enlarge.)

Confirm that the shunts installed during assembly are in the proper positions. A post shunt should already be installed on the two pin header labeled "SJTest" near R3. This puts the SpeakJet into its normal running mode (when the shunt is removed, the SpeakJet is in a self-test mode). For the software examples below to work, this shunt MUST be installed!

A post shunt should also already be installed on the two pins at the "TTS" labeled side of the three post header near IC2 (the SpeakJet chip). This connects serial communication from digital pin 2 of the Arduino directly to the text-to-code processor. The proper position of this  shunt is shown in the photo below.


A post shunt may also be installed to signal either a SpeakJet buffer half-full (BHalf) or SpeakJet busy (Busy) condition to your Arduino. This can be used as a form of flow-control if you need it in your programs. Some programs you write may not need flow control so this shunt may be removed if you desire. For the software example used on this page, the shunt is plugged onto the two pins at the "Busy" side of the three post header near R3 as shown in the photo below.


Writing Software for the SpeakJet Shield TTS:

Note for SpeakJet Shield TTS v1.3 or later:
wherever #define txPin 2  appears, change it to #define txPin 6
wherever #define rxPin 3 appears, change it to #define rxPin 5
wherever #define busyPin 4 appears, change it to #define busyPin 7

A classic first program could be "Hello World".

Stack your Arduino and SpeakJet TTS Shield together; connect your stereo headphone (I-Pod ear-buds work great!) or speaker to the SpeakJet TTS Shield headphone jack. Connect power to the Arduino.

Start up the Arduino code editor, and create a sketch like the following.

// SpeakJetTTS Hello World sketch
// a demo showing a minimal sketch for the SpeakJet/TTS Shield
// written by Galen Raben / www.droidbuilder.com

// set up a new software serial port
#include <SoftwareSerial.h>
//rxPin: the pin on which to receive serial data
//txPin: the pin on which to transmit serial data
//busyPin: the pin used to monitor SpeakJet Busy line
// SpeakJet Shield v1.0-1.2 uses these pins:
//#define txPin 2
//#define rxPin 3

// SpeakJet Shield v1.3 or later uses these pins:
#define rxPin 5
#define txPin 6

SoftwareSerial sjSerial = SoftwareSerial(rxPin, txPin);

void setup(){
  // initialize the serial communications with the SpeakJet-TTS256
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  sjSerial.begin(9600);// set the data rate for the SoftwareSerial port
  delay(1000); // wait a second for the Arduino resets to finish (speaks "ready")
  sjSerial.println("Hello world!"); // send it to the SpeakJet
}

void loop()
{}

At this point, save the sketch and click the "Upload" button in the Arduino editor.

After a few moments, the Arduino will reset and you may hear "ready" spoken multiple times (at least with mine, three times is common).

After that, it very shortly should say "hello world". If it doesn't, press the "Reset" button on the shield; it should then say "ready" once and then "hello world" (note: sometimes random squeaks and quacks may be heard  during the upload,  after uploading is done, press the Reset button twice). If you still don't hear anything, check the speaker connection and the setting of the volume pot on the shield (turning more clockwise is louder).

You will note I highlighted part of the sketch above in yellow. As an exercise, you can modify this to say whatever you want the shield to speak. Have fun!

Note: The sketch above has been tested on Arduino 15, 17 and 18 software. If you have an earlier version of the Arduino software, the sketch may or may not function.


Creative Commons License
SpeakJet Shield TTS/Basic by Galen Raben is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Permissions beyond the scope of this license may be available at http://www.droidbuilder.com.

The code samples given in this document are released into the public domain.

© 2010 Galen Raben/DroidBuilder.com
ċ
TTS_HelloWorld.pde
(1k)
Galen Raben,
Nov 6, 2009, 10:46 PM