Fix crash in Android tts engine demo. (#2029)
This commit is contained in:
@@ -177,8 +177,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
rtfText = ""
|
rtfText = ""
|
||||||
Log.i(TAG, "Started with text $testText")
|
Log.i(TAG, "Started with text $testText")
|
||||||
|
|
||||||
samplesChannel = Channel<FloatArray>()
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
for (samples in samplesChannel) {
|
for (samples in samplesChannel) {
|
||||||
track.write(
|
track.write(
|
||||||
@@ -191,6 +189,10 @@ class MainActivity : ComponentActivity() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (s in samplesChannel) {
|
||||||
|
// drain the channel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
@@ -219,7 +221,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
audioDuration,
|
audioDuration,
|
||||||
elapsed / audioDuration
|
elapsed / audioDuration
|
||||||
)
|
)
|
||||||
samplesChannel.close()
|
|
||||||
|
|
||||||
val filename =
|
val filename =
|
||||||
application.filesDir.absolutePath + "/generated.wav"
|
application.filesDir.absolutePath + "/generated.wav"
|
||||||
|
|||||||
Reference in New Issue
Block a user