speakAndAwait

suspend fun speakAndAwait(text: String, preset: SpeechPreset = config.defaultPreset): SpeechResult

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 */}
}
}

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

block

DSL block executed on a SpeechBuilder receiver.

See also