Fangjun Kuang
Committed by GitHub

Publish npm package with node-addon-api for Windows (#838)

@@ -6,3 +6,4 @@ See also @@ -6,3 +6,4 @@ See also
6 - https://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency 6 - https://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency
7 - https://github.com/WonderInventions/node-webrtc/blob/develop/lib/binding.js 7 - https://github.com/WonderInventions/node-webrtc/blob/develop/lib/binding.js
8 - cross-compiling https://github.com/nodejs/node-gyp/issues/829#issuecomment-665527032 8 - cross-compiling https://github.com/nodejs/node-gyp/issues/829#issuecomment-665527032
  9 + - https://nodejs.github.io/node-addon-examples/build-tools/cmake-js
1 { 1 {
2 - "name": "sherpa-onnx-PLATFORM-ARCH", 2 + "name": "sherpa-onnx-PLATFORM2-ARCH",
3 "version": "SHERPA_ONNX_VERSION", 3 "version": "SHERPA_ONNX_VERSION",
4 "description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection", 4 "description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection",
5 "main": "index.js", 5 "main": "index.js",
@@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
47 "optionalDependencies": { 47 "optionalDependencies": {
48 "sherpa-onnx-darwin-arm64": "^SHERPA_ONNX_VERSION", 48 "sherpa-onnx-darwin-arm64": "^SHERPA_ONNX_VERSION",
49 "sherpa-onnx-darwin-x64": "^SHERPA_ONNX_VERSION", 49 "sherpa-onnx-darwin-x64": "^SHERPA_ONNX_VERSION",
50 - "sherpa-onnx-linux-x64": "^SHERPA_ONNX_VERSION" 50 + "sherpa-onnx-linux-x64": "^SHERPA_ONNX_VERSION",
  51 + "sherpa-onnx-win-x64": "^SHERPA_ONNX_VERSION"
51 } 52 }
52 } 53 }
@@ -7,6 +7,11 @@ src_dir=$sherpa_onnx_dir/.github/scripts/node-addon @@ -7,6 +7,11 @@ src_dir=$sherpa_onnx_dir/.github/scripts/node-addon
7 7
8 platform=$(node -p "require('os').platform()") 8 platform=$(node -p "require('os').platform()")
9 arch=$(node -p "require('os').arch()") 9 arch=$(node -p "require('os').arch()")
  10 +platform2=$platform
  11 +
  12 +if [[ $platform == win32 ]]; then
  13 + platform2=win
  14 +fi
10 15
11 SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 16 SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
12 echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION" 17 echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
@@ -17,6 +22,7 @@ fi @@ -17,6 +22,7 @@ fi
17 22
18 sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g $src_dir/package-optional.json 23 sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g $src_dir/package-optional.json
19 sed -i.bak s/k2-fsa/$owner/g $src_dir/package-optional.json 24 sed -i.bak s/k2-fsa/$owner/g $src_dir/package-optional.json
  25 +sed -i.bak s/PLATFORM2/$platform2/g $src_dir/package-optional.json
20 sed -i.bak s/PLATFORM/$platform/g $src_dir/package-optional.json 26 sed -i.bak s/PLATFORM/$platform/g $src_dir/package-optional.json
21 sed -i.bak s/ARCH/$arch/g $src_dir/package-optional.json 27 sed -i.bak s/ARCH/$arch/g $src_dir/package-optional.json
22 28
@@ -66,30 +66,26 @@ jobs: @@ -66,30 +66,26 @@ jobs:
66 - name: Build sherpa-onnx node-addon 66 - name: Build sherpa-onnx node-addon
67 shell: bash 67 shell: bash
68 run: | 68 run: |
69 - export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH 69 + d=$PWD
  70 + export SHERPA_ONNX_INSTALL_DIR=$d/build/install
  71 +
70 sudo mkdir /shared 72 sudo mkdir /shared
71 sudo ln -s $PWD/build /shared/ 73 sudo ln -s $PWD/build /shared/
72 74
73 ls -lh /shared/build 75 ls -lh /shared/build
74 76
75 - pkg-config --cflags sherpa-onnx  
76 - pkg-config --libs sherpa-onnx  
77 -  
78 cd scripts/node-addon-api/ 77 cd scripts/node-addon-api/
79 78
80 npm i 79 npm i
81 80
82 - ./node_modules/.bin/node-gyp configure build --verbose 81 + ./node_modules/.bin/cmake-js compile --log-level verbose
83 82
84 - name: Prepare for publish 83 - name: Prepare for publish
85 shell: bash 84 shell: bash
86 run: | 85 run: |
87 - export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH  
88 -  
89 owner=${{ github.repository_owner }} 86 owner=${{ github.repository_owner }}
90 export owner 87 export owner
91 88
92 -  
93 echo "---" 89 echo "---"
94 ls -lh build/install/lib/ 90 ls -lh build/install/lib/
95 sudo chown -R runner ./build 91 sudo chown -R runner ./build
@@ -61,31 +61,24 @@ jobs: @@ -61,31 +61,24 @@ jobs:
61 .. 61 ..
62 make -j install 62 make -j install
63 63
64 -  
65 -  
66 - name: Build sherpa-onnx node-addon 64 - name: Build sherpa-onnx node-addon
67 shell: bash 65 shell: bash
68 run: | 66 run: |
69 - export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH  
70 -  
71 - pkg-config --cflags sherpa-onnx  
72 - pkg-config --libs sherpa-onnx 67 + d=$PWD
  68 + export SHERPA_ONNX_INSTALL_DIR=$d/build/install
73 69
74 cd scripts/node-addon-api/ 70 cd scripts/node-addon-api/
75 71
76 npm i 72 npm i
77 73
78 - ./node_modules/.bin/node-gyp configure build --verbose 74 + ./node_modules/.bin/cmake-js compile --log-level verbose
79 75
80 - name: Prepare for publish 76 - name: Prepare for publish
81 shell: bash 77 shell: bash
82 run: | 78 run: |
83 - export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH  
84 -  
85 owner=${{ github.repository_owner }} 79 owner=${{ github.repository_owner }}
86 export owner 80 export owner
87 81
88 -  
89 ls -lh build/install/lib/ 82 ls -lh build/install/lib/
90 echo "---" 83 echo "---"
91 84
  1 +name: npm-addon-win-x64
  2 +
  3 +on:
  4 + workflow_dispatch:
  5 +
  6 +concurrency:
  7 + group: npm-addon-win-x64-${{ github.ref }}
  8 + cancel-in-progress: true
  9 +
  10 +permissions:
  11 + contents: read
  12 + id-token: write
  13 +
  14 +jobs:
  15 + npm-addon-win-x64:
  16 + runs-on: ${{ matrix.os }}
  17 + strategy:
  18 + fail-fast: false
  19 + matrix:
  20 + os: [windows-latest]
  21 + python-version: ["3.8"]
  22 +
  23 + steps:
  24 + - uses: actions/checkout@v4
  25 + with:
  26 + fetch-depth: 0
  27 +
  28 + - name: Setup Python ${{ matrix.python-version }}
  29 + uses: actions/setup-python@v5
  30 + with:
  31 + python-version: ${{ matrix.python-version }}
  32 +
  33 + - uses: actions/setup-node@v4
  34 + with:
  35 + registry-url: 'https://registry.npmjs.org'
  36 +
  37 + - name: Display node version
  38 + shell: bash
  39 + run: |
  40 + node --version
  41 +
  42 + - name: Build sherpa-onnx
  43 + shell: bash
  44 + run: |
  45 + mkdir build
  46 + cd build
  47 + cmake \
  48 + -DCMAKE_BUILD_TYPE=Release \
  49 + -DCMAKE_INSTALL_PREFIX=./install \
  50 + -DBUILD_SHARED_LIBS=ON \
  51 + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
  52 + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
  53 + -DSHERPA_ONNX_ENABLE_BINARY=OFF \
  54 + ..
  55 +
  56 + ls -lh _deps/onnxruntime-src/lib/
  57 +
  58 + cmake --build . --config Release --target install -- -m:6
  59 +
  60 + ls -lh install/lib
  61 +
  62 + echo "----------"
  63 +
  64 + cp -v _deps/onnxruntime-src/lib/*.lib ./install/lib
  65 +
  66 + echo "----------"
  67 +
  68 + ls -lh install/lib
  69 +
  70 + - name: Build sherpa-onnx node-addon
  71 + shell: bash
  72 + run: |
  73 + d=$PWD
  74 + export SHERPA_ONNX_INSTALL_DIR=$d/build/install
  75 +
  76 + cd scripts/node-addon-api/
  77 +
  78 + npm i
  79 +
  80 + ./node_modules/.bin/cmake-js compile --log-level verbose
  81 +
  82 + - name: Prepare for publish
  83 + shell: bash
  84 + run: |
  85 + owner=${{ github.repository_owner }}
  86 + export owner
  87 +
  88 + echo "---"
  89 + ls -lh build/install/lib/
  90 + echo "---"
  91 + ls -lh build/install/lib/
  92 + echo "---"
  93 +
  94 + .github/scripts/node-addon/run.sh
  95 +
  96 + - name: Display files to be published
  97 + shell: bash
  98 + run: |
  99 + ls -lh ./sherpa-onnx-node
  100 +
  101 + - name: Publish
  102 + shell: bash
  103 + env:
  104 + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  105 + run: |
  106 + cd ./sherpa-onnx-node
  107 + npm install
  108 + npm ci
  109 + # see https://docs.npmjs.com/generating-provenance-statements
  110 + npm publish --provenance --access public
@@ -39,7 +39,7 @@ jobs: @@ -39,7 +39,7 @@ jobs:
39 strategy: 39 strategy:
40 fail-fast: false 40 fail-fast: false
41 matrix: 41 matrix:
42 - os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04] 42 + os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04, windows-latest]
43 node-version: ["16", "17", "18", "19", "21", "22"] 43 node-version: ["16", "17", "18", "19", "21", "22"]
44 python-version: ["3.8"] 44 python-version: ["3.8"]
45 45
@@ -53,6 +53,16 @@ jobs: @@ -53,6 +53,16 @@ jobs:
53 with: 53 with:
54 python-version: ${{ matrix.python-version }} 54 python-version: ${{ matrix.python-version }}
55 55
  56 + - name: Install Python dependencies
  57 + shell: bash
  58 + run: |
  59 + pip install ninja
  60 +
  61 + - name: Show ninja help
  62 + shell: bash
  63 + run: |
  64 + ninja --help || true
  65 +
56 - uses: actions/setup-node@v4 66 - uses: actions/setup-node@v4
57 with: 67 with:
58 registry-url: 'https://registry.npmjs.org' 68 registry-url: 'https://registry.npmjs.org'
@@ -63,12 +73,18 @@ jobs: @@ -63,12 +73,18 @@ jobs:
63 run: | 73 run: |
64 node --version 74 node --version
65 75
  76 + - name: Display npm help
  77 + shell: bash
  78 + run: |
  79 + npm help
  80 +
66 - name: ccache 81 - name: ccache
67 uses: hendrikmuhs/ccache-action@v1.2 82 uses: hendrikmuhs/ccache-action@v1.2
68 with: 83 with:
69 key: ${{ matrix.os }}-release-shared 84 key: ${{ matrix.os }}-release-shared
70 85
71 - name: Build sherpa-onnx 86 - name: Build sherpa-onnx
  87 + if: matrix.os == 'windows-latest'
72 shell: bash 88 shell: bash
73 run: | 89 run: |
74 export CMAKE_CXX_COMPILER_LAUNCHER=ccache 90 export CMAKE_CXX_COMPILER_LAUNCHER=ccache
@@ -77,34 +93,71 @@ jobs: @@ -77,34 +93,71 @@ jobs:
77 mkdir build 93 mkdir build
78 cd build 94 cd build
79 cmake \ 95 cmake \
80 - -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx \ 96 + -DCMAKE_BUILD_TYPE=Release \
  97 + -DCMAKE_INSTALL_PREFIX=./install \
81 -DBUILD_SHARED_LIBS=ON \ 98 -DBUILD_SHARED_LIBS=ON \
82 -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ 99 -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
83 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ 100 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
84 -DSHERPA_ONNX_ENABLE_BINARY=OFF \ 101 -DSHERPA_ONNX_ENABLE_BINARY=OFF \
85 .. 102 ..
86 - make -j  
87 - make install 103 +
  104 + ls -lh _deps/onnxruntime-src/lib/
  105 +
  106 + cmake --build . --config Release --target install -- -m:6
  107 +
  108 + ls -lh install/lib
  109 +
  110 + echo "----------"
  111 +
  112 + cp -v _deps/onnxruntime-src/lib/*.lib ./install/lib
  113 +
  114 + echo "----------"
  115 +
  116 + ls -lh install/lib
  117 +
  118 + - name: Build sherpa-onnx
  119 + if: matrix.os != 'windows-latest'
  120 + shell: bash
  121 + run: |
  122 + export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  123 + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
  124 +
  125 + mkdir build
  126 + cd build
  127 + cmake \
  128 + -G Ninja \
  129 + -DCMAKE_BUILD_TYPE=Release \
  130 + -DCMAKE_INSTALL_PREFIX=./install \
  131 + -DBUILD_SHARED_LIBS=ON \
  132 + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
  133 + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
  134 + -DSHERPA_ONNX_ENABLE_BINARY=OFF \
  135 + ..
  136 +
  137 + cmake --build . --config Release --target install -- -j 6
88 138
89 - name: Build node-addon-api package 139 - name: Build node-addon-api package
90 shell: bash 140 shell: bash
91 run: | 141 run: |
92 - cd scripts/node-addon-api 142 + d=$PWD
  143 + export SHERPA_ONNX_INSTALL_DIR=$d/build/install
93 144
94 - export PKG_CONFIG_PATH=/tmp/sherpa-onnx:$PKG_CONFIG_PATH 145 + cd scripts/node-addon-api
95 146
96 - ls -lh /tmp/sherpa-onnx 147 + echo $d/build/install
97 148
98 - pkg-config --cflags sherpa-onnx  
99 - pkg-config --libs sherpa-onnx 149 + ls -lh $d/build/install
100 150
101 npm i 151 npm i
102 152
103 - ./node_modules/.bin/node-gyp configure build --verbose 153 + ./node_modules/.bin/cmake-js compile --log-level verbose
104 154
105 - name: Test streaming transducer 155 - name: Test streaming transducer
106 shell: bash 156 shell: bash
107 run: | 157 run: |
  158 + export PATH=$PWD/build/install/lib:$PATH
  159 + export LD_LIBRARY_PATH=$PWD/build/install/lib:$LD_LIBRARY_PATH
  160 +
108 cd scripts/node-addon-api 161 cd scripts/node-addon-api
109 curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 162 curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
110 tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 163 tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
@@ -42,7 +42,7 @@ jobs: @@ -42,7 +42,7 @@ jobs:
42 strategy: 42 strategy:
43 fail-fast: false 43 fail-fast: false
44 matrix: 44 matrix:
45 - os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04] 45 + os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04, windows-latest]
46 node-version: ["16", "17", "18", "19", "21", "22"] 46 node-version: ["16", "17", "18", "19", "21", "22"]
47 47
48 steps: 48 steps:
@@ -26,14 +26,14 @@ python3 ./python-api-examples/offline-tts.py \ @@ -26,14 +26,14 @@ python3 ./python-api-examples/offline-tts.py \
26 26
27 Example (2/2) 27 Example (2/2)
28 28
29 -wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-zh-aishell3.tar.bz2  
30 -tar xvf vits-zh-aishell3.tar.bz2 29 +wget https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-icefall-zh-aishell3.tar.bz2
  30 +tar xvf vits-icefall-zh-aishell3.tar.bz2
31 31
32 python3 ./python-api-examples/offline-tts.py \ 32 python3 ./python-api-examples/offline-tts.py \
33 - --vits-model=./vits-aishell3.onnx \ 33 + --vits-model=./model.onnx \
34 --vits-lexicon=./lexicon.txt \ 34 --vits-lexicon=./lexicon.txt \
35 --vits-tokens=./tokens.txt \ 35 --vits-tokens=./tokens.txt \
36 - --tts-rule-fsts=./rule.fst \ 36 + --tts-rule-fsts='./phone.fst,./date.fst,./number.fst' \
37 --sid=21 \ 37 --sid=21 \
38 --output-filename=./liubei-21.wav \ 38 --output-filename=./liubei-21.wav \
39 "勿以恶小而为之,勿以善小而不为。惟贤惟德,能服于人。122334" 39 "勿以恶小而为之,勿以善小而不为。惟贤惟德,能服于人。122334"
  1 +# See also https://github.com/cmake-js/cmake-js
  2 +# npm install cmake-js
  3 +# ./node_modules/.bin/cmake-js --help
  4 +# ./node_modules/.bin/cmake-js --version
  5 +# ./node_modules/.bin/cmake-js compile --help
  6 +# ./node_modules/.bin/cmake-js compile --log-level
  7 +# ./node_modules/.bin/cmake-js compile --log-level verbose
  8 +cmake_minimum_required(VERSION 3.15)
  9 +cmake_policy(SET CMP0091 NEW)
  10 +cmake_policy(SET CMP0042 NEW)
  11 +
  12 +project(sherpa-onnx)
  13 +
  14 +set(CMAKE_CXX_STANDARD 14)
  15 +
  16 +add_definitions(-DNAPI_VERSION=3)
  17 +
  18 +include_directories(${CMAKE_JS_INC})
  19 +
  20 +set(srcs
  21 + src/sherpa-onnx-node-addon-api.cc
  22 + src/streaming-asr.cc
  23 + src/wave-reader.cc
  24 +)
  25 +
  26 +if(NOT DEFINED ENV{SHERPA_ONNX_INSTALL_DIR})
  27 + message(FATAL_ERROR "
  28 +Please run:
  29 +git clone https://github.com/k2-fsa/sherpa-onnx
  30 +cd sherpa-onnx
  31 +mkdir build
  32 +cd build
  33 +cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ..
  34 +make install
  35 +export SHERPA_ONNX_INSTALL_DIR=$PWD/install
  36 + ")
  37 +endif()
  38 +
  39 +include_directories($ENV{SHERPA_ONNX_INSTALL_DIR}/include)
  40 +
  41 +# See https://nodejs.github.io/node-addon-examples/build-tools/cmake-js
  42 +# Include Node-API wrappers
  43 +execute_process(
  44 + COMMAND node -p "require('node-addon-api').include"
  45 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  46 + OUTPUT_VARIABLE NODE_ADDON_API_DIR
  47 +)
  48 +
  49 +string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
  50 +string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
  51 +include_directories(${NODE_ADDON_API_DIR})
  52 +
  53 +link_directories($ENV{SHERPA_ONNX_INSTALL_DIR}/lib)
  54 +
  55 +add_library(${PROJECT_NAME} SHARED ${srcs} ${CMAKE_JS_SRC})
  56 +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
  57 +target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
  58 +
  59 +target_link_libraries(${PROJECT_NAME}
  60 + sherpa-onnx-c-api
  61 + sherpa-onnx-core
  62 + kaldi-decoder-core
  63 + sherpa-onnx-kaldifst-core
  64 + sherpa-onnx-fstfar
  65 + sherpa-onnx-fst
  66 + kaldi-native-fbank-core
  67 + piper_phonemize
  68 + espeak-ng
  69 + ucd
  70 + onnxruntime
  71 + -Wl,-rpath,$ENV{SHERPA_ONNX_INSTALL_DIR}/lib
  72 +)
  73 +
  74 +
  75 +if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
  76 + # Generate node.lib
  77 + execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
  78 +endif()
1 -{  
2 - 'targets': [  
3 - {  
4 - 'target_name': 'sherpa-onnx',  
5 - 'sources': [  
6 - 'src/sherpa-onnx-node-addon-api.cc',  
7 - 'src/streaming-asr.cc',  
8 - 'src/wave-reader.cc'  
9 - ],  
10 - 'include_dirs': [  
11 - "<!@(node -p \"require('node-addon-api').include\")",  
12 - "<!@(pkg-config --variable=includedir sherpa-onnx)"  
13 - ],  
14 - 'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],  
15 - 'cflags!': [  
16 - '-fno-exceptions',  
17 - ],  
18 - 'cflags_cc!': [  
19 - '-fno-exceptions',  
20 - '-std=c++17'  
21 - ],  
22 - 'libraries': [  
23 - "<!@(pkg-config --libs sherpa-onnx)"  
24 - ],  
25 - 'xcode_settings': {  
26 - 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',  
27 - 'CLANG_CXX_LIBRARY': 'libc++',  
28 - 'MACOSX_DEPLOYMENT_TARGET': '10.7'  
29 - },  
30 - 'msvs_settings': {  
31 - 'VCCLCompilerTool': { 'ExceptionHandling': 1 },  
32 - }  
33 - }  
34 - ]  
35 -}  
1 const os = require('os'); 1 const os = require('os');
2 -const platform_arch = `${os.platform()}-${os.arch()}`; 2 +
  3 +// Package name triggered spam for sherpa-onnx-win32-x64
  4 +// so we have renamed it to sherpa-onnx-win-x64
  5 +const platform_arch =
  6 + `${os.platform() == 'win32' ? 'win' : os.platform()}-${os.arch()}`;
3 const possible_paths = [ 7 const possible_paths = [
4 '../build/Release/sherpa-onnx.node', 8 '../build/Release/sherpa-onnx.node',
5 '../build/Debug/sherpa-onnx.node', 9 '../build/Debug/sherpa-onnx.node',
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 "version": "1.0.0", 3 "version": "1.0.0",
4 "description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection", 4 "description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection",
5 "dependencies": { 5 "dependencies": {
  6 + "cmake-js": "^6.0.0",
6 "node-addon-api": "^1.1.0", 7 "node-addon-api": "^1.1.0",
7 - "bindings": "^1.5.0",  
8 - "perf_hooks": "*",  
9 - "node-gyp": "^8.3.0" 8 + "perf_hooks": "*"
10 }, 9 },
11 "scripts": { 10 "scripts": {
  11 + "install": "cmake-js compile --log-level verbose",
12 "test": "node --napi-modules ./test/test_binding.js" 12 "test": "node --napi-modules ./test/test_binding.js"
13 }, 13 },
14 "repository": { 14 "repository": {
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 // Copyright (c) 2024 Xiaomi Corporation 3 // Copyright (c) 2024 Xiaomi Corporation
4 #include "napi.h" // NOLINT 4 #include "napi.h" // NOLINT
5 5
6 -Napi::Object InitStreamingAsr(Napi::Env env, Napi::Object exports); 6 +void InitStreamingAsr(Napi::Env env, Napi::Object exports);
7 void InitWaveReader(Napi::Env env, Napi::Object exports); 7 void InitWaveReader(Napi::Env env, Napi::Object exports);
8 8
9 Napi::Object Init(Napi::Env env, Napi::Object exports) { 9 Napi::Object Init(Napi::Env env, Napi::Object exports) {