k2-fsa / sherpa-ncnn

Real-time speech recognition using next-gen Kaldi with ncnn without Internet connection. Support iOS, Android, Raspberry Pi, VisionFive2, LicheePi4A etc.
https://k2-fsa.github.io/sherpa/ncnn/index.html
Apache License 2.0
902 stars 138 forks source link

Add examples for NodeJS #280

Closed csukuangfj closed 8 months ago

csukuangfj commented 8 months ago

~The CI reports the following error after successfully decoding a file.~

~I am not familiar with nodejs.~

~Any help is appreciated.~

~https://github.com/csukuangfj/sherpa-ncnn/actions/runs/6841272416/job/18601451413#step:8:540~

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0x7ffe3e50dca0
 1: 0xb72001  [node]
 2: 0x1bfa314 V8_Fatal(char const*, ...) [node]
 3: 0xfb7791 v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr<v8::internal::BackingStore>) [node]
 4: 0xd09188 v8::ArrayBuffer::GetBackingStore() [node]
 5: 0xabced0 napi_get_typedarray_info [node]
 6: 0x7f87144053ac  [/home/runner/work/sherpa-ncnn/sherpa-ncnn/nodejs-examples/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 7: 0x7f8714405b48  [/home/runner/work/sherpa-ncnn/sherpa-ncnn/nodejs-examples/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 8: 0x7f8714407831  [/home/runner/work/sherpa-ncnn/sherpa-ncnn/nodejs-examples/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 9: 0x7f871440d4ab Napi::details::CallbackData<void (*)(Napi::CallbackInfo const&), void>::Wrapper(napi_env__*, napi_callback_info__*) [/home/runner/work/sherpa-ncnn/sherpa-ncnn/nodejs-examples/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
10: 0xab380d  [node]
11: 0xd3df8e  [node]
12: 0xd3f3af v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x15d9f39  [node]
./run.sh: line 34:  4556 Trace/breakpoint trap   (core dumped) node ./test.js
csukuangfj commented 8 months ago

Note that NodeJS 18, 20, and 21 are known not to work due to https://github.com/node-ffi-napi/node-ffi-napi/issues/244

I am using

$ node --version
v16.20.2
csukuangfj commented 8 months ago

Downgrading node to v13.14 fixes the error.

See https://github.com/node-ffi-napi/node-ffi-napi/issues/97 for details.