Emic2 speaks all phrases one after the other instead of spaced by 10 seconds

I am running Arduino 1. 0. 5 on a Mega with a Chronodot RTC and an Emic2 text to speech converter. I am developing a home and garden control system that annunciates what it is doing when it makes a decision. The simple code below should say phrases spaced by ten seconds as my Mega sets up my shed control system, all the Serial.println("number") statements are purely for me to try and track what is going on. What it actually does, which I do not actually believe, is to immediately say all the phrases one after the other with no delay, then silence, then executes the code perfectly as though the emicSerial.print statements were missing from the code. I have bounced this problem off a software engineer who thinks it might be a compiler problem but maybe I missed a trick somewhere in my code Can anybody advise

Gerry O'D

[ if (InitialisationControlCount == 0)
     Serial.println(" 1 ");
     emicSerial.print( "attention please                                                         attention please." );
     Serial.println(" 2 ");  
     Serial.println(" 3 ");    
     InitialisationControlCount = InitialisationControlCount + 1;  //  InitialisationControlCount now = 1 
     Serial.print(" InitialisationControlCount = " );
    Serial.println (InitialisationControlCount);
     Serial.println(" 4 ");
    if (InitialisationControlCount == 1)
     Serial.println(" 5 ");
     emicSerial.print( "shed control system is in the process of booting up, please wait." );
     Serial.println(" 6 ");
      Serial.println(" 7 ");
     InitialisationControlCount = InitialisationControlCount + 1;  //  InitialisationControlCount now = 2
     Serial.print(" InitialisationControlCount = " );
     Serial.println(" 8 ");
    if (InitialisationControlCount == 2 )
      Serial.println(" 9 ");
     emicSerial.print( "setting shed processor clock to internet time, please wait" );
      Serial.println(" 10 ");
      Serial.println(" 11 ");
     InitialisationControlCount = InitialisationControlCount + 1;  //  InitialisationControlCount now = 3
     Serial.print(" InitialisationControlCount = " );
     Serial.println(" 12 ");
   if (InitialisationControlCount == 3)
     Serial.println(" 13 ");
     emicSerial.print( "shed processor time now set, please wait" );
     Serial.println(" 14 ");
     Serial.println(" 15 ");
     InitialisationControlCount = InitialisationControlCount + 1;  //  InitialisationControlCount now = 4
     Serial.print(" InitialisationControlCount = " );
     Serial.println(" 16 ");code]

Hi Gerry

Could you please post your complete program?

You say ...

... then executes the code perfectly as though the emicSerial.print statements were missing from the code ...

Do your debug println statements print what you expect, with the correct delays between them?

How is the emic2 connected to the Mega?



Dear Ray,
Thank you for taking time to look at my problem. Emic2 connected, SOUT = pin 52, SIN = pin 50. All Emic2 demo software works fine. All println statements do exactly what I expect with the 10sec breaks between. This is my second attempt at this post. Tried to post my code, 815 lines but it broke the bank. If ever I manage to get it to you the Emic2 relevant lines are 29 - 34, 180 - 192, 267 - 272 and bit of code I have already given and not working is 310 - 358. Just to give you an idea of what I am building Google " shed intel inside " Please vote for my shed while you are there. How can I get you the code to look at?

Thanks again

PS I think I have attached the code

Emic2_Chronodot_Timed_Valve_control.ino (27.6 KB)

Hi Gerry

I've got the code - thanks for that.

Can I check something about the problem, by taking a small example.

    if (InitialisationControlCount == 0)
        Serial.println(" 1 ");
        emicSerial.print( "attention please                                                         attention please." );
        Serial.println(" 2 ");  
        Serial.println(" 3 ");

In this part of the code:

  1. Do you see the "1", "2" and "3" on the serial monitor?

  2. How long (in seconds) is there between seeing the "1" and hearing the [u]start[/u] of "attention please etc"?

  3. How long does the Emic take to say the whole "attention please ... attention please" phrase?

  4. When, in relation to that phrase, do you see the "2" on the serial monitor?

  5. How long between seeing the "2" and the "3"?

Sorry for all the questions but I'm just trying to get a handle on the sequence of events.



Dear Ray, Thanks for a quick response. To answer your questions I have carefully written down what happens on the serial monitor

Monitor opens with a blank Emic2 says ALL the phrases in the code not just " attention please....." I repeat it says all the phrases then silence. The emic2 says the phrases as though I had typed them as one phrase The monitor now starts to respond, the emic2 stays silent 1 2 immediately after each other 10 sec wait 3 initialisation count 1 4 5 6 immediately after each other 10 sec wait 7 initialisation count 2 8 9 10 immediately after each other 10 sec wait 11 initialisation count 3 12 13 14 immediately after each other 10 sec wait 15 initialisation count 4 16

Well that is what it does. It is as though the compiler moved all the emic2 phrases in one lump to the top of the code then the rest of the code runs as though those line have been extracted. If this is so, then I need to change my code in some way to stop the compiler doing that? Hope all the detail I have given you answers all your questions Gerry PS If I close and open the serial port it repeats the process. Does opening and closing automatically do a system restart?

Thanks, Gerry. The easy question is your last one - yes, closing and opening serial does a reset, at least on some of the Arduino models (maybe all).

About the Emic …I looked in the documentation on their website.

Command set
Each command must be terminated with a CR or LF.
Sx Convert text-to-speech: x = message (1023 characters maximum)

You send an S at the end of startup(). But then you emicSerial.print the various messages. The “print” does not add a CR or LF. You either need to add “\n” at the end of each message string, or change to emicSerial.println(" your message ").

Then, I think you need to send another “S” before each following message.

All this would explain why the messages come out as one block. I’m still not sure why there is no serial monitor output or delays until after the messages are spoken.

I also found an example program with the library. It has a “structural” difference versus your code.

emicSerial.print("Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song.");  // Send the desired string to convert to speech
while (emicSerial.read() != ':');   // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command

As well as the “S” and “\n”, the code waits for the Emic to respond before sending another message. Not sure how essential this will be in your application, but it is something to consider.

All the best


Dear Ray, You have sorted me out, code running perfectly now. I thought that after emic2 setup you did a "/S " and then threw text at it willy nilly and it would speak, obviously not. Did you look at my shed? Google " shed intel inside " . I am in the Shed of Year competition with my arduino project. If you have time please vote daily until Monday. Sorry to ask but have only come 4th and 5th in previous years and need every vote I can get,

Thank you again for your time and expertise

Gerry gerryshawend@btinternet.com

Glad to hear that, Gerry.

And impressive shed! Just voted.

Thanks again Ray, glad you like shed only took 20 years to build, please vote every day until Monday. Appreciate your valuable time Gerry