Getting Started Guide - alan4186/Speakjet-Interface GitHub Wiki

This page will help you to use the library I have created and get a working demo finished quickly.

The Code

The helper functions I have written are included at the bottom of the demo sketch so that they can use the software serial object initialized at the top of the sketch to communicate with the SpeakJet

Forming Sentences

The commands.h and wordCmds.h files make it easier to create phrases for the SpeakJet. These files create a variable for all of the words in the SpeakJet's dictionary. The variables represent character arrays of commands. The variable names for each of the words starts with an underscore to prevent conflicts with keywords or other variable names a programmer may use. There are 'words' for each letter of the alphabet as well, so if a word is missing from the dictionary a programer can spell it phonetically to produce a close approximation of the word. To create a sentence (just a 2D character array) you can just use the variables for the words instead of individual commands, for example

char * message[] = { _hello, _world ,_i , _am, _the, _speakjet };

instead of

char message[] = { 183, 7, 131, 145, 146, 164, 5,
                   147, 151, 145, 176, 5, 157, 5,
                   132, 132, 140, 5, 8, 169, 8,
                   128, 5, 187, 198, 8, 128, 196,
                   165, 131, 191
                 };

You sentence can then be sent to the SpeakJet with the sendSentence function described below.

sendSentence

The send sentence function takes a 2D array of characters and a single character as its input arguments. The first dimension of the array should represent words, the second dimension should represent individual commands that make up the words. The second single character argument is the 'pause' character and is played between each word. Normally the 'pause' character is the command P5 which delays speech for 60ms.

Syntax:

sendSentence(mySentence, myPauseChar);

The send sentence function reads the ready state pin of the SpeakJet to determine if the SpeakJet is busy. The function will wait until the ready pin is low to send the next character of a sentence or word. For debugging, the state of the pins is printed to the terminal.

resetSpeakJet

This is a simple function that will pull the SpeakJet's reset pin (defined in pinout.h) low and then high to reset the SpeakJet.

The Hardware

The SpeakJet has several interrupt or 'Event' pins that can be used to play predetermined phrases. My project does not use these pins because the number of I/O pins on the Arduino is limited and the same functionality can be achieved with the serial port. All of the 'Event' pins are grounded in the following pictures and diagrams. The SpeakJet has a few outputs that indicate the status of the device, including ready, speaking and buffer half full pins. The ready pin is the only pin that the Arduino must read to determine if a command can be sent. The buffer half full pin can be used instead of the ready pin. In my experience the ready pin and the buffer half full pin were were always inverted with respect to one another so I only read one of them. For this project, the Arduino did not need to know if the SpeakJet was speaking so that pin was not read by the program. A complete hookup diagram for the 'midterm-demo' sketch can be seen below:

SpeakJet hookup guide

The SpeakJet's data sheet recommends connecting the audio output of the SpeakJet to a two pole low pass filter to remove noise. The audio signal will need amplification if the filter is used. The circuit in the diagram above works ok, although there is signal degradation that occurs because of the poor connections made in the breadboard. Using headphones instead of a speaker can make the un-amplified signal easier to hear.