From 4fee9190baf5cf3f2c3ed5ae4da12a3b3d5a1f43 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 12 Aug 2024 08:35:59 +0000 Subject: [PATCH] add CI for windows --- .github/workflows/pascal.yaml | 36 +++++++++++++++- pascal-api-examples/read-wav/run.sh | 12 +++--- .../streaming-asr/run-paraformer.sh | 11 ++--- .../streaming-asr/run-zipformer-ctc-hlg.sh | 41 +++++++++++++++++++ .../streaming-asr/run-zipformer-ctc.sh | 41 +++++++++++++++++++ .../streaming-asr/run-zipformer-transducer.sh | 11 ++--- 6 files changed, 134 insertions(+), 18 deletions(-) create mode 100755 pascal-api-examples/streaming-asr/run-zipformer-ctc-hlg.sh create mode 100755 pascal-api-examples/streaming-asr/run-zipformer-ctc.sh diff --git a/.github/workflows/pascal.yaml b/.github/workflows/pascal.yaml index 9ddab6936..92dba408e 100644 --- a/.github/workflows/pascal.yaml +++ b/.github/workflows/pascal.yaml @@ -40,7 +40,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, macos-13] + os: [ubuntu-latest, macos-latest, macos-13, windows-latest] steps: - uses: actions/checkout@v4 @@ -65,10 +65,26 @@ jobs: run: | brew install fpc # brew install --cask lazarus + # + - name: Install Free pascal compiler (windows) + if: matrix.os == 'windows-latest' + shell: bash + run: | + choco install lazarus + ls -lh /c/lazarus/ + echo '--' + ls -lh /c/lazarus/fpc/ + echo '--' + ls -lh /c/lazarus/fpc/* + echo '--' + ls -lh /c/lazarus/fpc/*/* + + ls -lh /c/lazarus/fpc/3.2.2/bin/x86_64-win64/ - name: FPC info shell: bash run: | + export PATH=/c/lazarus/fpc/3.2.2/bin/x86_64-win64:$PATH which fpc fpc -i @@ -88,6 +104,7 @@ jobs: cd build cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ -D BUILD_SHARED_LIBS=ON \ -D SHERPA_ONNX_ENABLE_BINARY=OFF \ -D CMAKE_BUILD_TYPE=Release \ @@ -99,11 +116,23 @@ jobs: export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" cd build - make -j2 sherpa-onnx-c-api + cmake --build . --target install --config Release + + ls -lh install/lib/ + + if [[ ${{ matrix.os }} == 'windows-latest' ]]; then + cp -v install/lib/*.dll ../pascal-api-examples/read-wav + cp -v install/lib/*.dll ../pascal-api-examples/streaming-asr + + cp -v ../sherpa-onnx/pascal-api/sherpa_onnx.pas ../pascal-api-examples/read-wav + cp -v ../sherpa-onnx/pascal-api/sherpa_onnx.pas ../pascal-api-examples/streaming-asr + fi - name: Run Pascal test (Read wav test) shell: bash run: | + export PATH=/c/lazarus/fpc/3.2.2/bin/x86_64-win64:$PATH + cd ./pascal-api-examples pushd read-wav @@ -115,6 +144,9 @@ jobs: - name: Run Pascal test (Streaming ASR) shell: bash run: | + export PATH=/c/lazarus/fpc/3.2.2/bin/x86_64-win64:$PATH + + cd ./pascal-api-examples pushd streaming-asr diff --git a/pascal-api-examples/read-wav/run.sh b/pascal-api-examples/read-wav/run.sh index 60bb803c8..f71fbe909 100755 --- a/pascal-api-examples/read-wav/run.sh +++ b/pascal-api-examples/read-wav/run.sh @@ -7,10 +7,11 @@ SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" -if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/libsherpa-onnx-c-api.so ]]; then +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then mkdir -p ../../build pushd ../../build cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ -DSHERPA_ONNX_ENABLE_TESTS=OFF \ -DSHERPA_ONNX_ENABLE_CHECK=OFF \ @@ -18,8 +19,7 @@ if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/l -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ .. - make -j4 sherpa-onnx-c-api - ls -lh lib + cmake --build . --target install --config Release popd fi @@ -29,10 +29,10 @@ fi fpc \ -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ - -Fl$SHERPA_ONNX_DIR/build/lib \ + -Fl$SHERPA_ONNX_DIR/build/install/lib \ ./main.pas -export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$DYLD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH ./main diff --git a/pascal-api-examples/streaming-asr/run-paraformer.sh b/pascal-api-examples/streaming-asr/run-paraformer.sh index ff724ad25..aa6f056e3 100755 --- a/pascal-api-examples/streaming-asr/run-paraformer.sh +++ b/pascal-api-examples/streaming-asr/run-paraformer.sh @@ -7,10 +7,11 @@ SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" -if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/libsherpa-onnx-c-api.so ]]; then +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then mkdir -p ../../build pushd ../../build cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ -DSHERPA_ONNX_ENABLE_TESTS=OFF \ -DSHERPA_ONNX_ENABLE_CHECK=OFF \ @@ -18,7 +19,7 @@ if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/l -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ .. - make -j4 sherpa-onnx-c-api + cmake --build . --target install --config Release ls -lh lib popd fi @@ -32,10 +33,10 @@ fi fpc \ -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ - -Fl$SHERPA_ONNX_DIR/build/lib \ + -Fl$SHERPA_ONNX_DIR/build/install/lib \ ./paraformer.pas -export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$DYLD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH ./paraformer diff --git a/pascal-api-examples/streaming-asr/run-zipformer-ctc-hlg.sh b/pascal-api-examples/streaming-asr/run-zipformer-ctc-hlg.sh new file mode 100755 index 000000000..e0d97508c --- /dev/null +++ b/pascal-api-examples/streaming-asr/run-zipformer-ctc-hlg.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -ex + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) + +echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" + +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then + mkdir -p ../../build + pushd ../../build + cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ + .. + + cmake --build . --target install --config Release + ls -lh lib + popd +fi + +if [ ! -f ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt ]; then + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 + tar xvf sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 + rm sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 +fi + +fpc \ + -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ + -Fl$SHERPA_ONNX_DIR/build/install/lib \ + ./zipformer_ctc_hlg.pas + +export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH + +./zipformer_ctc_hlg diff --git a/pascal-api-examples/streaming-asr/run-zipformer-ctc.sh b/pascal-api-examples/streaming-asr/run-zipformer-ctc.sh new file mode 100755 index 000000000..4892c1aec --- /dev/null +++ b/pascal-api-examples/streaming-asr/run-zipformer-ctc.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -ex + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) + +echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" + +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then + mkdir -p ../../build + pushd ../../build + cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ + .. + + cmake --build . --target install --config Release + ls -lh lib + popd +fi + +if [ ! -f ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/tokens.txt ]; then + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 + tar xvf sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 + rm sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2 +fi + +fpc \ + -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ + -Fl$SHERPA_ONNX_DIR/build/install/lib \ + ./zipformer_ctc.pas + +export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH + +./zipformer_ctc diff --git a/pascal-api-examples/streaming-asr/run-zipformer-transducer.sh b/pascal-api-examples/streaming-asr/run-zipformer-transducer.sh index 1089c076a..ddcce7816 100755 --- a/pascal-api-examples/streaming-asr/run-zipformer-transducer.sh +++ b/pascal-api-examples/streaming-asr/run-zipformer-transducer.sh @@ -7,10 +7,11 @@ SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd) echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR" -if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/libsherpa-onnx-c-api.so ]]; then +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then mkdir -p ../../build pushd ../../build cmake \ + -DCMAKE_INSTALL_PREFIX=./install \ -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ -DSHERPA_ONNX_ENABLE_TESTS=OFF \ -DSHERPA_ONNX_ENABLE_CHECK=OFF \ @@ -18,7 +19,7 @@ if [[ ! -f ../../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/lib/l -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ .. - make -j4 sherpa-onnx-c-api + cmake --build . --target install --config Release ls -lh lib popd fi @@ -32,10 +33,10 @@ fi fpc \ -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \ - -Fl$SHERPA_ONNX_DIR/build/lib \ + -Fl$SHERPA_ONNX_DIR/build/install/lib \ ./zipformer_transducer.pas -export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/lib:$DYLD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH ./zipformer_transducer