Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
pkufool committed May 9, 2024
2 parents 589ca83 + 5d8c35e commit 78e8700
Show file tree
Hide file tree
Showing 194 changed files with 8,727 additions and 808 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/node-addon/README-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

Please see [sherpa-onnx-node](https://www.npmjs.com/package/sherpa-onnx-node)
11 changes: 11 additions & 0 deletions .github/scripts/node-addon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Introduction

Please see
https://github.com/k2-fsa/sherpa-onnx/blob/master/nodejs-addon-examples/README.md
for usages.


||Method|Support multiple threads|Minimum required node version|
|---|---|---|---|
|this package| https://github.com/nodejs/node-addon-api | Yes | v10|
|https://www.npmjs.com/package/sherpa-onnx| WebAssembly | No | v18|
1 change: 1 addition & 0 deletions .github/scripts/node-addon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./sherpa-onnx.node');
9 changes: 9 additions & 0 deletions .github/scripts/node-addon/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Introduction

See also

- https://github.com/WonderInventions/node-webrtc/blob/develop/package.json
- https://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency
- https://github.com/WonderInventions/node-webrtc/blob/develop/lib/binding.js
- cross-compiling https://github.com/nodejs/node-gyp/issues/829#issuecomment-665527032
- https://nodejs.github.io/node-addon-examples/build-tools/cmake-js
53 changes: 53 additions & 0 deletions .github/scripts/node-addon/package-optional.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "sherpa-onnx-PLATFORM2-ARCH",
"version": "SHERPA_ONNX_VERSION",
"description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/k2-fsa/sherpa-onnx.git"
},
"keywords": [
"speech to text",
"text to speech",
"transcription",
"real-time speech recognition",
"without internet connection",
"embedded systems",
"open source",
"zipformer",
"asr",
"tts",
"stt",
"c++",
"onnxruntime",
"onnx",
"ai",
"next-gen kaldi",
"offline",
"privacy",
"open source",
"vad",
"speaker id",
"language id",
"node-addon-api",
"streaming speech recognition",
"speech",
"recognition"
],
"author": "The next-gen Kaldi team",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/k2-fsa/sherpa-onnx/issues"
},
"homepage": "https://github.com/k2-fsa/sherpa-onnx#readme",
"os": [
"PLATFORM"
],
"cpu": [
"ARCH"
]
}
54 changes: 54 additions & 0 deletions .github/scripts/node-addon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "sherpa-onnx-node",
"version": "SHERPA_ONNX_VERSION",
"description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection",
"main": "sherpa-onnx.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/k2-fsa/sherpa-onnx.git"
},
"keywords": [
"speech to text",
"text to speech",
"transcription",
"real-time speech recognition",
"without internet connection",
"embedded systems",
"open source",
"zipformer",
"asr",
"tts",
"stt",
"c++",
"onnxruntime",
"onnx",
"ai",
"next-gen kaldi",
"offline",
"privacy",
"open source",
"vad",
"speaker id",
"language id",
"node-addon-api",
"streaming speech recognition",
"speech",
"recognition"
],
"author": "The next-gen Kaldi team",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/k2-fsa/sherpa-onnx/issues"
},
"homepage": "https://github.com/k2-fsa/sherpa-onnx#readme",
"optionalDependencies": {
"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"
}
}
45 changes: 45 additions & 0 deletions .github/scripts/node-addon/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

sherpa_onnx_dir=$PWD
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
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"

if [ -z $owner ]; then
owner=k2-fsa
fi

sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g $src_dir/package-optional.json
sed -i.bak s/k2-fsa/$owner/g $src_dir/package-optional.json
sed -i.bak s/PLATFORM2/$platform2/g $src_dir/package-optional.json
sed -i.bak s/PLATFORM/$platform/g $src_dir/package-optional.json
sed -i.bak s/ARCH/$arch/g $src_dir/package-optional.json

git diff $src_dir/package-optional.json

dst=$sherpa_onnx_dir/sherpa-onnx-node
mkdir -p $dst

cp $src_dir/package-optional.json $dst/package.json
cp $src_dir/index.js $dst/
cp $src_dir/README-optional.md $dst/README.md

cp -fv build/install/lib/lib* $dst/ || true
cp -fv build/install/lib/*dll $dst/ || true

cp scripts/node-addon-api/build/Release/sherpa-onnx.node $dst/

ls $dst
1 change: 1 addition & 0 deletions .github/scripts/test-dot-net.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cd ../offline-decode-files
cd ../offline-tts
./run-aishell3.sh
./run-piper.sh
./run-hf-fanchen.sh
ls -lh

cd ../..
Expand Down
24 changes: 24 additions & 0 deletions .github/scripts/test-nodejs-addon-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -ex

d=nodejs-addon-examples
echo "dir: $d"
cd $d
npm install --verbose
git status
ls -lh
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
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2

node test_asr_streaming_transducer.js

rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
101 changes: 99 additions & 2 deletions .github/scripts/test-offline-ctc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,111 @@ echo "PATH: $PATH"

which $EXE

log "-----------------------------------------------------------------"
log "Run Nemo fast conformer hybrid transducer ctc models (CTC branch)"
log "-----------------------------------------------------------------"

url=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
name=$(basename $url)
curl -SL -O $url
tar xvf $name
rm $name
repo=$(basename -s .tar.bz2 $name)
ls -lh $repo

log "test $repo"
test_wavs=(
de-german.wav
es-spanish.wav
hr-croatian.wav
po-polish.wav
uk-ukrainian.wav
en-english.wav
fr-french.wav
it-italian.wav
ru-russian.wav
)
for w in ${test_wavs[@]}; do
time $EXE \
--tokens=$repo/tokens.txt \
--nemo-ctc-model=$repo/model.onnx \
--debug=1 \
$repo/test_wavs/$w
done

rm -rf $repo

url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-fast-conformer-ctc-en-24500.tar.bz2
name=$(basename $url)
curl -SL -O $url
tar xvf $name
rm $name
repo=$(basename -s .tar.bz2 $name)
ls -lh $repo

log "Test $repo"

time $EXE \
--tokens=$repo/tokens.txt \
--nemo-ctc-model=$repo/model.onnx \
--debug=1 \
$repo/test_wavs/en-english.wav

rm -rf $repo

url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-fast-conformer-ctc-es-1424.tar.bz2
name=$(basename $url)
curl -SL -O $url
tar xvf $name
rm $name
repo=$(basename -s .tar.bz2 $name)
ls -lh $repo

log "test $repo"

time $EXE \
--tokens=$repo/tokens.txt \
--nemo-ctc-model=$repo/model.onnx \
--debug=1 \
$repo/test_wavs/es-spanish.wav

rm -rf $repo

url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-fast-conformer-ctc-en-de-es-fr-14288.tar.bz2
name=$(basename $url)
curl -SL -O $url
tar xvf $name
rm $name
repo=$(basename -s .tar.bz2 $name)
ls -lh $repo

log "Test $repo"

test_wavs=(
en-english.wav
de-german.wav
fr-french.wav
es-spanish.wav
)

for w in ${test_wavs[@]}; do
time $EXE \
--tokens=$repo/tokens.txt \
--nemo-ctc-model=$repo/model.onnx \
--debug=1 \
$repo/test_wavs/$w
done

rm -rf $repo

log "------------------------------------------------------------"
log "Run Wenet models"
log "------------------------------------------------------------"
wenet_models=(
sherpa-onnx-zh-wenet-aishell
sherpa-onnx-zh-wenet-aishell2
# sherpa-onnx-zh-wenet-aishell2
# sherpa-onnx-zh-wenet-wenetspeech
sherpa-onnx-zh-wenet-multi-cn
# sherpa-onnx-zh-wenet-multi-cn
sherpa-onnx-en-wenet-librispeech
# sherpa-onnx-en-wenet-gigaspeech
)
Expand Down
9 changes: 7 additions & 2 deletions .github/scripts/test-spoken-language-identification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ for wav in ${waves[@]}; do
ls -lh *.wav
done

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/spoken-language-identification-test-wavs.tar.bz2
tar xvf spoken-language-identification-test-wavs.tar.bz2
rm spoken-language-identification-test-wavs.tar.bz2
data=spoken-language-identification-test-wavs

for name in ${names[@]}; do
log "------------------------------------------------------------"
log "Run $name"
Expand All @@ -85,14 +90,14 @@ for name in ${names[@]}; do
time $EXE \
--whisper-encoder=$repo/${name}-encoder.onnx \
--whisper-decoder=$repo/${name}-decoder.onnx \
$wav
$data/$wav

log "test int8 onnx"

time $EXE \
--whisper-encoder=$repo/${name}-encoder.int8.onnx \
--whisper-decoder=$repo/${name}-decoder.int8.onnx \
$wav
$data/$wav
done
rm -rf $repo
done
6 changes: 6 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
./build-android-arm64-v8a.sh
mkdir -p jniLibs/arm64-v8a/
cp -v ./build-android-arm64-v8a/install/lib/*.so ./jniLibs/arm64-v8a/
rm -rf ./build-android-arm64-v8a/
- name: build android armv7-eabi
shell: bash
Expand All @@ -65,6 +66,7 @@ jobs:
./build-android-armv7-eabi.sh
mkdir -p ./jniLibs/armeabi-v7a/
cp -v ./build-android-armv7-eabi/install/lib/*.so ./jniLibs/armeabi-v7a/
rm -rf ./build-android-armv7-eabi
- name: build android x86_64
shell: bash
Expand All @@ -73,6 +75,7 @@ jobs:
./build-android-x86-64.sh
mkdir -p ./jniLibs/x86_64
cp -v ./build-android-x86-64/install/lib/*.so ./jniLibs/x86_64
rm -rf ./build-android-x86-64
- name: build android x86
shell: bash
Expand All @@ -81,6 +84,7 @@ jobs:
./build-android-x86.sh
mkdir -p ./jniLibs/x86
cp -v ./build-android-x86/install/lib/*.so ./jniLibs/x86
rm -rf ./build-android-x86
- name: Copy files
shell: bash
Expand Down Expand Up @@ -112,6 +116,8 @@ jobs:
command: |
git config --global user.email "[email protected]"
git config --global user.name "Fangjun Kuang"
du -h -d1 .
ls -lh
rm -rf huggingface
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
Expand Down
Loading

0 comments on commit 78e8700

Please sign in to comment.