Converting Text into a Number

I’m currently working with the Speech Recognizer. What I want to achieve is, that when I say a number, the programm should also use this number. But it looks like instead of an integer, the speech recognizer delivers a string. I was wondering if there is a way to convert the string, from the result of the speech recognizer, to an integer.

Test the speech recogniser output with the isNumber block. AI2 will handle numbers in text blocks and number blocks as numbers e.g.

image

This is my function, where I activate the speech recognizer. The result is then set to global time value.
image

After I got the text I check if it’s a number.

image

The app always tells me, that my voice-input is not a number

grafik

Have you tried passing the speech output through a long lookup-in-pairs list block to translate English number phrases to numbers?

one,1
won,1
too,2
two,2
three,3

the SpeechRecognizer component works asynchronously... which means, you get the result back in the AfterGettingText event... you programmed your blocks as if the result comes back immediately, which does not make sense...

Unbenannt

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Ah, I see what I did wrong now. Thanks for your reply. The app works now as intended

Btw, exactly what I showed in my example above.