Welcome to Synthiam!

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

Get Started
Asked — Edited

Convert A String Into A Numeric Value

Hello Everyone,

I'm writing a script that will allow JD to give a short & simple math quiz to 6th grade special education students (my wife is a special ed teacher).

A challenge I have run into, is with converting the spoken text into a numeric value. For example:

Code:


$response = WaitForSpeech(30, "4", "3")


Is not detecting when 4 or 3 is spoken, however when I use:

Code:


$response = WaitForSpeech(30, "Four", "Three")


The response is detected and the value is stored as a string, but I can't do any math with it. I would like to actually perform calculations based on numbers provided by the student.

Code:


$answer = $response + 3


Any thoughts on how I can approach this differently?

#1  
You can do something like this

Code:


if($response="one")
$answer=1
elseif($response="two")
$answer=2
elseif($response="three")
$answer=3
elseif($response="four")
$answer=4
#etc....
endif

$answer=$answer+3
#2  
LOL - Obviously. One of thoes Hommer Simpson moments :-) . Thanks @Richard
#3  
Though, I like where you were taking this. It would be nice if your setup would work.
#4  
@Technopro Thanks, I have a few goals for this 1st classroom appearance.

Dance to a song:
Provide a mobile button + voice command that will trigger a sequence of frames and audio file.

Play peek-a-boo:
Use the facial recognition to detect a student face, the game will consist of the student hiding his/her face then JD will say where did you go. When the student face appears, JD will say hey there you are.

Give a math quiz:
I am coding in math problems that JD can give to students. JD will

1. begin by saying the problem what is the sum of 4 and 4,
2. begin listening for the answer spoken by the student.
3. evaluate the answer provided by the student and compare against the stored answer
4. Reply to student:
Correct answer = flash LEDs and cheer
Incorrect answer = flash LEDs and buzz incorrectly


Take a math quiz:
I would like the students to give JD a math quiz, he will

1. begin listening for simple math question spoken by the student. (4+4)
2. detect the numbers and operation (only +, -, *, / options allowed)
3. evaluate
4. say the correct answer to the student

Basic Controls:
Walk Forward
Walk Backward
Move head Vertical & Horizontal

I will post the video when completed.