MBS Plugin Advent calendar: 4 - Speech
Door 4 - Speech
Fact of the day |
---|
A voice output can not only make reading easier, but also creates freedom for people with physical disabilities. |
In this door, you have the opportunity to ensure that your solution never has to be at a loss for words again. Today we are teaching your application to speak, because MBS offers speech output for Windows, Mac and iOS with the Component Speech.
If we want to output a text, we can use the Speech.Speak function. We first pass the text to be read out in the parameters. That's enough for now. Optionally, we can also choose from various speakers. You can find out which speakers are available with the Speech.AvailableVoices function. This function provides you with a list of all speakers. You can specify in this function whether you want the speaker names or the ID for the speaker to be displayed in this list.
If you want to use a specific speaker in the Speech.Speak function, you need to enter the ID. In the Speech.Speak function, you can also set whether or not your script should be continued while the speech output is running. Stopping a script also makes sense if you call the Speech.Speak function in the script several times so that the text that follows is also read out and is not lost because another text is being read out. You can also set the volume and playback rate in the function. The volume is between 0.0 (silent) and 1.0 (full). The playback speed ranges between 0.0 (silent) and 2.0 (double speed). The default value for both settings is 1.0.
Set Variable [ $r ; Value: MBS( "Speech.Speak"; DoorFour::Text ; DoorFour::Speaker ; 1 ; 1; .7 ) ]
Of course, there are also functions with which you can stop the speech output. With Speech.Stop, you can stop the current output at the next possible time. The text is then completely interrupted and cannot be continued again. So if you only want to pause the output in order to continue it later, you need the Speech.Pause function. To resume the output, you need the Speech.Resume function. You should pay attention to the Stop and Pause functions: If a script has a Wait instruction from the Speech.Speak function, then of course we remain in the script and it cannot be stopped or the speech output terminated prematurely.
With just a few functions, you can integrate a very useful functionality into your solution. I wish you a lot of fun with it.
3 | 👈 4 of 24 👉 | 5 |