Add keyword spotter C API for HarmonyOS (#1769)

This commit is contained in:
Fangjun Kuang
2025-01-26 14:12:30 +08:00
committed by GitHub
parent 73c3695287
commit f178e96bf0
8 changed files with 135 additions and 42 deletions

View File

@@ -6,6 +6,15 @@
#include "sherpa-onnx/csrc/keyword-spotter-transducer-impl.h"
#if __ANDROID_API__ >= 9
#include "android/asset_manager.h"
#include "android/asset_manager_jni.h"
#endif
#if __OHOS__
#include "rawfile/raw_file_manager.h"
#endif
namespace sherpa_onnx {
std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
@@ -18,9 +27,9 @@ std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
exit(-1);
}
#if __ANDROID_API__ >= 9
template <typename Manager>
std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
AAssetManager *mgr, const KeywordSpotterConfig &config) {
Manager *mgr, const KeywordSpotterConfig &config) {
if (!config.model_config.transducer.encoder.empty()) {
return std::make_unique<KeywordSpotterTransducerImpl>(mgr, config);
}
@@ -28,6 +37,15 @@ std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
SHERPA_ONNX_LOGE("Please specify a model");
exit(-1);
}
#if __ANDROID_API__ >= 9
template std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
AAssetManager *mgr, const KeywordSpotterConfig &config);
#endif
#if __OHOS__
template std::unique_ptr<KeywordSpotterImpl> KeywordSpotterImpl::Create(
NativeResourceManager *mgr, const KeywordSpotterConfig &config);
#endif
} // namespace sherpa_onnx