Notes About Working with Various Arduino & Netduino Microcontroller Boards

Sunday, April 21, 2013

Emic 2 Text-to-Speech Module & the Arduino Due

The Emic 2 text-to-speech module is a 5 volt serial device, but the Arduino Due's I/O pins don't tolerate more than 3.3 volts. The serial connection requires a logic level converter, such as the Sparkfun Logic Level Converter (BOB-08745). For me experiments with the Emic 2, I am using a cheap, thin 8 Ohm speaker without amplification.

On the Arduino Due, there are three serial ports available for use with the Emic 2 (since the first Serial device is used for the serial console).  The example below uses Serial1 (pins RX1 & TX1). You could also use  Serial2  (RX2 & TX2), or Serial3 (RX3 & TX3).


Connections



Arduino Due Logic Level Conv Emic 2
TX1 (D18)   LV TXI - HV TXO  SIN
RX1 (D19)   LV RXO - HV RXI  SOUT
GND         LV GND
GND         HV GND           GND
5V          HV HV            5V
3.3V        LV LV    

SP+ and SP- on the Emic 2 are connected to the speaker.


Code


The code below doesn't do anything special  it's just the usual "Hello world." 


void setup() {
  Serial1.begin(9600);
  // Check for response from Emic 2
  Serial1.print('\n');
  // Emic 2 returns ':' if ready for command
  while (Serial1.read() != ':'); 
  // Set volume to maximum
  Serial1.print('V18\n');
  delay(10);
  Serial1.flush();  
}

void loop() {
  Serial1.print('\n');
  while (Serial1.read() != ':');
  // 'S' command = say 
  String cmd = "S"; 
  String text = "hello world";
  Serial1.print(cmd + text + "\n");
  while(1) { ; } 
}

Note that each command ends with a new line character ('\n'). Here is the list of available commands for the Emic 2 taken from its User Manual -


Sx  Convert text-to-speech: x = message (1023 characters maximum)
Dx  Play demonstration message: x = 0 (Speaking), 1 (Singing), 2 (Spanish)
X   Stop playback (while message is playing)
Z   Pause/un-pause playback (while message is playing)
Nx  Select voice: x = 0 to 8
Vx  Set audio volume (dB): x = -48 to 18
Wx  Set speaking rate (words/minute): x = 75 to 600
Lx  Select language: x = 0 (US English), 1 (Castilian Spanish), 2 (Latin Spanish)
Px  Select parser: x = 0 (DECtalk), 1 (Epson) 
R   Revert to default text-to-speech settings 
C   Print current text-to-speech settings
I   Print version information
H   Print list of available commands

The manual contains additional information about these commands. 

No comments:

Post a Comment