Skip to first unread message

ck8

unread,
Dec 9, 2016, 1:39:21 PM12/9/16
to mitappinv...@googlegroups.com
Below are all my codes. (code 4 and code 5 are the same block, it's just too long to fit it in one picture.) I need help in three areas: 1) Even though the texttospeech feature would work perfectly, the speechrate would not change. What's the problem? 2) Would the speech pitch work as the same way as the speech rate? 3) Is there any way to create a button so that if I don't click on it, the text to speech will not say the translated sentence, but if I click on it, it will? 

Thanks a bunch, I really appreciate it. 

SteveJG

unread,
Dec 9, 2016, 5:12:33 PM12/9/16
to MIT App Inventor Forum
Hmmm.  Your codes did not post.
\
Here is a link for what you can do with the TextToSpeech using the AI2 control  http://ai2.appinventor.mit.edu/reference/components/media.html#TextToSpeech   

How are you attempting to change the SpeechRate?    From the above 
SpeechRate
Sets the SpeechRate for TextToSpeech. The values should be between 0 and 2 where lower values slow down the pitch and greater values accelerate it.


The DEFAULT is a SpeechRate=1   .  To slow the rate use = 0.8 perhaps or slower, to have the TTS speak more rapidly like perhaps =1.4

This works fine, without a block image no idea why your method to change the speed is not working for you.  It might be where you place the block in relation to other blocks...remember, commands work asynchronously .

Pitch
Sets the Pitch for TextToSpeech. The values should be between 0 and 2 where lower values lower the tone of synthesized voice and greater values raise it.

The Default is Pitch= 1.   try and use a value of 0.5 and the TTS will speak in a deeper tone.   A value of 1.5 will make the voice high pitched.

The pitch works the same way as the rate.

Your question " Is there any way to create a button so that if I don't click on it, the text to speech will not say the translated sentence, but if I click on it, it will? "   Well the answer is you can write code and use a boolean switch in the Click event handler and test for it in your mainline code    If myBooleanDoNotSpeak = true  then don't execute the TTS but if the boolean is False then talk all you want.  A simple solution is to use a CheckBox instead.   If checked is true then... if checked is false...

You really need to EXPERIMENT.   The answers to all your questions could be determined with simple experimentation.   Have you read Dr.Wolber's free book (   http://www.appinventor.org/book2  ) yet?   Do you know you can get self help using the Help menu  (to the right of the Build menu) on the AI2 Compiler.  Try the Library, users will be amazed at the free hints and code available there.

Regards,
Steve



ck8

unread,
Dec 9, 2016, 5:45:49 PM12/9/16
to MIT App Inventor Forum
Thanks for the answer. I think I can get the creating the button part, and sure I'll give that book a read. But for the Speech rate part, here's my entire code: 


code1.JPG
code2.JPG
code3.JPG
code4.JPG
code5.JPG

ck8

unread,
Dec 12, 2016, 1:59:28 PM12/12/16
to MIT App Inventor Forum
Bump.

Taifun

unread,
Dec 12, 2016, 6:50:09 PM12/12/16
to MIT App Inventor Forum
1) Even though the texttospeech feature would work perfectly, the speechrate would not change. What's the problem? 
probably because you set the speech rate to 1 after selecting a language?
and where do you set the pitch?

2) Would the speech pitch work as the same way as the speech rate? 
see the documentation and just try something...

 3) Is there any way to create a button so that if I don't click on it, the text to speech will not say the translated sentence, but if I click on it, it will? 
sure, just set a boolean variable after clicking that button and check the value of that variable before speaking the translated sentence

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Reply all
Reply to author
Forward
0 new messages