diff --git a/.github/workflows/aarch64-linux-gnu-shared.yaml b/.github/workflows/aarch64-linux-gnu-shared.yaml index 18516452..5e867530 100644 --- a/.github/workflows/aarch64-linux-gnu-shared.yaml +++ b/.github/workflows/aarch64-linux-gnu-shared.yaml @@ -37,13 +37,13 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest + - os: ubuntu-22.04-arm gpu: ON onnxruntime_version: "1.11.0" - - os: ubuntu-latest + - os: ubuntu-22.04-arm gpu: ON onnxruntime_version: "1.16.0" - - os: ubuntu-latest + - os: ubuntu-22.04-arm gpu: OFF onnxruntime_version: "" @@ -52,154 +52,107 @@ jobs: with: fetch-depth: 0 - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ matrix.os }}-aarch64-shared - - - name: cache-qemu - id: cache-qemu - uses: actions/cache@v4 - with: - path: qemu-install - key: qemu-aarch64-install-20220908 - - - name: install-qemu-build-deps - if: steps.cache-qemu.outputs.cache-hit != 'true' - run: | - sudo apt-get update - sudo apt-get install autoconf automake autotools-dev ninja-build libglib2.0-dev. - - - name: checkout-qemu - if: steps.cache-qemu.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: qemu/qemu - path: qemu - ref: f5643914a9e8f79c606a76e6a9d7ea82a3fc3e65 - - - name: qemu - if: steps.cache-qemu.outputs.cache-hit != 'true' - run: | - cd qemu - ./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=aarch64-linux-user --disable-system - make -j2 - make install - - - name: cache-toolchain (CPU) - if: matrix.gpu == 'OFF' - id: cache-toolchain-cpu - uses: actions/cache@v4 - with: - path: toolchain - key: gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz - - - name: cache-toolchain (GPU) + - name: Build sherpa-onnx if: matrix.gpu == 'ON' - id: cache-toolchain-gpu - uses: actions/cache@v4 + shell: bash + run: | + onnxruntime_version=${{ matrix.onnxruntime_version }} + + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib + pushd alsa-lib + ./gitcompile + popd + + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs + + mkdir build + cd build + cmake \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX=./install \ + -DSHERPA_ONNX_ENABLE_GPU=ON \ + -DSHERPA_ONNX_LINUX_ARM64_GPU_ONNXRUNTIME_VERSION=$onnxruntime_version \ + .. + make -j4 install + + rm -rf install/lib/pkgconfig + rm -fv install/lib/cargs.h + rm -fv install/lib/libcargs.so + + - name: Build sherpa-onnx + if: matrix.gpu == 'OFF' + uses: addnab/docker-run-action@v3 with: - path: toolchain - key: gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz + image: quay.io/pypa/manylinux2014_aarch64 + options: | + --volume ${{ github.workspace }}/:/k2-fsa/sherpa-onnx + shell: bash + run: | + echo "config: ${{ matrix.config }}" + uname -a + which gcc - - name: Download toolchain (CPU, gcc 7.5) - if: steps.cache-toolchain-cpu.outputs.cache-hit != 'true' && matrix.gpu == 'OFF' + gcc --version + g++ --version + + echo "pwd" + + ls -lh + + cd /k2-fsa/sherpa-onnx/ + + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib + pushd alsa-lib + ./gitcompile + popd + + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs + + mkdir build + cd build + + cmake \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX=./install \ + .. + + make -j4 install + + rm -rf install/lib/pkgconfig + rm -fv install/lib/cargs.h + rm -fv install/lib/libcargs.so + + - name: Display system info shell: bash run: | - wget -qq https://huggingface.co/csukuangfj/sherpa-ncnn-toolchains/resolve/main/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz + uname -a + gcc --version + g++ --version - mkdir $GITHUB_WORKSPACE/toolchain - tar xf ./gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain - - - name: Download toolchain (GPU, gcc 10.3) - if: steps.cache-toolchain-gpu.outputs.cache-hit != 'true' && matrix.gpu == 'ON' + - name: Display generated files shell: bash run: | - wget -qq https://huggingface.co/csukuangfj/sherpa-ncnn-toolchains/resolve/main/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz + cd build/install - mkdir $GITHUB_WORKSPACE/toolchain - tar xf ./gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain + ls -lh bin - - name: Set environment variable - if: steps.cache-build-result.outputs.cache-hit != 'true' - shell: bash - run: | - echo "$GITHUB_WORKSPACE/toolchain/bin" >> "$GITHUB_PATH" - echo "$GITHUB_WORKSPACE/bin" >> "$GITHUB_PATH" - ls -lh "$GITHUB_WORKSPACE/toolchain/bin" + echo "---" - if [[ ${{ matrix.gpu }} == OFF ]]; then - echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" - echo "CXX=aarch64-linux-gnu-g++" >> "$GITHUB_ENV" - else - echo "CC=aarch64-none-linux-gnu-gcc" >> "$GITHUB_ENV" - echo "CXX=aarch64-none-linux-gnu-g++" >> "$GITHUB_ENV" - fi + ls -lh lib - - name: Display toolchain info - shell: bash - run: | - if [[ ${{ matrix.gpu }} == OFF ]]; then - which aarch64-linux-gnu-gcc - aarch64-linux-gnu-gcc --version - else - which aarch64-none-linux-gnu-gcc - aarch64-none-linux-gnu-gcc --version - fi + file bin/sherpa-onnx - - name: Display qemu-aarch64 -h - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-linux-gnu/libc - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-none-linux-gnu/libc - qemu-aarch64 -h + readelf -d bin/sherpa-onnx - - name: build aarch64-linux-gnu - shell: bash - run: | - export CMAKE_CXX_COMPILER_LAUNCHER=ccache - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + ldd bin/sherpa-onnx - cmake --version - - export BUILD_SHARED_LIBS=ON - export SHERPA_ONNX_ENABLE_GPU=${{ matrix.gpu }} - export SHERPA_ONNX_LINUX_ARM64_GPU_ONNXRUNTIME_VERSION=${{ matrix.onnxruntime_version }} - - ./build-aarch64-linux-gnu.sh - - ls -lh build-aarch64-linux-gnu/bin - ls -lh build-aarch64-linux-gnu/lib - - file build-aarch64-linux-gnu/bin/sherpa-onnx - - - name: Test sherpa-onnx - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH - if [[ ${{ matrix.gpu }} == OFF ]]; then - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-linux-gnu/libc - else - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-none-linux-gnu/libc - fi - - ls -lh ./build-aarch64-linux-gnu/bin - - qemu-aarch64 ./build-aarch64-linux-gnu/bin/sherpa-onnx --help - - readelf -d ./build-aarch64-linux-gnu/bin/sherpa-onnx + ./bin/sherpa-onnx --help - name: Copy files shell: bash run: | - if [[ ${{ matrix.gpu }} == OFF ]]; then - aarch64-linux-gnu-strip --version - else - aarch64-none-linux-gnu-strip --version - fi - SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-shared @@ -210,19 +163,18 @@ jobs: fi mkdir $dst - cp -a build-aarch64-linux-gnu/install/bin $dst/ - cp -a build-aarch64-linux-gnu/install/lib $dst/ + cp -a build/install/bin $dst/ + cp -a build/install/lib $dst/ - ls -lh build-aarch64-linux-gnu/install/lib - ls -lh build-aarch64-linux-gnu/install/bin + ls -lh build/install/lib + ls -lh build/install/bin ls -lh $dst/bin/ echo "strip" - if [[ ${{ matrix.gpu }} == OFF ]]; then - aarch64-linux-gnu-strip $dst/bin/* - else - aarch64-none-linux-gnu-strip $dst/bin/* - fi + strip $dst/bin/* + + echo "after strip" + ls -lh $dst/bin/ tree $dst @@ -266,9 +218,32 @@ jobs: git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main - name: Release pre-compiled binaries and libs for aarch64 linux - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 with: file_glob: true overwrite: true file: sherpa-onnx-*linux-aarch64*.tar.bz2 + + - name: Release pre-compiled binaries and libs for aarch64 linux + if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + file_glob: true + overwrite: true + file: sherpa-onnx-*linux-aarch64*.tar.bz2 + # repo_name: k2-fsa/sherpa-onnx + # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} + # tag: v1.10.42 + + - name: Test offline Moonshine + if: matrix.build_type != 'Debug' + shell: bash + run: | + du -h -d1 . + export PATH=$PWD/build/install/bin:$PATH + export EXE=sherpa-onnx-offline + + readelf -d build/bin/sherpa-onnx-offline + + .github/scripts/test-offline-moonshine.sh diff --git a/.github/workflows/aarch64-linux-gnu-static.yaml b/.github/workflows/aarch64-linux-gnu-static.yaml index 66ce6ec2..48b0bbe2 100644 --- a/.github/workflows/aarch64-linux-gnu-static.yaml +++ b/.github/workflows/aarch64-linux-gnu-static.yaml @@ -36,125 +36,72 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-22.04-arm] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + - name: Build sherpa-onnx + uses: addnab/docker-run-action@v3 with: - key: ${{ matrix.os }}-aarch64-static + image: quay.io/pypa/manylinux2014_aarch64 + options: | + --volume ${{ github.workspace }}/:/k2-fsa/sherpa-onnx + shell: bash + run: | + echo "config: ${{ matrix.config }}" + uname -a + which gcc - - name: cache-qemu - id: cache-qemu - uses: actions/cache@v4 - with: - path: qemu-install - key: qemu-aarch64-install-20220908 + gcc --version + g++ --version - - name: install-qemu-build-deps - if: steps.cache-qemu.outputs.cache-hit != 'true' - run: | - sudo apt-get update - sudo apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev ninja-build + echo "pwd" - - name: checkout-qemu - if: steps.cache-qemu.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: qemu/qemu - path: qemu - ref: f5643914a9e8f79c606a76e6a9d7ea82a3fc3e65 + ls -lh - - name: qemu - if: steps.cache-qemu.outputs.cache-hit != 'true' - run: | - cd qemu - ./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=aarch64-linux-user --disable-system - make -j2 - make install + cd /k2-fsa/sherpa-onnx/ - - name: cache-toolchain - id: cache-toolchain - uses: actions/cache@v4 - with: - path: toolchain - key: gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz + git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib + pushd alsa-lib + ./gitcompile + popd - - name: Download toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - shell: bash - run: | - wget -qq https://huggingface.co/csukuangfj/sherpa-ncnn-toolchains/resolve/main/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz + export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH + export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs - mkdir $GITHUB_WORKSPACE/toolchain - tar xf ./gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz --strip-components 1 -C $GITHUB_WORKSPACE/toolchain + mkdir build + cd build + cmake \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_INSTALL_PREFIX=./install \ + .. - - name: Display toolchain info - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH - aarch64-none-linux-gnu-gcc --version + make -j 4 - - name: Display qemu-aarch64 -h - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-none-linux-gnu/libc - qemu-aarch64 -h + make install - - name: build aarch64-linux-gnu - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH + ls -lh install/lib - export CMAKE_CXX_COMPILER_LAUNCHER=ccache - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - - cmake --version - - export BUILD_SHARED_LIBS=OFF - - ./build-aarch64-linux-gnu.sh - - ls -lh build-aarch64-linux-gnu/bin - ls -lh build-aarch64-linux-gnu/lib - - file build-aarch64-linux-gnu/bin/sherpa-onnx - - - name: Test sherpa-onnx - shell: bash - run: | - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/aarch64-none-linux-gnu/libc - - ls -lh ./build-aarch64-linux-gnu/bin - - qemu-aarch64 ./build-aarch64-linux-gnu/bin/sherpa-onnx --help - - readelf -d ./build-aarch64-linux-gnu/bin/sherpa-onnx + rm -rf install/lib/pkgconfig + rm -fv install/lib/cargs.h - name: Copy files shell: bash run: | - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH - aarch64-none-linux-gnu-strip --version - SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-aarch64-static mkdir $dst - ls -lh build-aarch64-linux-gnu/install/lib + ls -lh build/install/lib - cp -a build-aarch64-linux-gnu/install/bin $dst/ + cp -a build/install/bin $dst/ ls -lh $dst/bin/ echo "strip" - aarch64-none-linux-gnu-strip $dst/bin/* + strip $dst/bin/* ls -lh $dst/bin/ tree $dst @@ -199,9 +146,32 @@ jobs: git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main - name: Release pre-compiled binaries and libs for aarch64 linux - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 with: file_glob: true overwrite: true file: sherpa-onnx-*linux-aarch64*.tar.bz2 + + - name: Release pre-compiled binaries and libs for aarch64 linux + if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + file_glob: true + overwrite: true + file: sherpa-onnx-*linux-aarch64*.tar.bz2 + # repo_name: k2-fsa/sherpa-onnx + # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} + # tag: v1.10.42 + + - name: Test offline Moonshine + if: matrix.build_type != 'Debug' + shell: bash + run: | + du -h -d1 . + export PATH=$PWD/build/bin:$PATH + export EXE=sherpa-onnx-offline + + readelf -d build/bin/sherpa-onnx-offline + + .github/scripts/test-offline-moonshine.sh diff --git a/.github/workflows/linux-jni-aarch64.yaml b/.github/workflows/linux-jni-aarch64.yaml index 19d1e09c..4b1df3f5 100644 --- a/.github/workflows/linux-jni-aarch64.yaml +++ b/.github/workflows/linux-jni-aarch64.yaml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ubuntu-22.04-arm] # java-version: ['8', '11', '16', '17', '21'] java-version: ['21'] @@ -33,12 +33,6 @@ jobs: distribution: 'temurin' # See 'Supported distributions' for available options java-version: ${{ matrix.java-version }} - - name: Set up QEMU - if: steps.cache-build-result.outputs.cache-hit != 'true' - uses: docker/setup-qemu-action@v2 - with: - platforms: all - - name: Display PWD shell: bash run: | @@ -167,10 +161,20 @@ jobs: git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main - name: Release pre-compiled binaries and libs for linux aarch64 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.java-version == '21' + if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.java-version == '21' uses: svenstaro/upload-release-action@v2 with: file_glob: true overwrite: true file: sherpa-onnx-*.tar.bz2 + # repo_name: k2-fsa/sherpa-onnx + # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} + # tag: v1.10.42 + - name: Release pre-compiled binaries and libs for linux aarch64 + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.java-version == '21' + uses: svenstaro/upload-release-action@v2 + with: + file_glob: true + overwrite: true + file: sherpa-onnx-*.tar.bz2 diff --git a/harmony-os/SherpaOnnxHar/sherpa_onnx/BuildProfile.ets b/harmony-os/SherpaOnnxHar/sherpa_onnx/BuildProfile.ets index ea97166b..80ba0070 100644 --- a/harmony-os/SherpaOnnxHar/sherpa_onnx/BuildProfile.ets +++ b/harmony-os/SherpaOnnxHar/sherpa_onnx/BuildProfile.ets @@ -1,7 +1,7 @@ /** * Use these variables when you tailor your ArkTS code. They must be of the const type. */ -export const HAR_VERSION = '1.10.41'; +export const HAR_VERSION = '1.10.42'; export const BUILD_MODE_NAME = 'debug'; export const DEBUG = true; export const TARGET_NAME = 'default'; diff --git a/harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc b/harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc index 003bd3b7..145e7b0d 100644 --- a/harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc +++ b/harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/non-streaming-tts.cc @@ -146,7 +146,7 @@ static Napi::External CreateOfflineTtsWrapper( SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts); SHERPA_ONNX_ASSIGN_ATTR_INT32(max_num_sentences, maxNumSentences); SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars); - SHERPA_ONNX_ASSIGN_ATTR_STR(silence_scale, silenceScale); + SHERPA_ONNX_ASSIGN_ATTR_FLOAT(silence_scale, silenceScale); #if __OHOS__ std::unique_ptr