speak

fun speak(text: String, preset: SpeechPreset = config.defaultPreset, queueMode: Int = TextToSpeech.QUEUE_FLUSH): SpeechResult

Speaks text aloud using the given preset.

If Config.autoChunkLongText is enabled and the generated SSML exceeds ~4 000 characters, the text is automatically split at natural boundaries (paragraphs, sentences, clauses).

Return

SpeechResult.Success if the text was dispatched, SpeechResult.NotReady if the engine is not initialized, or SpeechResult.Error on failure.

Parameters

text

The French text to speak.

preset

Prosody preset to apply (rate, pitch, volume). Defaults to Config.defaultPreset.

queueMode

TextToSpeech.QUEUE_FLUSH (default) to interrupt ongoing speech, or TextToSpeech.QUEUE_ADD to append to the queue.


fun speak(queueMode: Int = TextToSpeech.QUEUE_FLUSH, block: SpeechBuilder.() -> Unit): SpeechResult

Speaks content built with the Kotlin DSL.

tts.speak {
sentence { text("Première phrase.") }
pause(300)
emphasis("strong") { text("Important !") }
}

Return

SpeechResult indicating success or failure.

Parameters

block

DSL block executed on a SpeechBuilder receiver.

See also