SpeechRecognizer and numbers

Hello.
When you dictate a figure to "SpeechRecognizer", for example: 45, it returns "forty-five", but calculation operations cannot be performed with text strings. Years ago, SpeechRecognizer did return the dictated number in numerical format "45". The question is how to convert the text string "forty-five" to "45" to do mathematical calculations.
Thank you.

There is a powerful text block that does replace with dictionary.

Forty -> 4
Five -> 5
...

Remove the spaces afterwards.

BTW, this is a hard problem.

There's a hundred and one ways to fail.
1001?
101?

On my Android 13 that is still the case (saying a number results in a numeral).

What you are experiencing may be an issue of pronunciation. Try saying forty-five rapidly and you may get 45 recognized.

what happens with the SR on my Android however is when I say a single digit numeral, the SR elicits three or five or seven instead of 3 5 or 7. However if I say digit three, the SR returns 3 ! Prefacing with the word digit evidently forces a digit. You might try prefacing with number or numeral 45 or digits 45 and see what happens.

Whatever you implement should include feedback and error checks

Did you really want to buy three million donuts?

1 Like