Add streaming ASR support for HarmonyOS. (#1565)
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
#include "android/asset_manager_jni.h"
|
||||
#endif
|
||||
|
||||
#if __OHOS__
|
||||
#include "rawfile/raw_file_manager.h"
|
||||
#endif
|
||||
|
||||
#include "sherpa-onnx/csrc/cat.h"
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
#include "sherpa-onnx/csrc/onnx-utils.h"
|
||||
@@ -36,8 +40,8 @@ class OnlineNeMoCtcModel::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
Impl(AAssetManager *mgr, const OnlineModelConfig &config)
|
||||
template <typename Manager>
|
||||
Impl(Manager *mgr, const OnlineModelConfig &config)
|
||||
: config_(config),
|
||||
env_(ORT_LOGGING_LEVEL_ERROR),
|
||||
sess_opts_(GetSessionOptions(config)),
|
||||
@@ -47,7 +51,6 @@ class OnlineNeMoCtcModel::Impl {
|
||||
Init(buf.data(), buf.size());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<Ort::Value> Forward(Ort::Value x,
|
||||
std::vector<Ort::Value> states) {
|
||||
@@ -202,7 +205,11 @@ class OnlineNeMoCtcModel::Impl {
|
||||
if (config_.debug) {
|
||||
std::ostringstream os;
|
||||
PrintModelMetadata(os, meta_data);
|
||||
SHERPA_ONNX_LOGE("%s\n", os.str().c_str());
|
||||
#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
|
||||
@@ -286,11 +293,10 @@ class OnlineNeMoCtcModel::Impl {
|
||||
OnlineNeMoCtcModel::OnlineNeMoCtcModel(const OnlineModelConfig &config)
|
||||
: impl_(std::make_unique<Impl>(config)) {}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
OnlineNeMoCtcModel::OnlineNeMoCtcModel(AAssetManager *mgr,
|
||||
template <typename Manager>
|
||||
OnlineNeMoCtcModel::OnlineNeMoCtcModel(Manager *mgr,
|
||||
const OnlineModelConfig &config)
|
||||
: impl_(std::make_unique<Impl>(mgr, config)) {}
|
||||
#endif
|
||||
|
||||
OnlineNeMoCtcModel::~OnlineNeMoCtcModel() = default;
|
||||
|
||||
@@ -323,4 +329,14 @@ std::vector<std::vector<Ort::Value>> OnlineNeMoCtcModel::UnStackStates(
|
||||
return impl_->UnStackStates(std::move(states));
|
||||
}
|
||||
|
||||
#if __ANDROID_API__ >= 9
|
||||
template OnlineNeMoCtcModel::OnlineNeMoCtcModel(
|
||||
AAssetManager *mgr, const OnlineModelConfig &config);
|
||||
#endif
|
||||
|
||||
#if __OHOS__
|
||||
template OnlineNeMoCtcModel::OnlineNeMoCtcModel(
|
||||
NativeResourceManager *mgr, const OnlineModelConfig &config);
|
||||
#endif
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
Reference in New Issue
Block a user