# Speech recognizer - I want it to wait for an answer

**URL:** <https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986>\
**Category:** Questions about Thunkable X\
**Tags:** speechrecognizer\
**Created:** [October 8, 2018, 9:30pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986 "2018-10-08T21:30:18Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 8, 2018, 9:30pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/1 "2018-10-08T21:30:18Z")

</div>

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.

 ![thunk%20math%20game%201](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/f/2f1b9c8be42a710adc140e73b37b97494e8f4be5.png)

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.

 ![thunk%20math%20game%202](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/844491d3cdf3f1fffee0d9f9314ce791fc59273e.png)

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

 ![thunk%20math%20game%203](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/d/cd6ba06a7f3144d998422d9c71709b82931110a9.png)

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 9:39pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/2 "2018-10-08T21:39:25Z")

</div>

I think the fact that you inserted the `repeat while` in the `repeat 10 times` is not good 😕

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

Nice day 🙂

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](http://community.thunkable.com/t/asynchronous-blocks-within-loops/33524)

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 8, 2018, 9:43pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/3 "2018-10-08T21:43:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 9:50pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/4 "2018-10-08T21:50:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 8, 2018, 9:58pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/5 "2018-10-08T21:58:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 9:59pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/6 "2018-10-08T21:59:55Z")

</div>

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 🙂

Why do you actually repeat it 10 times ?

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 10:02pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/7 "2018-10-08T22:02:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 8, 2018, 10:14pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/8 "2018-10-08T22:14:01Z")

</div>

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](http://community.thunkable.com/t/asynchronous-blocks-within-loops/33524)  
thread to try to understand it.

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 10:18pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/9 "2018-10-08T22:18:17Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 8, 2018, 10:29pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/10 "2018-10-08T22:29:33Z")

</div>

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.

 ![thunk%20math%20game%204](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c560c08300b9756c68b006ddf631bb45a0e4dd7b.png)

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 8, 2018, 10:36pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/11 "2018-10-08T22:36:14Z")

</div>

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 🙂). If it is `true` you execute the function again, otherwise, you `stop the loop`.

Hope it’s clear 🙂 Tell me if not !

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 9, 2018, 1:03pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/12 "2018-10-09T13:03:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 9, 2018, 1:12pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/13 "2018-10-09T13:12:36Z")

</div>

Repeat 10

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 9, 2018, 4:39pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/14 "2018-10-09T16:39:48Z")

</div>

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.

 ![thunk%20math%20game%205](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/4/04acd1c11ca68a74172d91dd6f16ef863f9d3702.png) ![thunk%20math%20game%206](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/9/d9c4f60fec0c4212b781bdd7cc60768b330bc405.png)

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 9, 2018, 4:45pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/15 "2018-10-09T16:45:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lin](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@Lin](https://community.thunkable.com/u/Lin)\
**Post date:** [October 9, 2018, 5:16pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/16 "2018-10-09T17:16:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AcrobatEpee](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/acrobatepee/32/26336_2.png) [@AcrobatEpee](https://community.thunkable.com/u/AcrobatEpee)\
**Post date:** [October 9, 2018, 5:19pm UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/17 "2018-10-09T17:19:35Z")

</div>

No problem !

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:55am UTC](https://community.thunkable.com/t/speech-recognizer-i-want-it-to-wait-for-an-answer/50986/18 "2024-11-08T11:55:12Z")

</div>


