Enable to stop TTS generation (#1041)

This commit is contained in:
Fangjun Kuang
2024-06-22 18:18:36 +08:00
committed by GitHub
parent 96ab843173
commit 9dd0e03568
32 changed files with 249 additions and 70 deletions

View File

@@ -126,7 +126,7 @@ class TtsService : TextToSpeechService() {
return
}
val ttsCallback = { floatSamples: FloatArray ->
val ttsCallback: (FloatArray) -> Int = fun(floatSamples): Int {
// convert FloatArray to ByteArray
val samples = floatArrayToByteArray(floatSamples)
val maxBufferSize: Int = callback.maxBufferSize
@@ -137,6 +137,9 @@ class TtsService : TextToSpeechService() {
offset += bytesToWrite
}
// 1 means to continue
// 0 means to stop
return 1
}
Log.i(TAG, "text: $text")
@@ -160,4 +163,4 @@ class TtsService : TextToSpeechService() {
}
return byteArray
}
}
}