#### Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

## 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?

ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!

Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#1
You can do something like this

`Code:if(\$response="one")\$answer=1elseif(\$response="two")\$answer=2elseif(\$response="three")\$answer=3elseif(\$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
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