Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish node-addon-api npm package for linux arm64 #841

Merged
merged 8 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/node-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"sherpa-onnx-darwin-arm64": "^SHERPA_ONNX_VERSION",
"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"
}
}
2 changes: 2 additions & 0 deletions .github/scripts/node-addon/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ echo "sherpa_onnx_dir: $sherpa_onnx_dir"
src_dir=$sherpa_onnx_dir/.github/scripts/node-addon

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

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

platform2=$platform

if [[ $platform == win32 ]]; then
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/test-nodejs-addon-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ls -lh node_modules
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH

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
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/npm-addon-linux-aarch64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: npm-addon-linux-aarch64

on:
workflow_dispatch:

concurrency:
group: npm-addon-linux-aarch64-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
id-token: write

jobs:
npm-addon-linux-aarch64:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Show .npmrc
shell: bash
run: |
echo $PWD
echo $HOME

find $HOME -name .npmrc

- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'

- name: Show .npmrc
shell: bash
run: |
echo $PWD
echo $HOME

find $HOME -name .npmrc

cat /home/runner/work/_temp/.npmrc
cp -v /home/runner/work/_temp/.npmrc ./

- name: Build sherpa-onnx
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_aarch64
options: |
--platform linux/arm64
--volume ${{ github.workspace }}/:/shared/
shell: bash
run: |
cp /shared/.npmrc ~/

cat ~/.npmrc

echo $HOME
uname -a
cat /etc/*release
gcc --version
cmake --version

curl -sL https://rpm.nodesource.com/setup_16.x | bash -
yum install -y nodejs

node --version

cd /shared

mkdir build
cd build
cmake \
-DCMAKE_INSTALL_PREFIX=./install \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
..

make -j
make install
cd ..

d=$PWD
export SHERPA_ONNX_INSTALL_DIR=$d/build/install

ls -lh /shared/build

pushd scripts/node-addon-api/
npm i

./node_modules/.bin/cmake-js compile --log-level verbose
popd

owner=${{ github.repository_owner }}
export owner

echo "---"
ls -lh build/install/lib/
sudo chown -R runner ./build
echo "---"
ls -lh build/install/lib/
echo "---"

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

ls -lh ./sherpa-onnx-node

export NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}

cd ./sherpa-onnx-node
cp -v /shared/.npmrc ./
npm install
npm ci
ls -lh
# see https://docs.npmjs.com/generating-provenance-statements
npm publish --provenance --access public
80 changes: 80 additions & 0 deletions .github/workflows/test-nodejs-addon-npm-aarch64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: test-node-addon-npm-aarch64

on:
push:
branches:
- master
paths:
- '.github/workflows/test-nodejs-addon-npm-aarch64.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'scripts/node-addon-api/**'
- 'scripts/node-addon-api/*.js'
- 'nodejs-addon-examples/package.json'

pull_request:
branches:
- master
paths:
- '.github/workflows/test-nodejs-addon-npm-aarch64.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'scripts/node-addon-api/*.js'
- 'nodejs-addon-examples/package.json'

workflow_dispatch:

concurrency:
group: test-node-addon-npm-aarch64-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test-node-addon-npm-aarch64:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- name: Test sherpa-onnx
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_aarch64
options: |
--platform linux/arm64
--volume ${{ github.workspace }}/:/shared/
shell: bash
run: |
git config --global --add safe.directory /shared

echo $HOME
uname -a
cat /etc/*release
cmake --version

curl -sL https://rpm.nodesource.com/setup_16.x | bash -
yum install -y nodejs

node --version

cd /shared

.github/scripts/test-nodejs-addon-npm.sh
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This repository supports running the following functions **locally**
- Spoken language identification
- Audio tagging
- VAD (e.g., [silero-vad](https://github.com/snakers4/silero-vad))
- Keyword spotting

on the following platforms and operating systems:

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

with the following APIs

- C++
- C
- Python
- Go
- ``C#``
- Javascript
- Java
- Kotlin
- C++, C, Python, Go, ``C#``
- Java, Kotlin, JavaScript
- Swift

# Links for pre-built Android APKs
## Links for pre-built Android APKs

| Description | URL | 中国用户 |
|--------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
Expand All @@ -52,7 +47,7 @@ with the following APIs
| 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) |
|Keyword spotting| [Address](https://k2-fsa.github.io/sherpa/onnx/kws/apk.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/kws/apk-cn.html)|

# Links for pre-trained models
## Links for pre-trained models

| Description | URL |
|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -65,12 +60,12 @@ with the following APIs
| 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) |
| Punctuation| [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models)|

# Useful links
## Useful links

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

# How to reach us
## How to reach us

Please see
https://k2-fsa.github.io/sherpa/social-groups.html
Expand Down
4 changes: 3 additions & 1 deletion nodejs-addon-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRAR

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

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

## Streaming speech recognition with zipformer transducer
```bash
Expand Down
Loading