Trouble with multiple recognizer.say commands

I am new to Movi, so pardon if this is an obvious question. How do I make Movi speak a multiple set of recognizer.say() commands? I have a simple set of four recognizer.say() commands, i.e.,

recognizer.say(“text”);
recognizer.say(“text”);
recognizer.say(“text”);
recognizer.say(“text”);

Movi will only say the first two then it hangs. The serial monitor hangs with MOVIEvent[150]: SPEAKING

That’s very odd.

Can you post the entire program? Did you rewire any of the serial communication?

Gerald

I am also having a problem with “say”. It doesn’t seem to be a blocking function so if you start speaking the next code instruction will execute before the speech ends.

May just be my beginner level but I cannot monitor the events 150 & 151 (start and end speaking) as they aren’t accessible during the speech.

I’ll post more if I come up with a solution. Good problem :wink:

awk,

I also need to send multiple sequential speech commands to MOVI’s synthesizer.

My project is providing features for a Robotic Monkey Head. I use 2650 Arduinos for a 1. processor dedicated to MOVI for speech rec and speech synthesis 2. a control processor that provides most of the head’s intelligence logic, sensors and messaging between all other processors via hardware serial links and 3. a dedicated processor that handles all the PWM servos and DC servos moving the head’s elements (eyes, mouth eyelids, eyebrow, left,right, up down etc.).

Here is a solution and code snippets that work for me:

On the speech processor in the mail loop I check the receive serial port from the control processor for any commands that may have been sent.

When a speech command is detected, a function is called outside of the loop to process the command, speak it and monitor the events until the MOVI advises that the speech has completed (a -151 event code).

At this time I echo the original command back to the sender thus providing an acknowledge. With the acknowledge in hand the control processor can then send the next speech command.

Here is the main loop code:

// **********************check to see if we have received a command

if (busyFlag == false) { //only process one command at a time
rxCommand = Serial2.readString();//fetch anything in the serial receive buffer
if (rxCommand.length() > 0) {//we have a command!
busy();//set the busy flag so other actions don’t stomp on this process
Serial.println("received command from control processor => " + rxCommand);
if (rxCommand.substring(0, 3 ) = “say”) {// a 'say ’ prefix to the command flags the command as a speach
rxCommand = rxCommand.substring(4, rxCommand.length());//remove the ‘say’ prefix
speak(rxCommand);//send the speach to the function for processing
done();// clear the busy flag
}
if (rxCommand.substring(0, 3 ) = “cmd”) {
// for future use, a ‘cmd’ prefix identifies commands meant for the MOVI to execute
// as sent by the control processor
}
}
}

and here is the function that processes a speech command sent from the control processor:

void speak(String speech) {
signed int pollCode;//signed event from MOVI
int eventCode;// used to (strip sign) evaluate MOVI event codes

startTime = millis();//start the timeout timer
recognizer.say(speech);// begin speaking

while (eventCode != 151) { //-151 is the code for finished speaking
pollCode = recognizer.poll(); // Get event codes from MOVI - negative values denote events
eventCode = abs(pollCode);// event code handling
if ((millis() > (startTime + timeout))) {
Serial.println("acknowlege timeout of say command => " + rxCommand);//rxCommand contains the speech sent from another processor over a serial link
rxCommand = “”;
return;
}
}
Serial2.print(rxCommand); //serves as the Acknowleged for a say command
Serial.println("sent acknowlege of say command => " + rxCommand);
rxCommand = “”;
}

I hope this helps you with your problem. I can stack up unlimited speech phrases with no overruns or crashes.

Pardon my coding but I code for maintenance and not memory or C compliance. Having fun!

cheers - Mike