Arduino Speech Software
The sp0256 has its own built-in firmware, but needs feeding allophones so that it knows what to say. There is an ATmega328 with Arduino 16MHz Bootloader built into the design of the custom PCB, which will receive instructions from the master Arduino and supply the relevant Allophone values to the sp0256 enabling it to 'speak'.
// // Program for the Speech ATmega328 / sp0256 board. // // It will listen on the I2C bus for Allophones strings. // The Allophones will be space separated, and terminated by // the string "eot". // A lookup will be made in the Allophone array, and the // relevant numeric values sent to the sp0256. // #include <Wire.h> #define pin_ald A2 #define pin_lrq A3 char* allophones[64]; // Allophone storage array int allophone_value[100]; // extracted Allophone values for // the input words int allophone_count = 0; byte value; String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // is the string complete void setup() { // put the Allophone definitions in the array allophones[0] = "PA1"; allophones[1] = "PA2"; allophones[2] = "PA3"; allophones[3] = "PA4"; allophones[4] = "PA5"; allophones[5] = "OY"; allophones[6] = "AY"; allophones[7] = "EH"; allophones[8] = "KK3"; allophones[9] = "PP"; allophones[10] = "JH"; allophones[11] = "NN1"; allophones[12] = "IH"; allophones[13] = "TT2"; allophones[14] = "RR1"; allophones[15] = "AX"; allophones[16] = "MM"; allophones[17] = "TT1"; allophones[18] = "DH1"; allophones[19] = "IY"; allophones[20] = "EY"; allophones[21] = "DD1"; allophones[22] = "UW1"; allophones[23] = "AO"; allophones[24] = "AA"; allophones[25] = "YY2"; allophones[26] = "AE"; allophones[27] = "HH1"; allophones[28] = "BB1"; allophones[29] = "TH"; allophones[30] = "UH"; allophones[31] = "UW2"; allophones[32] = "AW"; allophones[33] = "DD2"; allophones[34] = "GG3"; allophones[35] = "VV"; allophones[36] = "GG1"; allophones[37] = "SH"; allophones[38] = "ZH"; allophones[39] = "RR2"; allophones[40] = "FF"; allophones[41] = "KK2"; allophones[42] = "KK1"; allophones[43] = "ZZ"; allophones[44] = "NG"; allophones[45] = "LL"; allophones[46] = "WW"; allophones[47] = "XR"; allophones[48] = "WH"; allophones[49] = "YY1"; allophones[50] = "CH"; allophones[51] = "ER1"; allophones[52] = "ER2"; allophones[53] = "OW"; allophones[54] = "DH2"; allophones[55] = "SSS"; allophones[56] = "NN2"; allophones[57] = "HH2"; allophones[58] = "OR"; allophones[59] = "AR"; allophones[60] = "YR"; allophones[61] = "GG2"; allophones[62] = "EL"; allophones[63] = "BB2"; // Set pin modes pinMode( pin_ald, OUTPUT ); pinMode( pin_lrq, INPUT ); DDRD = B11111111; // Set port D pins to output digitalWrite(pin_ald, HIGH); // tell sp0256 to listen // reserve 32 bytes for the inputString: inputString.reserve(32); inputString = ""; } void loop() { // Wait for Allophones from the Master // Convert input into the Allophone numeric values // Send all the Allophone values to the sp0256 for( byte b = 0; b < allophone_count; b++ ) { speak( allophone_value[b] ); } speak(0); // send stop speaking pause } void speak( byte allophone ) { // Wait for LRQ to go low while ( digitalRead(pin_lrq) != HIGH ); // load the data PORTD = allophone; // Tell the sp0256 to speak by toggling ALD digitalWrite(pin_ald, LOW); digitalWrite(pin_ald, HIGH); }
The Master Arduino sends, via the I2C bus, Allophone references that make up the phrase to be spoken. These allophones must include the pauses necessary between words. The buffer size for the I2C transmission is 32 bytes, so a long spoken message will have to be split into logical parts.
Once the allophones have been received, they are converted into numeric values for sending to the sp0256. Communication to the sp0256 is via handshaking, with one value at a time.