App doesn't wait for Text to speech to finish before moving on to the next block

I am building an app that can read data from spreedsheets.

it reads the data from column 1, repeat it the number of time specified in column 2, then read the word at column 3 and repeat the row the number of time specified in column4, then moves to the next row.

here are my blocks

on execution the app only reads the word in the very last cell. I am using a label to show if the app got all the list items and it shows that the app is doing everything as it should, this suggests that the app simple doesn’t wait for the TTS(text to speech) block to finish before moving to the next block.

I tried using the after speaking block in the TTS, but since it can’t be attached to the loop it’s too hard to get the app to function properly with it.

trying to pause with a timer like this doesn’t work, and it won’t work any way because each cell has different duration of audio
blocks (4)

Howdy, please use this block correctly

image

you need to also show the block for when.clock1.timer block since you’re only activating the clock after a speech finishes, and you seems to be doing all the speech thing when web got text block which won’t wait for a speech to finish.

2 Likes

The reason for this is because of how AppInventor is designed.

Procedures never interrupt or terminate a handler, as explained in this document (Credit: @Taifun). This means that unless your procedure is really fast and takes extremely less time, such as setting the text of a label, the program will not wait for you to finish things up.

I don’t think I understood what you are trying to accomplish… But try this…
Create a dummy label and make it not visible and set dummy label.text to whatever you want TTS to readout… Keep setting the value for dummy label and use text-to-speech.Speak function at last and set the message to dummy label text.

I think david had the right solution, I tried building a screen reader repurposing codes from an already existing text to speech AI and had a timing issue with the AI. The Clock1 double function to “always fires” might be an issue… Try using codes from an open source project :+1:t2: