Fix crash in Android tts engine demo. (#2029)
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user