I have conntected a TTS256 to an Arduino RX, TX and Speaking.
The TTS256 is connected to the Speakjet.
Everytime when i power on the circuit begins the speakjet to play some seconds random tones.
I think this are values who are in the TTS256 buffer.
What can i do to change this ?
#include <SoftwareSerial.h>
#define txPin 2
#define rxPin 3
#define busyPin 4
// set the data rate for the Speakjet Shield SoftwareSerial port
SoftwareSerial speakJet = SoftwareSerial(rxPin, txPin);
char sayThis[256]; // string (char array) that holds bytes of incoming string
// read a string from the serial and store it in an array
// this bit of code adapted from WilsonSerialIO.pde
// http://userwww.sfsu.edu/~swilson/
void readSerialString (char *strArray) {
int i = 0;
if(Serial.available()) {
//Serial.print("reading Serial String: "); //optional: for confirmation
while (Serial.available()){
strArray[i] = Serial.read();
i++;
Serial.print(strArray[(i-1)]); // for confirmation
}
strArray[i] = '\0'; // append a proper null to end of string
Serial.println(); // for confirmation
}
}
void setup(){
// initialize the serial communications with PC:
Serial.begin(9600);
// initialize the serial communications with the SpeakJet-TTS256
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
speakJet.begin(9600);
// make sure we are ready to start talking!
delay(1000); // this delay minimizes random spoken text in TTS256 buffer
speakJet.println("Talking term ready");
delay(1000);
speakJet.print(13, BYTE); // send cr
speakJet.print(20, BYTE); // vol
speakJet.print(127, BYTE); // 0-127 default 96
speakJet.print(21, BYTE); // speed
speakJet.print(75, BYTE); // 0-127 default 114
speakJet.print(22, BYTE); // pitch
speakJet.print(50, BYTE); // 0-255 default 88
speakJet.print(23, BYTE); // bend
speakJet.print(5, BYTE); // 0-15 default 5
speakJet.println("X"); // terminate passthruon
speakJet.println(10, BYTE); // add linefeed (\x0A)
delay(2000);
SJBusy(); // wait for speakjet buffer to empty
sayThis[0] = '\0'; // clear speakjet buffer
}
void loop()
{
// get string sent from PC
readSerialString(sayThis);
// speak it!
speakJet.println(sayThis);
SJBusy(); // wait for speakjet buffer to empty
sayThis[0] = '\0'; // clear speakjet buffer before getting next string
}
void SJBusy(){
delay(20); // wait 12ms minimum before checking SpeakJet busy pin
while(digitalRead(busyPin)){
delay(250); // wait here while SpeakJet is busy (pin 4 is true)
}
delay(250); // a bit more delay after busyPin goes false
}