texttospeech.speak()


Type Function

Return value none

See also texttospeech.*


Overview

Generates and plays the speech. This process is not instant and it will take some time before you actually hear the sound.

Syntax

texttospeech.speak(text, [params])

text required

String. The text to be spoken by a speech engine.

params optional

Table. Contains parameters for the call — see the next section for details.

Parameter Reference

The params table includes parameters for the call.

language optional

String. Set the language to be used, values can be 'ru-RU', 'fr-FR' or other. Default is 'en-US'. See texttospeech.getLanguagesAndVoices() for the list of available languages.

voice optional

String. Set the voice to be used. Default value is specific to the platform and the engine. See texttospeech.getLanguagesAndVoices() for the list of available voices.

pitch optional

Float. Set the pitch of the voice, value from 0.5 to 2.0. Default is 1.0.

rate optional

Float. Set the speech rate (speed), value from 0.5 to 2.0, default is 1.0. On iOS, tvOS and macOS limits are not known.

volume optional

Float. Set the volume of the speech, value from 0.0 to 1.0. Default is 1.0.

id optional

String. Speech identifier. If supplied, it will be passed to the corresponding listeners. Default value is a random numeric string.

filename optional ~(Android, macOS)~

String. If supplied, the generated speech will be written into a file instead of being played. WAV on Android, AIFF on macOS.

baseDir optional ~(Android, macOS)~

Constant. The base directory for the filename. Default is system.TemporaryDirectory.

onStart optional

Listener. Listener which receives the onStart event, indicating that the speech has been started.

onProgress optional

Listener. Listener which receives the onProgress event multiple times during the speech.

onComplete optional

Listener. Listener which receives the onComplete event after the speech has ended.

onPause optional ~(not Android)~

Listener. Listener which receives the onPause event when the speech has been paused.

onContinue optional ~(not Android)~

Listener. Listener which receives the onContinue event when the speech has been resumed.