Add streaming ASR support for HarmonyOS. (#1565)
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
#include "android/asset_manager_jni.h"
|
||||
#endif
|
||||
|
||||
#if __OHOS__
|
||||
#include "rawfile/raw_file_manager.h"
|
||||
#endif
|
||||
|
||||
#include "onnxruntime_cxx_api.h" // NOLINT
|
||||
#include "sherpa-onnx/csrc/cat.h"
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
@@ -50,9 +54,9 @@ OnlineConformerTransducerModel::OnlineConformerTransducerModel(
|
||||
}
|
||||
}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
template <typename Manager>
|
||||
OnlineConformerTransducerModel::OnlineConformerTransducerModel(
|
||||
AAssetManager *mgr, const OnlineModelConfig &config)
|
||||
Manager *mgr, const OnlineModelConfig &config)
|
||||
: env_(ORT_LOGGING_LEVEL_ERROR),
|
||||
config_(config),
|
||||
sess_opts_(GetSessionOptions(config)),
|
||||
@@ -72,7 +76,6 @@ OnlineConformerTransducerModel::OnlineConformerTransducerModel(
|
||||
InitJoiner(buf.data(), buf.size());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void OnlineConformerTransducerModel::InitEncoder(void *model_data,
|
||||
size_t model_data_length) {
|
||||
@@ -91,7 +94,11 @@ void OnlineConformerTransducerModel::InitEncoder(void *model_data,
|
||||
std::ostringstream os;
|
||||
os << "---encoder---\n";
|
||||
PrintModelMetadata(os, meta_data);
|
||||
#if __OHOS__
|
||||
SHERPA_ONNX_LOGE("%{public}s", os.str().c_str());
|
||||
#else
|
||||
SHERPA_ONNX_LOGE("%s", os.str().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
Ort::AllocatorWithDefaultOptions allocator; // used in the macro below
|
||||
@@ -121,7 +128,11 @@ void OnlineConformerTransducerModel::InitDecoder(void *model_data,
|
||||
std::ostringstream os;
|
||||
os << "---decoder---\n";
|
||||
PrintModelMetadata(os, meta_data);
|
||||
#if __OHOS__
|
||||
SHERPA_ONNX_LOGE("%{public}s", os.str().c_str());
|
||||
#else
|
||||
SHERPA_ONNX_LOGE("%s", os.str().c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
Ort::AllocatorWithDefaultOptions allocator; // used in the macro below
|
||||
@@ -273,4 +284,14 @@ Ort::Value OnlineConformerTransducerModel::RunJoiner(Ort::Value encoder_out,
|
||||
return std::move(logit[0]);
|
||||
}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
template OnlineConformerTransducerModel::OnlineConformerTransducerModel(
|
||||
AAssetManager *mgr, const OnlineModelConfig &config);
|
||||
#endif
|
||||
|
||||
#if __OHOS__
|
||||
template OnlineConformerTransducerModel::OnlineConformerTransducerModel(
|
||||
NativeResourceManager *mgr, const OnlineModelConfig &config);
|
||||
#endif
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
Reference in New Issue
Block a user