Skip to content

Commit

Permalink
Provide npm package for 32-bit Windows x86 (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Jul 17, 2024
1 parent 5b1fa87 commit 9e448d0
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/scripts/node-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"sherpa-onnx-darwin-x64": "^SHERPA_ONNX_VERSION",
"sherpa-onnx-linux-x64": "^SHERPA_ONNX_VERSION",
"sherpa-onnx-linux-arm64": "^SHERPA_ONNX_VERSION",
"sherpa-onnx-win-x64": "^SHERPA_ONNX_VERSION"
"sherpa-onnx-win-x64": "^SHERPA_ONNX_VERSION",
"sherpa-onnx-win-ia32": "^SHERPA_ONNX_VERSION"
}
}
9 changes: 8 additions & 1 deletion .github/scripts/node-addon/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ platform=$(node -p "require('os').platform()")

arch=$(node -p "require('os').arch()")

echo "platform: $platform"
echo "arch: $arch"

# ia32 for win x86

platform2=$platform


if [[ $platform == win32 ]]; then
platform2=win
fi


SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"

# SHERPA_ONNX_VERSION=1.0.28
# SHERPA_ONNX_VERSION=1.0.31

if [ -z $owner ]; then
owner=k2-fsa
Expand Down
138 changes: 79 additions & 59 deletions .github/scripts/test-nodejs-addon-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,66 @@ d=nodejs-addon-examples
echo "dir: $d"
cd $d

arch=$(node -p "require('os').arch()")
platform=$(node -p "require('os').platform()")
node_version=$(node -p "process.versions.node.split('.')[0]")

echo "----------asr----------"

if [[ $arch != "ia32" && $platform != "win32" ]]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2
tar xvf sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2
rm sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2

node ./test_asr_non_streaming_nemo_ctc.js
rm -rf sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
tar xvf sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
rm sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2

node ./test_asr_non_streaming_paraformer.js

rm -f itn*

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn_zh_number.fst
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn-zh-number.wav

node ./test_asr_non_streaming_paraformer_itn.js

rm -rf sherpa-onnx-paraformer-zh-2023-09-14
fi

echo "----------tts----------"

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_GB-cori-medium.tar.bz2
tar xf vits-piper-en_GB-cori-medium.tar.bz2
rm vits-piper-en_GB-cori-medium.tar.bz2

node ./test_tts_non_streaming_vits_piper_en.js
rm -rf vits-piper-en_GB-cori-medium

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-coqui-de-css10.tar.bz2
tar xvf vits-coqui-de-css10.tar.bz2
rm vits-coqui-de-css10.tar.bz2

node ./test_tts_non_streaming_vits_coqui_de.js
rm -rf vits-coqui-de-css10

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-vits-zh-ll.tar.bz2
tar xvf sherpa-onnx-vits-zh-ll.tar.bz2
rm sherpa-onnx-vits-zh-ll.tar.bz2

node ./test_tts_non_streaming_vits_zh_ll.js
rm -rf sherpa-onnx-vits-zh-ll

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-icefall-zh-aishell3.tar.bz2
tar xvf vits-icefall-zh-aishell3.tar.bz2
rm vits-icefall-zh-aishell3.tar.bz2

node ./test_tts_non_streaming_vits_zh_aishell3.js
rm -rf vits-icefall-zh-aishell3

echo "----------keyword spotting----------"

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/kws-models/sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.tar.bz2
Expand All @@ -15,14 +75,23 @@ rm sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.tar.bz2
node ./test_keyword_spotter_transducer.js
rm -rf sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01

echo "----------add punctuations----------"
if [[ $arch != "ia32" && $platform != "win32" && $node_version != 21 ]]; then
# The punctuation model is so large that it cause memory allocation failure on windows x86
# 2024-07-17 03:24:34.2388391 [E:onnxruntime:, inference_session.cc:1981
# onnxruntime::InferenceSession::Initialize::<lambda_d603a8c74863bd6b58a1c7996295ed04>::operator ()]
# Exception during initialization: bad allocation
# Error: Process completed with exit code 127.
#
# Node 21 does not have such an issue
echo "----------add punctuations----------"

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2

node ./test_punctuation.js
rm -rf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12
node ./test_punctuation.js
rm -rf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12
fi

echo "----------audio tagging----------"

Expand Down Expand Up @@ -75,9 +144,10 @@ rm -f itn*
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn_zh_number.fst
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn-zh-number.wav

node test_asr_streaming_transducer_itn.js

node test_asr_streaming_transducer.js
if [[ $arch != "ia32" && $platform != "win32" ]]; then
node test_asr_streaming_transducer_itn.js
node test_asr_streaming_transducer.js
fi

rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20

Expand Down Expand Up @@ -114,56 +184,6 @@ rm sherpa-onnx-whisper-tiny.en.tar.bz2
node ./test_asr_non_streaming_whisper.js
rm -rf sherpa-onnx-whisper-tiny.en

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2
tar xvf sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2
rm sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k.tar.bz2

node ./test_asr_non_streaming_nemo_ctc.js
rm -rf sherpa-onnx-nemo-fast-conformer-ctc-be-de-en-es-fr-hr-it-pl-ru-uk-20k

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
tar xvf sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
rm sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2

node ./test_asr_non_streaming_paraformer.js

rm -f itn*

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn_zh_number.fst
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/itn-zh-number.wav

node ./test_asr_non_streaming_paraformer_itn.js

rm -rf sherpa-onnx-paraformer-zh-2023-09-14

echo "----------tts----------"

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_GB-cori-medium.tar.bz2
tar xvf vits-piper-en_GB-cori-medium.tar.bz2
rm vits-piper-en_GB-cori-medium.tar.bz2

node ./test_tts_non_streaming_vits_piper_en.js
rm -rf vits-piper-en_GB-cori-medium

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-coqui-de-css10.tar.bz2
tar xvf vits-coqui-de-css10.tar.bz2
rm vits-coqui-de-css10.tar.bz2

node ./test_tts_non_streaming_vits_coqui_de.js
rm -rf vits-coqui-de-css10

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-vits-zh-ll.tar.bz2
tar xvf sherpa-onnx-vits-zh-ll.tar.bz2
rm sherpa-onnx-vits-zh-ll.tar.bz2

node ./test_tts_non_streaming_vits_zh_ll.js
rm -rf sherpa-onnx-vits-zh-ll

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-icefall-zh-aishell3.tar.bz2
tar xvf vits-icefall-zh-aishell3.tar.bz2
rm vits-icefall-zh-aishell3.tar.bz2

node ./test_tts_non_streaming_vits_zh_aishell3.js
rm -rf vits-icefall-zh-aishell3

ls -lh
6 changes: 6 additions & 0 deletions .github/workflows/npm-addon-linux-x64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-linux-x64
path: ./sherpa-onnx-node.tar.bz2

- name: Publish
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/npm-addon-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-${{ matrix.os }}
path: ./sherpa-onnx-node.tar.bz2

- name: Publish
shell: bash
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/npm-addon-win-x64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
os: [windows-2019]
python-version: ["3.8"]

steps:
Expand Down Expand Up @@ -54,6 +54,8 @@ jobs:
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
..
ls -lh _deps/onnxruntime-src/lib/
Expand All @@ -65,6 +67,7 @@ jobs:
echo "----------"
cp -v _deps/onnxruntime-src/lib/*.lib ./install/lib
cp -v _deps/onnxruntime-src/lib/*.dll ./install/lib
echo "----------"
Expand Down Expand Up @@ -100,6 +103,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-win-x64
path: ./sherpa-onnx-node.tar.bz2

- name: Publish
shell: bash
Expand Down
Loading

0 comments on commit 9e448d0

Please sign in to comment.