desktopMain.nl.marc_apps.tts.TextToSpeech.kt Maven / Gradle / Ivy
package nl.marc_apps.tts
import androidx.compose.runtime.*
import nl.marc_apps.tts.experimental.ExperimentalDesktopTarget
@ExperimentalDesktopTarget
@Composable
actual fun rememberTextToSpeechOrNull(requestedEngine: TextToSpeechEngine): TextToSpeechInstance? {
var textToSpeech by remember { mutableStateOf(null) }
LaunchedEffect(Unit) {
textToSpeech = TextToSpeechFactory().createOrNull()
}
DisposableEffect(Unit) {
onDispose {
textToSpeech?.close()
textToSpeech = null
}
}
return textToSpeech
}