Switches to control text to speech

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

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

Thanks

1 Like

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?

1 Like

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

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

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

@tatiang
As you can see here,

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.

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).

1 Like

@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.

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

@tatiang
I’ve done this

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

1 Like

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

thanks for your advice

1 Like

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