Fix crash in Android tts engine demo. (#2029)

This commit is contained in:
Fangjun Kuang
2025-03-20 10:41:52 +08:00
committed by GitHub
parent a19e57604e
commit ee2b8d0a28

View File

@@ -177,8 +177,6 @@ class MainActivity : ComponentActivity() {
rtfText = ""
Log.i(TAG, "Started with text $testText")
samplesChannel = Channel<FloatArray>()
CoroutineScope(Dispatchers.IO).launch {
for (samples in samplesChannel) {
track.write(
@@ -191,6 +189,10 @@ class MainActivity : ComponentActivity() {
break
}
}
for (s in samplesChannel) {
// drain the channel
}
}
CoroutineScope(Dispatchers.Default).launch {
@@ -219,7 +221,6 @@ class MainActivity : ComponentActivity() {
audioDuration,
elapsed / audioDuration
)
samplesChannel.close()
val filename =
application.filesDir.absolutePath + "/generated.wav"