TextToSpeech

Last Updated On 2021-07-16

Version 5MinSDK 7Tutorial Video

The TestToSpeech component speaks a given text aloud. You can set the pitch and the rate of speech.

You can also set a language by supplying a language code. This changes the pronunciation of words, not the actual language spoken. For example, setting the language to French and speaking English text will sound like someone speaking English (en) with a French accent.

You can also specify a country by supplying a country code. This can affect the pronunciation. For example, British English (GBR) will sound different from US English (USA). Not every country code will affect every language.

The languages and countries available depend on the particular device, and can be listed with the AvailableLanguages and AvailableCountries properties.


Properties

You can set the below properties in the UI part of the builder.

  • Country - it's a countries value which is set to blank by default.
  • Language - it's a languages value which is set to blank by default.
  • Pitch - it's a float value which is set to 1.0 by default.
  • SpeechRate - it's a float value which is set to 1.0 by default.

Block Properties

You can set the below blocks properties in the blocks section of the builder.

AvailableCountries

List of the country codes available on this device for use with TextToSpeech. Check the Android developer documentation under supported languages to find the meanings of these abbreviations.


AvailableLanguages

List of the languages available on this device for use with TextToSpeech. Check the Android developer documentation under supported languages to find the meanings of these abbreviations.


Country

Country code to use for speech generation. This can affect the pronounciation. For example, British English (GBR) will sound different from US English (USA). Not every country code will affect every language.


Language

Sets the language for TextToSpeech. This changes the way that words are pronounced, not the actual language that is spoken. For example setting the language to and speaking English text with sound like someone speaking English with a Frernch accent.


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.


Result

Returns `true


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.



Methods

You can set the below method blocks in the blocks section of the builder.

Speak

Speaks the given message.


Events

You can set the below event blocks in the blocks section of the builder.

AfterSpeaking

Event to raise after the message is spoken. The result will be true if the message is spoken successfully, otherwise it will be false.

BeforeSpeaking

Event to raise when Speak is invoked, before the message is spoken.