TextToSpeech

Facade for performing operations on TextToSpeechEngine.

Important: This is a Public Preview API. It may be changed or removed at any time.

Constructors

Link copied to clipboard
fun TextToSpeech(context: Context, language: Locale = Locale.US)

Creates an instance of TextToSpeech with the default TextToSpeechEngine which is based on Android's TextToSpeech.

Link copied to clipboard

Creates an instance of TextToSpeech with the desired TextToSpeechEngine implementation.

Functions

Link copied to clipboard

Sets a listener to report on the readiness of the TextToSpeechEngine.

Link copied to clipboard
fun changeLanguage(language: Locale)

Changes the language which will be used to synthesize audio messages.

Link copied to clipboard

Substitutes the current TextToSpeechEngine with a different one. TextToSpeechEngine.close is called on TextToSpeechEngine which is being replaced.

Link copied to clipboard
fun clearQueue(stopCurrent: Boolean)

Clears all messages from the queue.

Link copied to clipboard
open override fun close()
Link copied to clipboard

Returns current language used to synthesize audio messages.

Link copied to clipboard

Checks if the specified language as represented by the Locale is available.

Link copied to clipboard
fun playAudioMessage(audioMessage: AudioMessage, config: MessageConfig, playbackListener: MessagePlaybackListener): Cancellable

Synthesizes an audio message. Message queuing depends on MessageConfig.priority. If the message currently being synthesized has priority equal or higher to the audioMessage, the new message will be added to the queue (taking the priorities of queued messages into account). If the message currently being synthesized has a lower priority, it will be interrupted and audioMessage will be processed right away.

Link copied to clipboard
fun playTaggedMessage(taggedMessage: TaggedMessage, config: MessageConfig, playbackListener: MessagePlaybackListener): Cancellable

Synthesizes a tagged message. Parsing to a supported message format is done in the underlying TextToSpeechEngine. Message queuing depends on MessageConfig.priority. If the message currently being synthesized has priority equal or higher to the taggedMessage, the new message will be added to the queue (taking the priorities of queued messages into account). If the message currently being synthesized has a lower priority, it will be interrupted and taggedMessage will be processed right away.

Link copied to clipboard

Removes the listener that reports on the readiness of the TextToSpeechEngine.

Link copied to clipboard

Stops synthesizing the current AudioMessage.