Voice Calculator Not Recognizing Numbers Well Starting from 1000+

Hi, I created a voice calculator project in MIT App Inventor that supports basic operations (+, -, *, /). It works fine for numbers below 1,000, but once I try numbers starting from 1,000 and above, the recognition becomes inconsistent.

Sometimes it mishears the number or operator, and other times it fails to process the input entirely. I checked the recognized speech list after I speak, and while it's capturing something, it often doesn't register the full number correctly.

For example, when I say "ten thousand five hundred," it might only catch "ten" or "five hundred," or jumble the result. The biggest issue happens when I try to add two 5-digit numbers (like "12345 plus 67890") — the voice recognition simply cannot understand the full input or splits it incorrectly.

If there’s a known limitation or a workaround to improve recognition for larger numbers, I’d really appreciate your help!

Thanks in advance!

Does your app work offline or need internet ?

This is a combination of two problems:

  • Premature evaluation of incoming speech

  • How to decide to respond to spoken numbers, digits or words?

The speech recognition event has parameters that are supposed to help with the first problem. Read the component help doc.

It might be better to address the first problem before the second.

oflline

i check if its digit all the time but about the Premature evaluation of incoming speech
how can i fix this issue

The AI2 speech recognizer has tools to deal with this:

https://ai2.appinventor.mit.edu/reference/components/media.html#SpeechRecognizer

SpeechRecognizer icon

Use a SpeechRecognizer component to listen to the user speaking and convert the spoken sound into text using the device’s speech recognition feature.

Properties

Language
Suggests the language to use for recognizing speech. An empty string (the default) will use the system’s default language.

Language is specified using a language tag with an optional region suffix, such as en or es-MX. The set of supported languages will vary by device.

Result
Returns the last text produced by the recognizer.
UseLegacy
If true, a separate dialog is used to recognize speech (the default). If false, speech is recognized in the background and updates are received as it recognizes words. AfterGettingText may get several calls with partial set to true. Once sufficient time has elapsed since the last utterance, or StopListening is called, the last string will be returned with partial set to false to indicate that it is the final recognized string and no more data will be provided until recognition is again started. See AfterGettingText for more details on partial speech recognition.

Events

AfterGettingText(result,partial)
Simple event to raise after the SpeechRecognizer has recognized speech. If UseLegacy is true, then this event will only happen once at the very end of the recognition. If UseLegacy is false, then this event will run multiple times as the SpeechRecognizer incrementally recognizes speech. In this case, partial will be true until the recognized speech has been finalized (e.g., the user has stopped speaking), in which case partial will be false.
BeforeGettingText()
Simple event to raise when the SpeechRecognizer is invoked but before its activity is started.

Methods

GetText()
Asks the user to speak, and converts the speech to text. Signals the AfterGettingText event when the result is available.
Stop()
Function used to forcefully stop listening speech in cases where SpeechRecognizer cannot stop automatically. This function works only when the UseLegacy property is set to false.

So show us how you are using

  • the UseLegacy flag
  • the partial return?
  • non-English environment

If totally lost and unable to read docs, export and upload your aia file.

What you can do with App Inventor to improve recognition is limited compared to using Android Studio etc. with its extensive libraries. However, there are small things you can do to improve recognition.

Here are some suggestions from a Speech Recognizer tutorial
How to avoid mistakes

  • Experiment with the various Parrot option choices until you find something the fits your speeking/dictation style. - A secret to making a Speech Recognizer work is to speak in a strong, steady, clear voice. Even then, the Parrot recognizer WILL make mistakes.
  • I show one way to delete words Parrot misspeaks…type the word that must be eliminated, press Delete or use the Delete Last of to delete the last spoken text.
  • There are a few grayed out Blocks of code at the top of the AfterGettingText event handler. Restore the Blocks and these or similar blocks can be used when the SpeechRecognizer is stubborn. Yes, sometimes it refuses to provide the word you speak. For example, if you do not want to record 2 when you say 2 but to print out two or to respond with for when it thinks you say four, you make it obey when it mis-understands your pronunciation.

If you haven't taken the tutorial

you might find some hints by doing this tutorial.

What you can do with App Inventor to improve recognition is limited compared to using Android Studio etc. as I said. There are small things you can do to improve recognition.

The advice is basically to learn to talk to your recognizer. :slightly_smiling_face: Speak in a steady, clear voice without background noise. That really does help.

Users who first language is English is their first language do better than those for who it is a second language and have even a slight accent.

Learn to write code to ameliorate some of the 'errors' you get while speaking

When your app if frequently making mistakes with voice recognition, provide a TextBox to provide input in text. :slightly_smiling_face:


this is my block code

Unfortunately, I can't edit a picture.
(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

.

Note that App Inventor does not implement its own speech recognition engine, we simply call the platform-defined speech recognition API. On iOS this is always Siri, on Android it is typically Google but other manufacturers (e.g., Samsung) may provide their own speech recognition implementations. App Inventor makes no attempt to normalize the output, so depending on what phone you have you may get slightly different results for the same spoken input.

(added to FAQ)

VoiceCalculator.aia (855.4 KB)
her is the file

You are so lucky.

I could not believe modern phone speech recognition could turn phrases like "one thousand twenty four" into 1,024.

Unfortunately, AI2 math blocks do not recognize commas in numbers.

The answer is to filter them out.

(draggable)

I hope you are not in France. They use decimal points for commas, and commas for decimal points.