Looping a list of sentences to the TextToSpeech control

I am trying to send a large amount of texts to the TextToSpeech control and can't figure out why only the last sentence is being spoken from a list i made a List of sentences by splitting the text at the period . I'm using a for each loop on the list and sending the item to the texttospeech message.


The above block was a debug test to see if I'm looping correctly and I am.

It works great when sending each sentence with corosponding index to a textbox.

However, when I use the TextToSpeech Control, Only the last sentence is spoken. Why.?
I tried sending just the text from a textbox one at a time and still, just the last sentence was spoken.

Here is the latest I have.

In the above blocks, here are the results . i get the index and sentence perfectly but still only the last sentece is spoken throgh the TextToSpeech control. this is just a portion of the output. there was 148 entries total.

Any ideas would be appreciated. thanks.

Do I need to use the BeforeSpeaking or AfterSpeaking Controls to try and slow the process down or something?

1 Like

yes

TextToSpeech1 (1).aia (7.7 KB)

Here is the latest Blocks I have.
I Tried to put the item in the for each loop into another variable and still received the same results.

you need the AfterSpeaking to slow down to wait previous speak to finish, then next.

Add a global list variable, initially empty.

Fill it with the sentences you want spoken. (Split at '.')

Speak the first sentence (item 1)

When the event fires signalling end of speech, remove item 1, check if list is not empty, then speak the new item 1.

No loops.

using a timer to read one item at a time or automatically using a Clock and a Switch

CounterTTS_2.aia (4.5 KB) might work for you Nicholas. :thinking:

I take it that the condition to check if list is empty is in the after speaking block and is where i would then call the text to speak block with the index 1 of the list of sentences.

Of course, before i do the above i would remove the index 1 of the list then proceed of empty.

This is kind of recursive. Yes?

I can't wait to try this

Here's a cleaned up and tested version.

It's not recursion, just events and lists.

TextToSpeech11 (1).aia (8.1 KB)

I added the global START constant to prevent exposure to typoes.

Wow, This works perfectly
I have a workable module i can modify.
I like that it loops until i stop it.
This is very helpful , thanks.

I appreciate your input.
MIT App Inventor Community Rocks!

Here is my final version . I hope this helps anyone with this interest

TextToSpeech12.aia (9.0 KB)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.