Skip to content

Commit 921c437

Browse files
authored
Fix building for open harmonyOS (#2142)
1 parent 7cbb1bc commit 921c437

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/audio-tagging.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ static Napi::Object AudioTaggingComputeWrapper(const Napi::CallbackInfo &info) {
196196
Napi::Number::New(env, events[i]->index));
197197
obj.Set(Napi::String::New(env, "prob"),
198198
Napi::Number::New(env, events[i]->prob));
199-
ans[i] = obj;
199+
// ans[i] = obj; // see #2120
200+
ans.Set(i, obj);
200201
}
201202

202203
SherpaOnnxAudioTaggingFreeResults(events);

harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/speaker-identification.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ static Napi::Array SpeakerEmbeddingManagerGetAllSpeakersWrapper(
766766

767767
Napi::Array ans = Napi::Array::New(env, num_speakers);
768768
for (uint32_t i = 0; i != num_speakers; ++i) {
769-
ans[i] = Napi::String::New(env, all_speaker_names[i]);
769+
// ans[i] = Napi::String::New(env, all_speaker_names[i]); // see #2120
770+
ans.Set(i, Napi::String::New(env, all_speaker_names[i]));
770771
}
771772
SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers(all_speaker_names);
772773
return ans;

harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/utils.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ static Napi::Array ListRawFileDir(const Napi::CallbackInfo &info) {
6666
auto files = GetFilenames(mgr.get(), dir);
6767
Napi::Array ans = Napi::Array::New(env, files.size());
6868
for (int32_t i = 0; i != files.size(); ++i) {
69-
ans[i] = Napi::String::New(env, files[i]);
69+
// Fix #2120
70+
// ans[i] = Napi::String::New(env, files[i]);
71+
ans.Set(i, Napi::String::New(env, files[i]));
7072
}
7173
return ans;
7274
}

0 commit comments

Comments
 (0)