Skip to content

Commit dbaa26f

Browse files
authored
Publish node-addon-api npm package for linux arm64 (#841)
1 parent d2e86b0 commit dbaa26f

File tree

7 files changed

+228
-13
lines changed

7 files changed

+228
-13
lines changed

.github/scripts/node-addon/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"sherpa-onnx-darwin-arm64": "^SHERPA_ONNX_VERSION",
4949
"sherpa-onnx-darwin-x64": "^SHERPA_ONNX_VERSION",
5050
"sherpa-onnx-linux-x64": "^SHERPA_ONNX_VERSION",
51+
"sherpa-onnx-linux-arm64": "^SHERPA_ONNX_VERSION",
5152
"sherpa-onnx-win-x64": "^SHERPA_ONNX_VERSION"
5253
}
5354
}

.github/scripts/node-addon/run.sh

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ echo "sherpa_onnx_dir: $sherpa_onnx_dir"
66
src_dir=$sherpa_onnx_dir/.github/scripts/node-addon
77

88
platform=$(node -p "require('os').platform()")
9+
910
arch=$(node -p "require('os').arch()")
11+
1012
platform2=$platform
1113

1214
if [[ $platform == win32 ]]; then

.github/scripts/test-nodejs-addon-npm.sh

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ls -lh node_modules
1313
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
1414
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
1515
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
16+
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
1617

1718
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
1819
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: npm-addon-linux-aarch64
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: npm-addon-linux-aarch64-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
jobs:
15+
npm-addon-linux-aarch64:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest]
21+
python-version: ["3.8"]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v2
30+
with:
31+
platforms: arm64
32+
33+
- name: Setup Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
38+
- name: Show .npmrc
39+
shell: bash
40+
run: |
41+
echo $PWD
42+
echo $HOME
43+
44+
find $HOME -name .npmrc
45+
46+
- uses: actions/setup-node@v4
47+
with:
48+
registry-url: 'https://registry.npmjs.org'
49+
50+
- name: Show .npmrc
51+
shell: bash
52+
run: |
53+
echo $PWD
54+
echo $HOME
55+
56+
find $HOME -name .npmrc
57+
58+
cat /home/runner/work/_temp/.npmrc
59+
cp -v /home/runner/work/_temp/.npmrc ./
60+
61+
- name: Build sherpa-onnx
62+
uses: addnab/docker-run-action@v3
63+
with:
64+
image: quay.io/pypa/manylinux2014_aarch64
65+
options: |
66+
--platform linux/arm64
67+
--volume ${{ github.workspace }}/:/shared/
68+
shell: bash
69+
run: |
70+
cp /shared/.npmrc ~/
71+
72+
cat ~/.npmrc
73+
74+
echo $HOME
75+
uname -a
76+
cat /etc/*release
77+
gcc --version
78+
cmake --version
79+
80+
curl -sL https://rpm.nodesource.com/setup_16.x | bash -
81+
yum install -y nodejs
82+
83+
node --version
84+
85+
cd /shared
86+
87+
mkdir build
88+
cd build
89+
cmake \
90+
-DCMAKE_INSTALL_PREFIX=./install \
91+
-DBUILD_SHARED_LIBS=ON \
92+
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
93+
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
94+
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
95+
..
96+
97+
make -j
98+
make install
99+
cd ..
100+
101+
d=$PWD
102+
export SHERPA_ONNX_INSTALL_DIR=$d/build/install
103+
104+
ls -lh /shared/build
105+
106+
pushd scripts/node-addon-api/
107+
npm i
108+
109+
./node_modules/.bin/cmake-js compile --log-level verbose
110+
popd
111+
112+
owner=${{ github.repository_owner }}
113+
export owner
114+
115+
echo "---"
116+
ls -lh build/install/lib/
117+
sudo chown -R runner ./build
118+
echo "---"
119+
ls -lh build/install/lib/
120+
echo "---"
121+
122+
.github/scripts/node-addon/run.sh
123+
124+
ls -lh ./sherpa-onnx-node
125+
126+
export NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}
127+
128+
cd ./sherpa-onnx-node
129+
cp -v /shared/.npmrc ./
130+
npm install
131+
npm ci
132+
ls -lh
133+
# see https://docs.npmjs.com/generating-provenance-statements
134+
npm publish --provenance --access public
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: test-node-addon-npm-aarch64
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '.github/workflows/test-nodejs-addon-npm-aarch64.yaml'
9+
- 'CMakeLists.txt'
10+
- 'cmake/**'
11+
- 'sherpa-onnx/csrc/*'
12+
- 'sherpa-onnx/c-api/*'
13+
- 'scripts/node-addon-api/**'
14+
- 'scripts/node-addon-api/*.js'
15+
- 'nodejs-addon-examples/package.json'
16+
17+
pull_request:
18+
branches:
19+
- master
20+
paths:
21+
- '.github/workflows/test-nodejs-addon-npm-aarch64.yaml'
22+
- 'CMakeLists.txt'
23+
- 'cmake/**'
24+
- 'sherpa-onnx/csrc/*'
25+
- 'sherpa-onnx/c-api/*'
26+
- 'scripts/node-addon-api/*.js'
27+
- 'nodejs-addon-examples/package.json'
28+
29+
workflow_dispatch:
30+
31+
concurrency:
32+
group: test-node-addon-npm-aarch64-${{ github.ref }}
33+
cancel-in-progress: true
34+
35+
permissions:
36+
contents: read
37+
38+
jobs:
39+
test-node-addon-npm-aarch64:
40+
name: ${{ matrix.os }}
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ubuntu-latest]
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v2
54+
with:
55+
platforms: arm64
56+
57+
- name: Test sherpa-onnx
58+
uses: addnab/docker-run-action@v3
59+
with:
60+
image: quay.io/pypa/manylinux2014_aarch64
61+
options: |
62+
--platform linux/arm64
63+
--volume ${{ github.workspace }}/:/shared/
64+
shell: bash
65+
run: |
66+
git config --global --add safe.directory /shared
67+
68+
echo $HOME
69+
uname -a
70+
cat /etc/*release
71+
cmake --version
72+
73+
curl -sL https://rpm.nodesource.com/setup_16.x | bash -
74+
yum install -y nodejs
75+
76+
node --version
77+
78+
cd /shared
79+
80+
.github/scripts/test-nodejs-addon-npm.sh

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This repository supports running the following functions **locally**
99
- Spoken language identification
1010
- Audio tagging
1111
- VAD (e.g., [silero-vad](https://github.com/snakers4/silero-vad))
12+
- Keyword spotting
1213

1314
on the following platforms and operating systems:
1415

@@ -27,17 +28,11 @@ on the following platforms and operating systems:
2728

2829
with the following APIs
2930

30-
- C++
31-
- C
32-
- Python
33-
- Go
34-
- ``C#``
35-
- Javascript
36-
- Java
37-
- Kotlin
31+
- C++, C, Python, Go, ``C#``
32+
- Java, Kotlin, JavaScript
3833
- Swift
3934

40-
# Links for pre-built Android APKs
35+
## Links for pre-built Android APKs
4136

4237
| Description | URL | 中国用户 |
4338
|--------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
@@ -52,7 +47,7 @@ with the following APIs
5247
| Spoken language identification | [Address](https://k2-fsa.github.io/sherpa/onnx/spoken-language-identification/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/spoken-language-identification/apk-cn.html) |
5348
|Keyword spotting| [Address](https://k2-fsa.github.io/sherpa/onnx/kws/apk.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/kws/apk-cn.html)|
5449

55-
# Links for pre-trained models
50+
## Links for pre-trained models
5651

5752
| Description | URL |
5853
|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
@@ -65,12 +60,12 @@ with the following APIs
6560
| Spoken language identification (Language ID) | See multi-lingual Whisper ASR models from [Speech recognition](https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models) |
6661
| Punctuation| [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models)|
6762

68-
# Useful links
63+
## Useful links
6964

7065
- Documentation: https://k2-fsa.github.io/sherpa/onnx/
7166
- Bilibili 演示视频: https://search.bilibili.com/all?keyword=%E6%96%B0%E4%B8%80%E4%BB%A3Kaldi
7267

73-
# How to reach us
68+
## How to reach us
7469

7570
Please see
7671
https://k2-fsa.github.io/sherpa/social-groups.html

nodejs-addon-examples/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRAR
2222

2323
# For Linux x64
2424
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
25-
```
2625

26+
# For Linux arm64, e.g., Raspberry Pi 4
27+
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
28+
```
2729

2830
## Streaming speech recognition with zipformer transducer
2931
```bash

0 commit comments

Comments
 (0)