Speech Recognizer Fills Extra TextBoxes or Repeats Values Unexpectedly

I'm using the SpeechRecognizer component to input two-digit numbers into a set of 15 TextBoxes. The user speaks digits (e.g., “4 5 4 6”), which I clean, pair into numbers like ["45", "46"], and then insert into the next available TextBoxes.

However, I’m facing an issue:

  • Sometimes, even when the twoDigitNumber list is just ["45", "46"], it fills more than two TextBoxes.
  • Occasionally, it even repeats the same number in multiple boxes.
  • I also noticed it sometimes overwrites filled ones.

I’m maintaining a global currentIndex to track which TextBox to fill next. But I suspect the recognizer returns inconsistent results, or my currentIndex isn't syncing correctly.

What I want:

  • A reliable way to fill only the next empty TextBoxes, without overwriting existing data.
  • Ensure that each number from the list is inserted only once, and that extra boxes are not filled.
    here is my blocks
    blocks(112)

I find it simpler to skip indices, and instead use temporary lists, adding to them or depleting them as needed.

For your immediate problem, apply Do It to see what arrived in your list of numbers.

If that doesn't help, export and upload your aia file for us to play with.

You need a global list to accumulate the spoken digits, one digit per item.

You also need a global list of components to receive the pairs of digits removed from the first list, two at a time.

You remove two items from the front of a list by removing item 1 twice, because AI2 lists are linked lists

Every speech event, add the incoming digits to the accumulated digits list. If it's got two or more items, take items 1 and 2 to fill the next available component. Then remove the filled component from its list and remove the two digits from their list .

1 Like

How do I use Mit App Inventor now

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

What you need to do is assume things will not always work (inconsistent results) - because that is always the case with speech recognition.

You definitely shouldn't have all of that code in the recogniser block, only use that block to collect the next spoken value. You need a procedure or procedures to process what the recogniser has captured and communicate with the User when recognition has failed and needs to be repeated - you also need to temporarily switch the recogniser off (Only allow User speech when prompted).

Start thinking of words to watch for in the input stream that request erasure of the last entry, like "oops", "undo", "erase", "back", "fudge",...

Here's my attempt, using my technique:


speech_input_two_digits_series.aia (4.5 KB)

I notice the Google speech recognizer on my phone stops soliciting speech early, even though I ran the speech component in Legacy mode.

Speech input is in deed tricky.

1 Like

My technique could be improved by checking for unfilled components after speech processing, and asking for more speech input if needed.

That would deal with premature speech termination.

1 Like

blocks(113)
i just used this then its working perfectly.

Show us what works, so we can use it to help others?

Initially, when I spoke numbers like '45 46', multiple textboxes were being filled unexpectedly. However, now it correctly fills only two textboxes. Similarly, saying '39 58' fills the next two boxes as intended.

1 Like