17
17
#include " android/asset_manager_jni.h"
18
18
#endif
19
19
20
+ #if __OHOS__
21
+ #include " rawfile/raw_file_manager.h"
22
+ #endif
23
+
20
24
#include " onnxruntime_cxx_api.h" // NOLINT
21
25
#include " sherpa-onnx/csrc/cat.h"
22
26
#include " sherpa-onnx/csrc/macros.h"
@@ -50,9 +54,9 @@ OnlineConformerTransducerModel::OnlineConformerTransducerModel(
50
54
}
51
55
}
52
56
53
- # if __ANDROID_API__ >= 9
57
+ template < typename Manager>
54
58
OnlineConformerTransducerModel::OnlineConformerTransducerModel (
55
- AAssetManager *mgr, const OnlineModelConfig &config)
59
+ Manager *mgr, const OnlineModelConfig &config)
56
60
: env_(ORT_LOGGING_LEVEL_ERROR),
57
61
config_ (config),
58
62
sess_opts_(GetSessionOptions(config)),
@@ -72,7 +76,6 @@ OnlineConformerTransducerModel::OnlineConformerTransducerModel(
72
76
InitJoiner (buf.data (), buf.size ());
73
77
}
74
78
}
75
- #endif
76
79
77
80
void OnlineConformerTransducerModel::InitEncoder (void *model_data,
78
81
size_t model_data_length) {
@@ -91,7 +94,11 @@ void OnlineConformerTransducerModel::InitEncoder(void *model_data,
91
94
std::ostringstream os;
92
95
os << " ---encoder---\n " ;
93
96
PrintModelMetadata (os, meta_data);
97
+ #if __OHOS__
98
+ SHERPA_ONNX_LOGE (" %{public}s" , os.str ().c_str ());
99
+ #else
94
100
SHERPA_ONNX_LOGE (" %s" , os.str ().c_str ());
101
+ #endif
95
102
}
96
103
97
104
Ort::AllocatorWithDefaultOptions allocator; // used in the macro below
@@ -121,7 +128,11 @@ void OnlineConformerTransducerModel::InitDecoder(void *model_data,
121
128
std::ostringstream os;
122
129
os << " ---decoder---\n " ;
123
130
PrintModelMetadata (os, meta_data);
131
+ #if __OHOS__
132
+ SHERPA_ONNX_LOGE (" %{public}s" , os.str ().c_str ());
133
+ #else
124
134
SHERPA_ONNX_LOGE (" %s" , os.str ().c_str ());
135
+ #endif
125
136
}
126
137
127
138
Ort::AllocatorWithDefaultOptions allocator; // used in the macro below
@@ -273,4 +284,14 @@ Ort::Value OnlineConformerTransducerModel::RunJoiner(Ort::Value encoder_out,
273
284
return std::move (logit[0 ]);
274
285
}
275
286
287
+ #if __ANDROID_API__ >= 9
288
+ template OnlineConformerTransducerModel::OnlineConformerTransducerModel(
289
+ AAssetManager *mgr, const OnlineModelConfig &config);
290
+ #endif
291
+
292
+ #if __OHOS__
293
+ template OnlineConformerTransducerModel::OnlineConformerTransducerModel(
294
+ NativeResourceManager *mgr, const OnlineModelConfig &config);
295
+ #endif
296
+
276
297
} // namespace sherpa_onnx
0 commit comments