TextToSpeech

class TextToSpeech : Disposable

Facade for performing operations on TextToSpeechEngine.

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
fun TextToSpeech(ttsEngine: TextToSpeechEngine)

Creates an instance of TextToSpeech with the desired TextToSpeechEngine implementation.

Functions

Link copied to clipboard
fun addOnEngineReadyListener(listener: OnEngineReadyListener)

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
fun changeTextToSpeechEngine(ttsEngine: TextToSpeechEngine)

Substitutes the current TextToSpeechEngine with a different one. TextToSpeechEngine.dispose 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 dispose()
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
fun removeOnEngineReadyListener(listener: OnEngineReadyListener)

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

Link copied to clipboard
fun stopMessagePlayback()

Stops synthesizing the current AudioMessage.