Welcome to Synthiam!

Program robots using technologies created from industry experts. EZ-Builder is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.
Get Started

New Zealand
Asked
Edited

Confirming A Human Response

This is one of my most used scripts. It is often called after my robot asks a question that requires a verbal response.

Positive responses = Yes, Affirmative, True, Okay, Correct
Negative responses = No, Negative, Incorrect, False, Wrong
Undecided responses = Maybe, perhaps, possibly

It converts the various answers to either Yes, No, Undecided or No Response and stores it in $Response for use by the main routine.

- Enjoy
Tameion (Wayne)



#---------------------------------------------------|
# Confirmation of a spoken response |
#---------------------------------------------------|

# Initialise Variables
$Name_Response_Loops=0

# Start the sequence

:Confirmation
$Name_Response_Loops=$Name_Response_Loops+1
Print ("Check # $Name_Response_Loops" )
$Response = WaitForSpeech(10, "Yes", "Affirmative", "True", "Okay", "Correct", "In correct", "No", "Negative", "False", "Wrong", "Maybe", "Perhaps" )


# Report initial response including any timeout
IF ($Response = "timeout" )
Print ("No response from User!" )
Else
Print ("I Heard you say $Response" )
ENDIF


# Take necessary action according to response
IF ($Response = "Yes" )
goto(Positive)
ELSEIF ($Response = "No" )
goto(Negative)
ELSEIF ($Response = "Affirmative" )
goto(Positive)
ELSEIF ($Response = "True" )
goto(Positive)
ELSEIF ($Response = "Okay" )
goto(Positive)
ELSEIF ($Response = "Correct" )
goto(Positive)
ELSEIF ($Response = "In correct" )
goto(Negative)
ELSEIF ($Response = "Negative" )
goto(Negative)
ELSEIF ($Response = "False" )
goto(Negative)
ELSEIF ($Response = "Wrong" )
goto(Negative)
ELSEIF ($Response = "Maybe" )
goto(Undecided)
ELSEIF ($Response = "Perhaps" )
goto(Undecided)
ELSEIF ($Response = "Possibly" )
goto(Undecided)
ELSE
IF ($Name_Response_Loops=3)
goto (No_Response)
ENDIF
goto(Confirmation)
ENDIF
Halt()

# All 'Yes' answers come here
:Positive
$Response = "Yes"
Halt()

# All 'No' answers come here
:Negative
$Response = "No"
Halt()

# All 'Maybe' answers come here
:Undecided
$Response = "Undecided"
Halt()

# No Answer comes here
:No_Response
$Response = "No Response"
Halt()

AI Support Bot
AI Support Bot
Synthiam
Hey there! This is an automated response from me, the support bot. I've searched other questions, tutorials and controls related to your question. Take a look at these links. They're all sorted by what I believe is the most relevant:
United Kingdom
#1  
You could probably simplify it with a few ORs in the IFs

i.e.

Code:


IF ($Response = "Yes" )
goto(Positive)
ELSEIF ($Response = "No" )
goto(Negative)
ELSEIF ($Response = "Affirmative" )
goto(Positive)
ELSEIF ($Response = "True" )
goto(Positive)
ELSEIF ($Response = "Okay" )
goto(Positive)
ELSEIF ($Response = "Correct" )
goto(Positive)


could all be replaced with

Code:


IF ($Response = "Yes" or $Response = "Affirmative" or $Response = "True" or $Response = "Okay" or $Response = "Correct")
GOTO(Positive)
ELSEIF
...


Then the same for negative.

There may be a way to check against a payload XML, I don't know if DJ has that implemented yet. VoxCommando (software I use for voice commanding my PC) uses XML lists for tv show names, actor, artists, albums, songs etc. etc.

So I'm thinking that the IF statement could cross reference to the XML file for acceptable responses rather than list them all out as ORs or ELSEIFs.
New Zealand
#2  
Interesting....

I tend to work vertically rather than horizontally as what is out of sight is often out of mind...lol.... will have a go tomorrow... 1am here... lol
United Kingdom
#3  
I too work that way but have recently been playing with the OR and AND commands, more to clean up code than anything else.

I personally see nothing wrong with large nests of IF statements (I also find them easier to follow than IFs with ORs)