mirror of
https://github.com/k2-fsa/sherpa-onnx.git
synced 2026-11-10 21:11:03 +08:00
Fixes #3731 espeak-ng and piper-phonemize are no longer built into sherpa-onnx. Text frontends are now: - **lexicon** — built in, no extra dependency - **phonemize** — phonemize outside sherpa-onnx (e.g. [piper-phonemize](https://github.com/csukuangfj/piper-phonemize)) and pass the result in. That library is GPL, so it stays optional: sherpa-onnx is GPL-free after this PR. ## API - `SherpaOnnxGenerationConfig` gains `phoneme_codepoints` and `tokens` (mutually exclusive alternatives to `text`) - `data_dir` on the TTS model configs is deprecated and ignored; the ABI slot is kept - all bindings updated: C/C++, Python, Java, Kotlin, Go, Rust, C#, Swift, Pascal, Dart/Flutter, node-addon, WASM, HarmonyOS
458 lines
13 KiB
YAML
458 lines
13 KiB
YAML
name: build-wheels-armv7l
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- wheel
|
|
workflow_dispatch:
|
|
inputs:
|
|
publish_sherpa_onnx_bin:
|
|
description: "Publish sherpa-onnx-bin"
|
|
required: false
|
|
default: "true"
|
|
type: boolean
|
|
|
|
env:
|
|
SHERPA_ONNX_IS_IN_GITHUB_ACTIONS: 1
|
|
|
|
concurrency:
|
|
group: build-wheels-armv7-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
core:
|
|
name: core
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Update version
|
|
shell: bash
|
|
run: |
|
|
./new-release.sh
|
|
git diff .
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: arm
|
|
|
|
- name: Display PWD
|
|
shell: bash
|
|
run: |
|
|
echo "pwd: $PWD"
|
|
ls -lh
|
|
du -h -d1 .
|
|
|
|
- name: Build sherpa-onnx
|
|
shell: bash
|
|
run: |
|
|
docker run --rm \
|
|
--platform linux/arm/v7 \
|
|
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx \
|
|
quay.io/pypa/manylinux_2_35_armv7l \
|
|
bash -c '
|
|
find / -name "*gcc*" 2>/dev/null
|
|
|
|
uname -a
|
|
gcc --version
|
|
cmake --version
|
|
cat /etc/*release
|
|
id
|
|
pwd
|
|
|
|
cd /home/runner/work/sherpa-onnx/sherpa-onnx
|
|
|
|
# find /opt -name "python*"
|
|
|
|
echo "--------------------"
|
|
PY_PATH=$(echo /opt/_internal/cpython-3.10*/bin)
|
|
export PATH=$PY_PATH:$PATH
|
|
which python3
|
|
python3 --version
|
|
|
|
python3 -m venv my
|
|
|
|
source ./my/bin/activate
|
|
|
|
python3 -m pip install setuptools wheel twine
|
|
|
|
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
|
|
pushd build
|
|
|
|
cmake \
|
|
-D SHERPA_ONNX_ENABLE_TTS=ON \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
-D BUILD_SHARED_LIBS=ON \
|
|
-D SHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
|
|
-D CMAKE_INSTALL_PREFIX=./install \
|
|
..
|
|
|
|
make -j2
|
|
make install
|
|
|
|
ls -lh lib
|
|
ls -lh bin
|
|
|
|
echo "----"
|
|
ls -lh install/lib
|
|
|
|
file install/lib/*
|
|
|
|
echo "----"
|
|
ls -lh install/bin
|
|
|
|
file install/bin/*
|
|
|
|
./install/bin/sherpa-onnx --help
|
|
|
|
echo "sherpa-onnx-core"
|
|
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
|
|
cp -v ./install/lib/lib*.so ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/lib
|
|
|
|
mkdir -p ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
|
|
cp -v ./install/include/sherpa-onnx/c-api/*.h ../scripts/wheel/sherpa-onnx-core/sherpa_onnx/include/sherpa-onnx/c-api
|
|
|
|
pushd ../scripts/wheel/sherpa-onnx-core
|
|
python3 setup.py bdist_wheel --plat-name=manylinux_2_35_armv7l
|
|
|
|
ls -lh dist
|
|
|
|
popd
|
|
|
|
echo "sherpa-onnx-bin"
|
|
|
|
mkdir -p ../scripts/wheel/sherpa-onnx-bin/bin
|
|
cp -v ./install/bin/sherpa-onnx* ../scripts/wheel/sherpa-onnx-bin/bin
|
|
|
|
pushd ../scripts/wheel/sherpa-onnx-bin
|
|
python3 setup.py bdist_wheel --plat-name=manylinux_2_35_armv7l
|
|
|
|
ls -lh dist
|
|
|
|
popd
|
|
'
|
|
|
|
- name: Collect wheels
|
|
shell: bash
|
|
run: |
|
|
sudo chown -R $USER ./scripts/wheel
|
|
mkdir wheelhouse
|
|
cp -v ./scripts/wheel/sherpa-onnx-core/dist/*.whl ./wheelhouse
|
|
cp -v ./scripts/wheel/sherpa-onnx-bin/dist/*.whl ./wheelhouse
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheels-core-linux-armv7l
|
|
path: ./wheelhouse/*.whl
|
|
|
|
- name: Show wheels
|
|
shell: bash
|
|
run: |
|
|
sudo chown -R $USER ./scripts/wheel
|
|
ls -lh ./scripts/wheel/sherpa-onnx-core/dist
|
|
ls -lh ./scripts/wheel/sherpa-onnx-bin/dist
|
|
|
|
unzip -l ./scripts/wheel/sherpa-onnx-core/dist/*.whl
|
|
echo "---"
|
|
unzip -l ./scripts/wheel/sherpa-onnx-bin/dist/*.whl
|
|
|
|
- name: Install patchelf
|
|
shell: bash
|
|
run: |
|
|
pip install patchelf
|
|
patchelf --version
|
|
|
|
- name: Patch wheels
|
|
shell: bash
|
|
run: |
|
|
mkdir ./wheels
|
|
sudo ./scripts/wheel/patch_wheel.py --in-dir ./wheelhouse --out-dir ./wheels
|
|
|
|
ls -lh ./wheels/
|
|
rm -rf ./wheelhouse
|
|
mv ./wheels ./wheelhouse
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheels-core-linux-armv7l-patched
|
|
path: ./wheelhouse/*.whl
|
|
|
|
test:
|
|
name: test
|
|
needs: [core]
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Retrieve artifact from Linux
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: wheels-core-linux-armv7l-patched
|
|
path: /tmp/wheels
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.10"
|
|
|
|
- name: Show
|
|
shell: bash
|
|
run: |
|
|
ls -lh /tmp/wheels
|
|
|
|
- name: Publish to huggingface
|
|
env:
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
max_attempts: 20
|
|
timeout_seconds: 200
|
|
shell: bash
|
|
command: |
|
|
git config --global user.email "csukuangfj@gmail.com"
|
|
git config --global user.name "Fangjun Kuang"
|
|
|
|
rm -rf huggingface
|
|
export GIT_LFS_SKIP_SMUDGE=1
|
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
|
|
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
|
|
|
d=cpu/$SHERPA_ONNX_VERSION
|
|
|
|
git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels huggingface
|
|
cd huggingface
|
|
git fetch
|
|
git pull
|
|
git merge -m "merge remote" --ff origin main
|
|
|
|
mkdir -p $d
|
|
|
|
cp -v /tmp/wheels/*.whl $d/
|
|
|
|
git status
|
|
git add .
|
|
git commit -m "add more wheels"
|
|
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels main
|
|
|
|
- name: Publish wheels to PyPI ${{ github.event.inputs.publish_sherpa_onnx_bin }}
|
|
if: ${{ (github.event.inputs.publish_sherpa_onnx_bin || 'true') == 'true' }}
|
|
env:
|
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
shell: bash
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install wheel twine==5.0.0 setuptools
|
|
|
|
twine upload --skip-existing --verbose /tmp/wheels/*.whl
|
|
|
|
|
|
build_wheels_armv7l:
|
|
name: ${{ matrix.manylinux }} ${{ matrix.python-version }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# see https://github.com/pypa/cibuildwheel/issues/2257
|
|
# we don't use qemu from now on
|
|
os: [ubuntu-latest]
|
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
manylinux: [manylinux_2_35] #, manylinux_2_28]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Update version
|
|
shell: bash
|
|
run: |
|
|
./new-release.sh
|
|
git diff .
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: arm
|
|
|
|
- name: Build sherpa-onnx
|
|
shell: bash
|
|
run: |
|
|
docker run --rm \
|
|
--platform linux/arm/v7 \
|
|
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx \
|
|
quay.io/pypa/manylinux_2_35_armv7l${{ matrix.python-version == '3.8' && ':2025.11.29-1' || '' }} \
|
|
bash -c '
|
|
find / -name "*gcc*" 2>/dev/null
|
|
|
|
uname -a
|
|
gcc --version
|
|
cmake --version
|
|
cat /etc/*release
|
|
id
|
|
pwd
|
|
|
|
python_version=${{ matrix.python-version }}
|
|
|
|
cd /home/runner/work/sherpa-onnx/sherpa-onnx
|
|
|
|
# find /opt -name "python*"
|
|
|
|
echo "--------------------"
|
|
# Construct glob pattern
|
|
PY_GLOB="/opt/_internal/cpython-${python_version}*/bin"
|
|
|
|
# Expand the glob safely
|
|
shopt -s nullglob # Avoid literal string if no match
|
|
matches=($PY_GLOB)
|
|
shopt -u nullglob
|
|
|
|
if [[ ${#matches[@]} -eq 0 ]]; then
|
|
echo "No Python installation found for version $python_version"
|
|
exit 1
|
|
elif [[ ${#matches[@]} -gt 1 ]]; then
|
|
echo "Multiple Python installations found for version $python_version:"
|
|
printf " %s\n" "${matches[@]}"
|
|
echo "Using the first one: ${matches[0]}"
|
|
fi
|
|
|
|
PY_PATH="${matches[0]}"
|
|
|
|
echo "$PY_PATH"
|
|
export PATH="$PY_PATH:$PATH"
|
|
echo $PY_PATH
|
|
export PATH=$PY_PATH:$PATH
|
|
which python3
|
|
python3 --version
|
|
|
|
python3 -m venv my
|
|
|
|
source ./my/bin/activate
|
|
|
|
python3 -m pip install setuptools wheel twine
|
|
|
|
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
|
|
pushd alsa-lib
|
|
./gitcompile
|
|
popd
|
|
|
|
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
|
|
echo "SHERPA_ONNX_ALSA_LIB_DIR: $SHERPA_ONNX_ALSA_LIB_DIR"
|
|
|
|
export LD_LIBRARY_PATH=$PWD/build/bdist.linux-aarch64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR:$LD_LIBRARY_PATH
|
|
export LIBRARY_PATH=$PWD/build/bdist.linux-aarch64/wheel/sherpa_onnx/lib:$SHERPA_ONNX_ALSA_LIB_DIR:$LIBRARY_PATH
|
|
|
|
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
|
|
echo "LIBRARY_PATH: $LIBRARY_PATH"
|
|
|
|
export C_INCLUDE_PATH=$PWD/alsa-lib/include:$C_INCLUDE_PATH
|
|
export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
|
|
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
|
|
|
|
export SHERPA_ONNX_MAKE_ARGS="VERBOSE=1"
|
|
export SHERPA_ONNX_ENABLE_ALSA=1
|
|
export SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_C_FLAGS=\"-march=armv7-a -mfloat-abi=hard -mfpu=neon\" -DCMAKE_CXX_FLAGS=\"-march=armv7-a -mfloat-abi=hard -mfpu=neon\" -DSHERPA_ONNX_ENABLE_BINARY=OFF -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF -DSHERPA_ONNX_ENABLE_C_API=ON -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF -DALSA_INCLUDE_DIR=$p/alsa-lib/include -DALSA_LIBRARY=$p/alsa-lib/src/.libs/libasound.so"
|
|
python3 setup.py bdist_wheel
|
|
ls -lh dist
|
|
|
|
mkdir wheelhouse
|
|
cp -v dist/* wheelhouse/
|
|
'
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheel-${{ matrix.python-version }}-${{ matrix.manylinux }}-linux-armv7l
|
|
path: ./wheelhouse/*.whl
|
|
|
|
- name: Display wheels
|
|
shell: bash
|
|
run: |
|
|
ls -lh ./wheelhouse/
|
|
|
|
- name: Show wheels
|
|
shell: bash
|
|
run: |
|
|
ls -lh wheelhouse/*.whl
|
|
|
|
unzip -l wheelhouse/*.whl
|
|
|
|
echo "---"
|
|
|
|
mkdir t
|
|
cp wheelhouse/*.whl ./t
|
|
cd ./t
|
|
unzip ./*.whl
|
|
ls -lh
|
|
echo "---"
|
|
|
|
readelf -d sherpa_onnx/lib/*.so
|
|
|
|
- name: Publish to huggingface
|
|
env:
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
max_attempts: 20
|
|
timeout_seconds: 200
|
|
shell: bash
|
|
command: |
|
|
git config --global user.email "csukuangfj@gmail.com"
|
|
git config --global user.name "Fangjun Kuang"
|
|
|
|
rm -rf huggingface
|
|
export GIT_LFS_SKIP_SMUDGE=1
|
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
|
|
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
|
|
|
d=cpu/$SHERPA_ONNX_VERSION
|
|
|
|
git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels huggingface
|
|
cd huggingface
|
|
git fetch
|
|
git pull
|
|
git merge -m "merge remote" --ff origin main
|
|
|
|
mkdir -p $d
|
|
|
|
cp -v ../wheelhouse/*.whl $d/
|
|
|
|
git status
|
|
git add .
|
|
git commit -m "add more wheels"
|
|
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-wheels main
|
|
|
|
- name: Publish wheels to PyPI
|
|
env:
|
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install wheel twine==5.0.0 setuptools
|
|
|
|
twine upload --skip-existing --verbose ./wheelhouse/*.whl
|