Canada
Asked — Edited
Resolved Resolved by thetechguru!

Voice Command And Recognition

Hello,

I am trying to write a simple block of code for Roli that will wait for a command, and have the robot repeat it.

When I say something the $ValSpeech variable is assigned the right value, but it will jump to the else every time.

When I click "Hello" or "Bye" from the Run screen, the robot will say the proper command.

Here is my code:

$ValSpeech = WaitForSpeech( 30, "Hello", "Bye")

If ($ValSpeech = "Hello") SayEZB("Hello") ElseIf ($ValSpeech = "Bye") SayEZB("Goodbye") Else SayEZB("Could you say that again?") EndIf

If there any problems with the code i provided could someone please help?

Thank you.


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

PRO
Synthiam
#1  

It's because the robot isn't understanding you. Have you trained your voice? Visit the speech recognition manual page. Get a better mic. Check if the mic is working. Etc... It's all documented on the manual page.

Here it is: https://synthiam.com/Tutorials/Help.aspx?id=90

You can look at a value of a variable. If you did, it would say "timeout": https://synthiam.com/Tutorials/Help.aspx?id=179

I'd start with Blockly or robotscratch to begin learning programming. They're great Interfaces that will provide excellent guidance.

#2  

IF statements on text are case specific, and the returned variable from speech recognition will always be lower case.

Your code should be:


$ValSpeech = WaitForSpeech( 30, "Hello", "Bye")
If ($ValSpeech = "hello")
SayEZB("Hello") 
ElseIf ($ValSpeech = "bye")
SayEZB("Goodbye")
Else
SayEZB("Could you say that again?")
EndIf

Alan

PRO
USA
#3  

Orimcg, You have 2 if statements. Try adding a second endif at the end. Or change the else if to just an else.

#4  

@rz90208 I only see one "if"... the other two are an elseif and else

PRO
USA
#5  

An else if is still an if statement.

#6  

See my answer. It is the case of the recognized words (first letter should not be capitalized). It works if you change to the code I provided.

Alan

PRO
USA
#7  

OK got back to a computer and I was incorrect only requires one endif. Tested Alan's solution and it works. I was unaware of the returned variable from speech recognition will always be lower case.

#8  

I am not 100% sure that it will always be lower case. Particularly if using the new Bing or Google speech integration. But pretty sure it will always be lower case if using SAPI.

Might be better to use, for example, "hello" or "Hello" in the IF statements to cover the bases. Maybe even "hello" or "Hello" or "HELLO"

Alan

Canada
#9  

Thank you for the response. It was because of the case sensitive comparison in the if statements!