support nodejs (#438)
This commit is contained in:
62
.github/scripts/test-nodejs-npm.sh
vendored
Executable file
62
.github/scripts/test-nodejs-npm.sh
vendored
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
echo "dir: $d"
|
||||
cd $d
|
||||
npm install
|
||||
git status
|
||||
ls -lh
|
||||
ls -lh node_modules
|
||||
|
||||
# offline asr
|
||||
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-ctc-en-conformer-small.tar.bz2
|
||||
tar xvf sherpa-onnx-nemo-ctc-en-conformer-small.tar.bz2
|
||||
rm sherpa-onnx-nemo-ctc-en-conformer-small.tar.bz2
|
||||
node ./test-offline-nemo-ctc.js
|
||||
rm -rf sherpa-onnx-nemo-ctc-en-conformer-small
|
||||
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-paraformer-zh-2023-03-28.tar.bz2
|
||||
tar xvf sherpa-onnx-paraformer-zh-2023-03-28.tar.bz2
|
||||
rm sherpa-onnx-paraformer-zh-2023-03-28.tar.bz2
|
||||
node ./test-offline-paraformer.js
|
||||
rm -rf sherpa-onnx-paraformer-zh-2023-03-28
|
||||
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-en-2023-06-26.tar.bz2
|
||||
tar xvf sherpa-onnx-zipformer-en-2023-06-26.tar.bz2
|
||||
rm sherpa-onnx-zipformer-en-2023-06-26.tar.bz2
|
||||
node ./test-offline-transducer.js
|
||||
rm -rf sherpa-onnx-zipformer-en-2023-06-26
|
||||
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-whisper-tiny.en.tar.bz2
|
||||
tar xvf sherpa-onnx-whisper-tiny.en.tar.bz2
|
||||
rm sherpa-onnx-whisper-tiny.en.tar.bz2
|
||||
node ./test-offline-whisper.js
|
||||
rm -rf sherpa-onnx-whisper-tiny.en
|
||||
|
||||
# online asr
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
|
||||
tar xvf sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
|
||||
rm sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
|
||||
node ./test-online-paraformer.js
|
||||
rm -rf sherpa-onnx-streaming-paraformer-bilingual-zh-en
|
||||
|
||||
wget -q 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
|
||||
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||
node ./test-online-transducer.js
|
||||
rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
|
||||
|
||||
# offline tts
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-vctk.tar.bz2
|
||||
tar xvf vits-vctk.tar.bz2
|
||||
rm vits-vctk.tar.bz2
|
||||
node ./test-offline-tts-en.js
|
||||
rm -rf vits-vctk
|
||||
|
||||
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-zh-aishell3.tar.bz2
|
||||
tar xvf vits-zh-aishell3.tar.bz2
|
||||
rm vits-zh-aishell3.tar.bz2
|
||||
node ./test-offline-tts-zh.js
|
||||
rm -rf vits-zh-aishell3
|
||||
1
.github/workflows/dot-net.yaml
vendored
1
.github/workflows/dot-net.yaml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dot-net
|
||||
- fix-dot-net
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
|
||||
58
.github/workflows/npm.yaml
vendored
Normal file
58
.github/workflows/npm.yaml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: npm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: npm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
nodejs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
cd nodejs-examples
|
||||
|
||||
npm install npm@6.14.4 -g
|
||||
npm install npm@6.14.4
|
||||
npm --version
|
||||
|
||||
- name: Build nodejs package
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd scripts/nodejs
|
||||
./run.sh
|
||||
npm install
|
||||
rm run.sh
|
||||
npm ci
|
||||
npm publish --provenance --access public
|
||||
59
.github/workflows/test-nodejs-npm.yaml
vendored
Normal file
59
.github/workflows/test-nodejs-npm.yaml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: test-nodejs-npm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
schedule:
|
||||
# minute (0-59)
|
||||
# hour (0-23)
|
||||
# day of the month (1-31)
|
||||
# month (1-12)
|
||||
# day of the week (0-6)
|
||||
# nightly build at 23:50 UTC time every day
|
||||
- cron: "50 23 * * *"
|
||||
|
||||
concurrency:
|
||||
group: test-nodejs-npm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-nodejs-npm:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
export d=nodejs-examples
|
||||
./.github/scripts/test-nodejs-npm.sh
|
||||
108
.github/workflows/test-nodejs.yaml
vendored
Normal file
108
.github/workflows/test-nodejs.yaml
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
name: test-nodejs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: test-nodejs-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-nodejs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-Release-ON
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ..
|
||||
make -j2
|
||||
make install
|
||||
ls -lh install/lib
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Copy files
|
||||
shell: bash
|
||||
run: |
|
||||
os=${{ matrix.os }}
|
||||
if [[ $os == 'ubuntu-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/linux-x64
|
||||
dst=scripts/nodejs/lib/linux-x64
|
||||
elif [[ $os == 'macos-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/osx-x64
|
||||
dst=scripts/nodejs/lib/osx-x64
|
||||
fi
|
||||
cp -v build/install/lib/* $dst/
|
||||
|
||||
- name: replace files
|
||||
shell: bash
|
||||
run: |
|
||||
cd nodejs-examples
|
||||
files=$(ls -1 *.js)
|
||||
for f in ${files[@]}; do
|
||||
echo $f
|
||||
sed -i.bak s%\'sherpa-onnx\'%\'./index.js\'% $f
|
||||
git status
|
||||
done
|
||||
git diff
|
||||
cp *.js ../scripts/nodejs
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
export d=scripts/nodejs
|
||||
|
||||
pushd $d
|
||||
npm install
|
||||
npm install wav
|
||||
popd
|
||||
|
||||
./.github/scripts/test-nodejs-npm.sh
|
||||
Reference in New Issue
Block a user