Speech recognizer - I want it to wait for an answer

I have a little math quiz and I display the questions from a list. When a question is displayed, I want the speech recognizer to wait until the person gives an answer, then check the answer.

In the first piece of code, it cycles through the questions and waits until something is typed into the answer box.

In the second piece of code, it cycles through the questions and but does not wait until you say an answer. It will put the answer in the box if you get lucky and say it at the right time.

In the third piece of code, I think it should wait until an answer is given, but it crashes the app.

I think the fact that you inserted the repeat while in the repeat 10 times is not good :confused:

May I ask why are you putting wait 1 second blocks everywhere ? What are they meant to do ?

Nice day :slight_smile:

I think you like I did have problem with Asynch Loops. Here is what you should do so you can optimize the response time of your app and make it less complicated so we can understand better where does the particular issue you’re talking about is from. Asynchronous Blocks within Loops

I put the waits and the button color changes in there so that I can visually follow where the code is going. It is for debugging and would not be in the final product.

Thanks for helping me out. I will check out the article.

If you need any help with these please tell me. I know it can be a bit confusing :slight_smile:
Nice day :slight_smile:

Are the little loops that the first guy does after his save sort of busy work loops that don’t do anything and give time for the save to finish? If so, would a wait 1 second work?

His loops just are functions repeating themselves, so they’ll wait for the answer to come back before executing again, this is meant to replace the repeat 10times :slight_smile:

Why do you actually repeat it 10 times ?

What about replacing the repeat while block by an if block ?

I have 10 questions in my quiz. I will eventually set it up so that it keeps asking questions until they stop the app.

An if block would only fire off 1 time very quickly, which wouldn’t wait for until the user speaks the answer.

Can you explain how I could use an if block to wait for an answer. I am reading the Asynchronous Blocks within Loops
thread to try to understand it.

Basically you just replace the repeat while by the if block and it will wait. If answer hing = say your answer it will do

And I suggest you add an else block for if the condition is not fulfilled :slight_smile:

I tried this below, and it waits for an answer ans displays it, but doesn’t do the 2nd repeat.

Thanks for your help, I am quitting for today.

For this you’ll need to use the article I sent.

I’ll make it quick here :

Create one variable called count and another one called counter

Counter is made to count the number of times you’ve executed the procedure, so you change counter by 1 each time the procedure is executed.

Count is the total amount of times you want to execute the function. Each time the procedure ends, you check with an if block if counter < or = (both of them together just don’t have a sign for that on the keyboard :slight_smile:). If it is true you execute the function again, otherwise, you stop the loop.

Hope it’s clear :slight_smile: Tell me if not !

This is instead of the repeat 10? Or a smaller loop after the speech recognizer?

Repeat 10

OK - I tried 2 way to do what you suggested, one with a repeat while and one with “count from 1 to 10 by 1”. both cycled through the list, but neither waited for an answer. If I take the wait 1 seconds out it all happens in an instant.

None of these represents what I told you :confused: I recommended using looping procedures as in the article I sent

Sorry - I am the worst! It didn’t look like a loop to me, but it is a loop after all! testing now.

No problem !