Support playing as it is generating for Android (#477)

This commit is contained in:
Fangjun Kuang
2023-12-09 16:36:38 +08:00
committed by GitHub
parent cae0231f93
commit 0f053d8040
5 changed files with 190 additions and 66 deletions

View File

@@ -2,6 +2,10 @@ package com.k2fsa.sherpa.onnx
import android.content.res.AssetManager
fun callback(samples: FloatArray): Unit {
println("callback got called with ${samples.size} samples");
}
fun main() {
testTts()
testAsr()
@@ -22,7 +26,7 @@ fun testTts() {
)
)
val tts = OfflineTts(config=config)
val audio = tts.generate(text="“Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar.”")
val audio = tts.generateWithCallback(text="“Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar.”", callback=::callback)
audio.save(filename="test-en.wav")
}