speak And Await
Suspends until the TTS engine finishes speaking text.
The coroutine is cancelled-safe: cancelling the job will stop the ongoing speech and clean up the internal callback.
lifecycleScope.launch {
when (val result = tts.speakAndAwait("Bonjour")) {
is SpeechResult.Success -> { /* done */}
is SpeechResult.Error -> { /* handle error */}
SpeechResult.NotReady -> { /* engine not ready */}
}
}Content copied to clipboard
Return
SpeechResult once the utterance completes or fails.
Parameters
text
The French text to speak.
preset
Prosody preset to apply. Defaults to Config.defaultPreset.
suspend fun speakAndAwait(queueMode: Int = TextToSpeech.QUEUE_FLUSH, block: SpeechBuilder.() -> Unit): SpeechResult
Suspends until the TTS engine finishes speaking the DSL content.
Combines the SpeechBuilder DSL with coroutine suspension for sequential speech flows.
Return
SpeechResult once the utterance completes or fails.
Parameters
queue Mode
TextToSpeech.QUEUE_FLUSH (default) or TextToSpeech.QUEUE_ADD.
block
DSL block executed on a SpeechBuilder receiver.