Waitforspeech Question


I have a problem using WaitForSpeech - I wonder if you could please advise DJ?

On my Win7 computer it does not work at all - there is no timeout the seconds variable gets ignored and the WaitForSpeech just runs through without a wait? I do see the timeout box very briefly. General SR works on this Win7 computer but I can only use it on US and not GB.

On my Win10 computer the same script works perfectly and the timeout window stays on the screen and counts down, so there is no problem here?

On the Win7 computer I then updated to the latest release (in case it was a previous bug) but this has made no difference.

Here is the script in question (which I borrowed from Rich)


SayWait("What is 4 times 4")
$response = WaitForSpeech(10, "10", "12", "14", "16")
If($response = "16")
SayWait("sorry that is incorrect, please try again")

Here is screendump of bottom of the Win7 screen.

User-inserted image

Thanks for your help



That's really bizarre. It looks like the project file is corrupt, but you say the exact project works on later os?


Do you have two (or more) controls with the same name?


Thanks DJ for responding, no there is only one control. I started a complete new project on the Win7 computer and added the script and still get the some problem. This computer will just not accept the WaitForSpeech function? Strange thing is, the SR is working for general things like "Robot enable speech" etc this all works? The bit that is failing is the timeout which seems to always default to zero seconds no matter what value it has been given. I am at a loss at what to try next?



I'm at a loss as well. I tried on a win7 computer today without any issues as well. That is a popular command for both RoboScratch and Blockly, which are used heavily in the classrooms with no issues.

Is this in a script manager control or a script control?


It a script control. Could there be a clue in the "waitforspeechcommand Error" shown on the bottom line of the screendump that I posted? "System.invalidoperationExecption" then indicates that grammar does not match.



Tony, just thinking out loud here, are you thinking the exception error is a mismatch between EN-US and GB speech recognition language setting of the control? In the control you say you have it set to EN-US (because that was the only way it worked on the Win7 computer)?

Or is it possible the error is pointing towards the list array, perhaps because on the Win7 it is less forgiving (my guess, apologies if it is bad/wrong guess) that the WaitForSpeech array has a mix of string variables and integers since the first 10 does not have quotes around it.


Justin, that error about theist collection is actually unrelated to the wait for speech. If that error is related to the script containing the wait for speech, I'm surprised it even runs at all.

This is because that error is related to compiling the ezscript after it has been edited. It's an internal error that should never ever ever happen. Hence why it also reads "strange,..." because the exception handler knows it's weird error.

I'm going to put a new EZ-Builder online today that has additional debug information about this scenario. however, I don't have a solution to suggest yet because I can't understand it.

My first instinct was that there were two controls running. My second is wondering if the script is a script manager.

Other than that, the error and situation, I beleive, is actually unrelated to wait for speech and instead is related to the pre-compile after edit.

@Tony, can you also verify that the script is not running via a ControlCommand() WHILE it is being edited in the edit window?


Thanks DJ for the explanation. I just loaded the latest EZ-Builder on a Win7 computer and ran Tony's script with no errors (language in EN-US of course). I did have to upgrade my .NET Framework to 4.62 because whatever it had was older and EZ-Builder provided the warning message that .NET needed updated before I could install.

Tony, just wondering, what version of .NET framework is on your Win7 system?

BTW Tony, I like your script sample, I've never seen that 10 second count down used that way before in WaitForSpeech, that's nifty! Smile


@tony, append this request to my previous question. Can you also post the project on here that is giving the trouble? The project can be posted using the ATTACH FILE feature to the right of the edit area.

Please send the project file from the windows 7 machine. Do not send a duplicate copy of the file from another computer.