# Switches to control text to speech

**URL:** <https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051>\
**Category:** Questions about Thunkable X\
**Created:** [March 23, 2022, 9:38pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051 "2022-03-23T21:38:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 23, 2022, 9:38pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/1 "2022-03-23T21:38:01Z")

</div>

As I am making an app with different text to speech,

 ![languages](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/3/c3d49536bcc1da3e8eb76593a632b3aa6662ee2c.png)

I wonder if it is very complicated to incorporate some switches so that the user is the one who determines what he wants to hear.  
I have found this but I am not sure how to apply it in my case

 ![1ºswitch](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/b/1b98104d377325f548e258c06d28b7c4bd3d0d39.png)

Thanks

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 23, 2022, 9:50pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/2 "2022-03-23T21:50:47Z")

</div>

Unless I spend a lot of time, I’m not going to know what you’re using all of those blocks for. It helps if you explain the part you do understand so that others don’t have to figure all of that out.

So without spending that time, I can at least say that a switch has two possible values: true or false. You can use an if/else block to check for the value of the switch (the green `newValue` block) and do two different things based on it.

It would also help if you explain how you envision the switches working. If I’m using your app and I switch one (or more) switchI(es) on/off, what should happen?

---

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 23, 2022, 11:33pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/3 "2022-03-23T23:33:45Z")

</div>

@tatiang Hi, thanks.  
In this case, on this page, I am reviewing proverbs and expressions,

 ![switch3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/0/e02125eef3e2f3a4ac068435927c50256b94ead4.png)

although there are another dozen similar pages with different vocabularies. It is designed to be used by English or Spanish speakers interchangeably, therefore, when they are pronounced in one of the languages, the text to speech flag is activated, so that’s why I use all these blocks

 ![Captura4](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/9/092ef4acf6f2ce7ebb806e90827965d21bd8e7ee.png)

and I have put the switches so that the corresponding pronunciation can be activated or deactivated.

---

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 23, 2022, 11:53pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/4 "2022-03-23T23:53:01Z")

</div>

@tatiang  
As you can see here,

 ![switch5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/9/39d2acf529ce75348a07d69053f5ce17fd85881c.png)

the idea is that it pronounces first in British, then in American, and finally in Spanish. Doing the test with the British switch, the only thing I get if I move it when it is speaking with its pronunciation, is that it stops and pronounces the following ones (American and Spanish), but in no position does it prevent it from starting to pronounce, which is what what I try to get. In addition, in the following word, it is necessary to switch it again so that it does the same thing but in the other (active - inactive) position.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 24, 2022, 5:13am UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/5 "2022-03-24T05:13:52Z")

</div>

The green `newValue` block is either true or false. You are checking to see if the value of the switch equals the new value. It’s always going to equal the new value so that will always evaluate as true and stop the Text to Speech. Typically, you’d check to see if newValue is true or false, not if it’s equal to itself.

If you only want the text to speech to run when the switch is true for each language, just check for the value of the switch. But you’ll need to store the newValue in a variable for each switch. That way, you can check that the value of the switch outside of the “on Value Change” event block (e.g. within the SpeakUK, SpeakUSA, and Speak Spanish functions).

---

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 24, 2022, 12:22pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/6 "2022-03-24T12:22:37Z")

</div>

@tatiang  
Yes, I just only want the text to speech to run when the switch is true for each language, and I’m trying to check for the value of the switch, and trying to store the newValue in a variable for each switch… and I’m making a lot of combinations, but of course I’m doing many things wrong, because any of them work as I want.

 ![switch mal](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/c/bcff8a25736659482ad34229bc4d51b02efc7087.png)

So how do I do what you’re telling me to do?  
Thanks

---

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 24, 2022, 4:13pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/7 "2022-03-24T16:13:41Z")

</div>

@tatiang  
I’ve done this

 ![switch funciona sin variables](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/1/51071714920bb831e40117492bc2589ffc607ee8.png)

and it’s working fine… but with no variables. Must I use them? how, please. Thank you

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 24, 2022, 4:32pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/8 "2022-03-24T16:32:49Z")

</div>

I think the way you’ve done it is good. No, you don’t have to use variables.

---

<div class="post-metadata">

**Author:** ![similar2similar](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@similar2similar](https://community.thunkable.com/u/similar2similar)\
**Post date:** [March 24, 2022, 4:47pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/9 "2022-03-24T16:47:21Z")

</div>

thanks for your advice

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [June 22, 2022, 4:47pm UTC](https://community.thunkable.com/t/switches-to-control-text-to-speech/1799051/10 "2022-06-22T16:47:44Z")

</div>

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