
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.Code:
# 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()
The script has been fixed:
Code:
EDIT 1: Changed phrases and comparison to lowercase
EDIT 2: Replaced == with =
EDIT 3: Multiple loop tags e.g. :loop
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 ?
What you mean wrong answer in Subtraction, Multiplication, Division ?
You can only get out saying the operation or timeout.
That is another bug! duplicate loop statements. I'll fix
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?
Try this version:
Code:
He will use it during his School visit coming up. The kids will enjoy it.
Ron
I believe there is a bug in your last script (#13).
Try running addition and giving the wrong answer.
Or is it just me?