Using the Sparkfun Speakjet Voicebox Shield with an Arduino in Passthrough mode

Nope, no music associated with this post either. There is a followup post, where I talk about the TTS256.

I wrote this junky piece specifically because when I was looking for the answer I found a lot of wrong information.

I recently puchased a Voicebox shield based on the Speakjet from Sparkfun Electronics for an Arduino project. The Speakjet is an embedded chip that essentially does allophone voice synthesis. That means you can’t send it plain text like “this article sucks”, but you send it a stream of codes for the allophone (vocal sounds) to build up words.

A useful tool from Magnevation, the folks to make the Speakjet, is this Windows program called Phrase-A-Lator, which has a fairly decent dictionary of word-to-allophone translations, and has the ability to pump information directly at a speakjet connected to a PC via a serial port. That’s nice because you program the EEPROM with some phrases directly, and test out how your phrasing sounds. Then with Phrase-a-Lator you can convert the text/allophone string into the proper codes to be sent to the Speakjet chip, and use that in your Arduino code.

The alternative to this is to buy the TTS256 chip, which I neglected to do, which contains a dictionary of words-to-allophones. You can solder it directly onto the voicebox shield, and then can just pump regular english text at the chip and have it speak.

With the Voicebox Shield on the Arduino, the problem is that the Magnevation software can’t communicate directly with the chip, since the communication is to the Arduino itself. No problem, you just need a simple little host program on the Arduino to redirect information to the Speakjet.

The wrinkle in this is how the Magnevation software works. The Magnevation software opens and closes the serial port every time you send information down. With the way the default Arduino setup is, when the USB-Serial connection is opened up by the host, it institutes a chip reset, and your program restarts. Then, of course, it will likely miss all the actual serial information Phrase-A-Lator sends as the Arudino’s onboard program gets up and running.

If you try my program below, and every time you communicate with Phase-A-Lator and all the chip does is constantly spout “READY”, that means the board is being reset, and you need to disable the auto-reset.

Luckily, I wrote an entire huge article on how to disable the auto-reset once before.

The other thing to watch with Phase-a-Lator is to disable Flow Control, since there is no flow control. If you leave it enabled it will just hang the software.

Here’s the Arduino code. It’s really simple. It also actually works, at least for me, as opposed to lots of other sample code you can find to do this. It uses NewSoftSerial, because NewSoftSerial is the bomb.

If you don’t know how to copy and paste, you can download this tiny pde from here.

// A Dirty SpeakjetPassthrough program for the Arduino. 
// For testing the Arduino VoiceBox Shield from
// This program lets you test your Speakjet VoiceBox Shield with 
// Magnavation's (maker of the Speakjet chip) Phrase-A-Lator test program. 
// Steven Cogswell, July 2011. 
// Includes probably five lines taken from the Sparkfun demo code. 
#include <NewSoftSerial.h>

#define txPin 2   // The pin for communicating to the Speakjet chip on the Arduino
#define RES  3   // The reset pin for the Speakjet. 

byte in;

// The NewSoftSerial object to talk to the Speakjet.  The Voice Shield doesn't have
// any communication back from the Speakjet chip, so all you need is Tx. 
NewSoftSerial speakjet(0,txPin);

void setup() 
  Serial.begin(9600);   // Serial communication with computer
  speakjet.begin(9600);   // Serial communication from arduino to Speakjet chip 

  //Set up a serial port to talk from Arduino to the SpeakJet module on pin 3.

  //Configure Reset line as an output
  pinMode(RES, OUTPUT);

  //All I/O pins are configured. Reset the SpeakJet module
  digitalWrite(RES, LOW);
  digitalWrite(RES, HIGH);    // Doing this reset will make the chip say "Ready" 
  // This says "Try it now", generated from the PhrasALator and just pasting it in. add a 0 at the end to null-terminate the string. 
  char message[] = {20, 30, 21, 114, 22, 120, 23, 5, 8, 191, 7, 148, 155, 8, 129, 8, 191, 142, 163, 0};

void loop() {
  // Loop forever, read a byte from input and just push it to the Speakjet.    
  if (Serial.available()) {; 

Here’s a couple of Phrase-A-Lator screenshots

When you have your phrase right, you can select “View Codes” to get the numerical allophone sequence and paste it into your Arduino code, as the program above does.

Here’s a voice demo,

You can also visit this website, which has nothing to do with any of this.

And as usual, you need a picture of an Arduino in your post in order to be taken seriously.