By default when you add the component to a skin you just need to add it as a child element to any text box to speak its contents.
For a video on how to use it please see this link: Text to Speech
The first mod you may want to do is to stop it talking, as an example when you change nodes it will continue to talk.
To do this automatically you can add a second action to the component.
Source: Before Node Change
Action: Go to URL
The the URL will be:
Code: Select all
javascript:
if (window.speechSynthesis) {
window.speechSynthesis.cancel();
}
You can even add this to a Stop button using, Mouse Click, Go to URL and use the code above.
Ther are also the options to add Pause and Resume buttons.
Using a Mouse Click, Go top URL action use the following code.
Pause button URL code:
Code: Select all
javascript:
if (window.speechSynthesis) {
window.speechSynthesis.pause();
}
Code: Select all
javascript:
if (window.speechSynthesis) {
window.speechSynthesis.resume();
}
Extending the functions
The default code ends with this code:
Code: Select all
utter.text = text;
synt.speak(utter);
window.ggLastTTSElement=this;
As an example I have added four new attobutes to the code, please see below:
Code: Select all
utter.text = text;
utter.lang = 'en';
utter.rate = 1;
utter.pitch = 1;
utter.volume = 1;
synt.speak(utter);
window.ggLastTTSElement=this;
You can also force regional accents of the same language as well as different languages.
For example:
utter.lang = 'en';
utter.lang = 'en-UK'; English British accent
utter.lang = 'en-US'; English Ameriacan accent
So all "en" but three different accents.
Please note, this works well for Chrome and Firefox, but Safari on the Mac is part of the OS and not a separate application. This means it will use the OS voice settings.
If you go to Preferences => Accessibility => Speech you can add more languages and regional accents to macOS.
Please see ISO Language Code Table
The next attribute is utter.rate = 1;
This is the speed of the speech, 1 is the default, so 0.8 will be slower and 1.2 will be faster.
Then there is utter.pitch = 1;
Setting the number higher will increase the pitch of the voice, as an example 0.5 will be lower and 1.5 will be much higher.
Finally utter.volume = 1;
The default is 1 which seems to be the systems volume level, however, you can set lower volumes, so 0.5 is half as loud as your system volume.
Regards,