Added progress for callback of tts generator (#712)

Co-authored-by: leohwang <leohwang@360converter.com>
This commit is contained in:
Leo Huang
2024-03-28 17:12:20 +08:00
committed by GitHub
parent de655e838e
commit 638f48f47a
8 changed files with 51 additions and 40 deletions

View File

@@ -797,7 +797,7 @@ class SherpaOnnxOfflineTts {
GeneratedAudio Generate(
const std::string &text, int64_t sid = 0, float speed = 1.0,
std::function<void(const float *, int32_t)> callback = nullptr) const {
std::function<void(const float *, int32_t, float)> callback = nullptr) const {
return tts_.Generate(text, sid, speed, callback);
}
@@ -1314,8 +1314,8 @@ Java_com_k2fsa_sherpa_onnx_OfflineTts_generateWithCallbackImpl(
const char *p_text = env->GetStringUTFChars(text, nullptr);
SHERPA_ONNX_LOGE("string is: %s", p_text);
std::function<void(const float *, int32_t)> callback_wrapper =
[env, callback](const float *samples, int32_t n) {
std::function<void(const float *, int32_t, float)> callback_wrapper =
[env, callback](const float *samples, int32_t n, float /*p*/) {
jclass cls = env->GetObjectClass(callback);
jmethodID mid = env->GetMethodID(cls, "invoke", "([F)V");