Herr Ball
Ok, I'm stumped. I have tried to do this myself for 3 days, time for help. Is there any reason why a script that works in Windows 7 not work on Windows 10? Below is a script (Credit to Luis Vazquez who wrote this years back, I only added to it) that I can not get to run on my new Windows 10 computer. It is the exact same script on both machines. I know, if it works on one it should work on the other!
The program starts out:
Program says "Oh good, I love to do math."
"What would you like to do ... addition, subtraction, multiplication or division?"
(Your answer) ... "addition"
Program says back "I heard you say addition." "OK, I will give you 5 addition math questions." "Lets begin"
This is where the problem begins!
I does not give a addition question but a division question on the W10 machine?
It is the exact script, copied from one to the other ... lol.
# Initialise Variables
$QuestionNumber = 0
SayWait("Oh good, I love to do math")
:StartTheSquence
SayWait("What would you like to do, addition, subtraction, multiplication or division?")
$MathTypeResponse = WaitForSpeech(10, "Addition", "Subtraction", "Multiplication", "Division")
# Repeat MathTypeResponse
if ($MathTypeResponse = "timeout" )
SayWait("I did not hear what you said.")
SayWait("Lets start over.")
Goto(StartTheSquence)
Else
SayWait("I heard you say " + $MathTypeResponse )
SayWait("Ok, I will give you 5 " + $MathTypeResponse + " math questions.")
SayWait("Lets begin.")
endif
# Go to math type catagory
if ($MathTypeResponse = "Addition" )
goto(Addition)
ELSEif ($MathTypeResponse = "Subtraction" )
goto(Subtraction)
ELSEif ($MathTypeResponse = "Multiplication" )
goto(Multiplication)
ELSE
goto(Division)
endif
# If MathResponse was addition.
:Addition
$FirstAdditionNumber = GetRandomUnique(0,5)
$SecondAdditionNumber = GetRandomUnique(0,5)
$AdditionAnswer = $FirstAdditionNumber + $SecondAdditionNumber
:loop
$QuestionNumber = $QuestionNumber + 1
if ($QuestionNumber = 6)
SayWait("That was 5 " + $MathTypeResponse + "questions.")
SayWait("Would you like to start over again?")
$StartOverResponse = WaitForSpeech(10, "No", "Affirmative", "Okay", "Yeah", "Negative", "Maybe", "Yes" )
Goto(StartOverQuestion)
endif
SayWait("What is " + $FirstAdditionNumber + " plus " + $SecondAdditionNumber )
sleep(1000)
$AdditionResponse = WaitForSpeech(20, "0","1","2","3","4","5","6","7","8","9","10")
SayWait("You said" + $AdditionResponse)
if ($AdditionResponse == $AdditionAnswer)
SayWait("Good job! Yes " + $AdditionAnswer + " is the correct answer")
goto(Addition)
Else
SayWait("Sorry " + $AdditionResponse + " is not correct. please try again.")
sleep(1000)
goto(loop)
endif
# If MathResponse was subtraction.
:Subtraction
$FirstSubtractionNumber = GetRandomUnique(5,10)
$SecondSubtractionNumber = GetRandomUnique(0,5)
$SubtractionAnswer = $FirstSubtractionNumber - $SecondSubtractionNumber
:loop
$QuestionNumber = $QuestionNumber + 1
if ($QuestionNumber = 6)
SayWait("That was 5 " + $MathTypeResponse + "questions.")
SayWait("Would you like to start over again?")
$StartOverResponse = WaitForSpeech(20, "No", "Affirmative", "Okay", "Yeah", "Negative", "Maybe", "Yes" )
Goto(StartOverQuestion)
endif
SayWait("what is " + $FirstSubtractionNumber + " minus " + $SecondSubtractionNumber )
sleep(1000)
$SubtractionResponse = WaitForSpeech(20, "0","1","2","3","4","5","6","7","8","9","10")
SayWait("You said" + $SubtractionResponse)
if ($SubtractionResponse == $SubtractionAnswer )
SayWait("Good job! Yes " + $SubtractionAnswer + " is the correct answer")
Goto (Subtraction)
else
SayWait("Sorry " + $SubtractionResponse + " is not correct. please try again.")
sleep(1000)
goto(loop)
endif
# If MathResponse was multiplication.
:Multiplication
$FirstMultiplicationNumber = GetRandomUnique(1,5)
$SecondMultiplicationNumber = GetRandomUnique(0,5)
$MultiplicationAnswer = $FirstMultiplicationNumber * $SecondMultiplicationNumber
:loop
$QuestionNumber = $QuestionNumber + 1
if ($QuestionNumber = 6)
SayWait("That was 5 " + $MathTypeResponse + "questions.")
SayWait("Would you like to start over again?")
$StartOverResponse = WaitForSpeech(20, "No", "Affirmative", "Okay", "Yeah", "Negative", "Maybe", "Yes" )
Goto(StartOverQuestion)
endif
SayWait("what is " + $FirstMultiplicationNumber + " times " + $SecondMultiplicationNumber )
sleep(1000)
$MultiplicationResponse = WaitForSpeech(20, "0","1","2","3","4","5","6","7","8","9","10","12","15","16","20","25")
SayWait("You said" + $MultiplicationResponse)
if ($MultiplicationResponse == $MultiplicationAnswer)
SayWait("Good job! Yes " + $MultiplicationAnswer + " is the correct answer")
goto(Multiplication)
Else
SayWait("Sorry " + $MultiplicationResponse + " is not correct. please try again.")
sleep(1000)
goto(loop)
endif
# If MathResponse was division.
:Division
$FirstDivisionNumber = GetRandomUnique(2,6)
$SecondDivisionNumber = GetRandomUnique(1,2)
$DivisionAnswer = $FirstDivisionNumber / $SecondDivisionNumber
:loop
$QuestionNumber = $QuestionNumber + 1
if ($QuestionNumber = 6)
SayWait("That was 5 " + $MathTypeResponse + "questions.")
SayWait("Would you like to start over again?")
$StartOverResponse = WaitForSpeech(20, "No", "Affirmative", "Okay", "Yeah", "Negative", "Maybe", "Yes" )
Goto(StartOverQuestion)
endif
SayWait("what is " + $FirstDivisionNumber + " divided by " + $SecondDivisionNumber )
sleep(1000)
$DivisionResponse = WaitForSpeech(20, "0","1","2","3","4","5","6","7","8","9","10","12","15","16","20","25")
SayWait("You said" + $DivisionResponse)
if ($DivisionResponse == $DivisionAnswer)
SayWait("Good job! Yes " + $DivisionAnswer + " is the correct answer")
goto(Division)
Else
SayWait("Sorry " + $DivisionResponse + " is not correct. please try again.")
sleep(1000)
goto(loop)
endif
#Halt()
# Start over response
:StartOverQuestion
if ($StartOverResponse = "Yes" )
goto(Yes)
ELSEif ($StartOverResponse = "No" )
goto(No)
ELSEif ($StartOverResponse = "Affirmative" )
goto(Yes)
ELSEif ($StartOverResponse = "Okay" )
goto(Yes)
ELSEif ($StartOverResponse = "Yeah" )
goto(Yes)
ELSEif ($StartOverResponse = "Negative" )
goto(No)
ELSE
goto(StartTheSquence)
endif
Return()
Halt()
:Yes
Goto(StartTheSquence)
Halt()
:No
SayWait("I enjoyed doing math with you.")
SayWait("Maybe we can do it again soon.")
HALT()
So you told "division" but it went to the behaved as if it heard "addition"? There are not program errors, it just behaves differently?
On your Win7 machine, did you need to code in Speech Recognition setting $MathTypeResponse because I don't see where it would get set otherwise? Did you just copy the script from your Win7 machine or the enter project? I feel like your are missing something else for the project.
@HerrBall
The script has been fixed:
EDIT 1: Changed phrases and comparison to lowercase EDIT 2: Replaced == with = EDIT 3: Multiple loop tags e.g. :loop
@HerrBall,
EZ-Script help:
So the 1 Million dollar question: why it works on Windows 7 ?
1) I presume DJ's added the lowercase information to the documentation after finding out the behavior.
2) ARC uses the System.Speech.Recognition API (SAPI) when a sentence is recognized the SpeechRecognized event is fired with a specific arguments SpeechRecognizedEventArgs one of the properties is the Text recognized.
If you read carefully (between the lines) https://msdn.microsoft.com/en-us/library/system.speech.recognition.recognizedphrase.text(v=vs.110).aspx
So what is a normalized text ?
https://msdn.microsoft.com/en-us/library/system.speech.recognition.replacementtext(v=vs.110).aspx
So what this means ? The Speech engines makes adjustments to the recognized text and the result can be different or slight different e.g. (Lowercase)
I believe windows 7 and windows 10 handle the recognition differently.
Do you feel Lucky ?
I tried this script out, if you give a wrong answer in Subtraction, Multiplication or Division, then the rest of 5 questions are Addition questions. Is it suppose to do that?
fixed script or the original script ?
What you mean wrong answer in Subtraction, Multiplication, Division ? You can only get out saying the operation or timeout.
I ran the fixed script. I then selected Division questions and it said it would ask me 5 division questions. I gave the wrong answer to one of the questions (just to see what would happen) and the rest of the 5 questions were addition questions not division questions.
@Bob,
That is another bug! duplicate loop statements. I'll fix
@ptp
Thanks ... that did it! Another lesson learned ... Grateful for you time and help. By the way, your plugin for the cube is awesome ... fine work.
@ bhouston
No it is not supposed to do that. I have not finished the script yet. If a lot of the code is the same, I have a bad habit of coping and pasting it and then going back and making the proper changes. If that makes sense? The division part is going to give me some problems as I need for it to only ask questions that will come out in even numbers. This is a program for my grandsons (10 & 9), so it must be easy. What fun right?
I fixed the last errors (EDIT 3)
That's working great now, nice script. My grand children will enjoy it.
Try this version:
Antonn says Thanks to All for bringing this script back out.
He will use it during his School visit coming up. The kids will enjoy it.
Ron
are there any video on this?
@ptp
I believe there is a bug in your last script (#13). Try running addition and giving the wrong answer. Or is it just me?