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
191 lines
7.3 KiB
YAML
191 lines
7.3 KiB
YAML
name: test-dart
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dart-api
|
|
- dart
|
|
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: test-dart-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test_dart:
|
|
name: ${{ matrix.os }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm, windows-2022, windows-11-arm]
|
|
include:
|
|
- os: windows-2022
|
|
win_arch: x64
|
|
cmake_extra_args: ""
|
|
- os: windows-11-arm
|
|
win_arch: arm64
|
|
cmake_extra_args: "-A ARM64"
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Clean stale onnxruntime (Windows)
|
|
if: startsWith(matrix.os, 'windows')
|
|
shell: bash
|
|
run: |
|
|
echo "Searching for stale onnxruntime.dll..."
|
|
search_dirs=(
|
|
"/c/Windows/System32"
|
|
"/c/Program Files"
|
|
"/c/Program Files (x86)"
|
|
"/c/Users"
|
|
"/c/hostedtoolcache"
|
|
)
|
|
count=0
|
|
for dir in "${search_dirs[@]}"; do
|
|
if [ -d "$dir" ]; then
|
|
while IFS= read -r f; do
|
|
[ -z "$f" ] && continue
|
|
echo "Deleting: $f"
|
|
rm -f "$f" || true
|
|
count=$((count + 1))
|
|
done < <(find "$dir" -name "onnxruntime.dll" -type f 2>/dev/null || true)
|
|
fi
|
|
done
|
|
if [ "$count" -eq 0 ]; then
|
|
echo "No stale onnxruntime.dll found"
|
|
else
|
|
echo "Deleted $count onnxruntime.dll file(s)"
|
|
fi
|
|
|
|
- name: Update version
|
|
shell: bash
|
|
run: |
|
|
./new-release.sh
|
|
git diff .
|
|
|
|
- name: Set up MSVC (Windows ARM64)
|
|
if: matrix.os == 'windows-11-arm'
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: ccache
|
|
if: "!startsWith(matrix.os, 'windows')"
|
|
uses: hendrikmuhs/ccache-action@v1.2
|
|
with:
|
|
key: ${{ matrix.os }}-dart
|
|
|
|
# see https://github.com/subosito/flutter-action/issues/345
|
|
- name: Set up Dart (ARM64)
|
|
if: matrix.os == 'windows-11-arm'
|
|
uses: dart-lang/setup-dart@v1
|
|
with:
|
|
sdk: stable
|
|
|
|
- name: Set up Flutter
|
|
if: matrix.os != 'windows-11-arm'
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
channel: master
|
|
flutter-version: 3.24.0
|
|
|
|
- name: Display info
|
|
shell: bash
|
|
run: |
|
|
which dart
|
|
dart --version
|
|
if command -v flutter &> /dev/null; then
|
|
which flutter
|
|
flutter --version
|
|
flutter doctor
|
|
fi
|
|
|
|
- name: Build sherpa-onnx
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.os }}" != windows* ]]; then
|
|
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
|
fi
|
|
cmake --version
|
|
|
|
if [[ "${{ matrix.os }}" == macos-latest ]]; then
|
|
./build-macos-shared-sherpa-with-static-onnxruntime.sh
|
|
else
|
|
mkdir build
|
|
cd build
|
|
|
|
cmake \
|
|
${{ matrix.cmake_extra_args }} \
|
|
-DBUILD_SHARED_LIBS=ON \
|
|
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
|
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
|
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
|
|
-DCMAKE_INSTALL_PREFIX=./install \
|
|
..
|
|
|
|
cmake --build . --target install --config Release
|
|
fi
|
|
|
|
- name: Copy libs
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.os }}" == ubuntu-latest ]]; then
|
|
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/x64
|
|
ls -lh ./flutter/sherpa_onnx_linux/linux/x64
|
|
elif [[ "${{ matrix.os }}" == ubuntu-24.04-arm ]]; then
|
|
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/aarch64
|
|
ls -lh ./flutter/sherpa_onnx_linux/linux/aarch64
|
|
elif [[ "${{ matrix.os }}" == macos-latest ]]; then
|
|
cp -av build-macos-shared-sherpa-with-static-onnxruntime/sherpa-onnx.xcframework flutter/sherpa_onnx_macos/macos/sherpa_onnx_macos/sherpa-onnx.xcframework
|
|
ls -lh ./flutter/sherpa_onnx_macos/macos/sherpa_onnx_macos/sherpa-onnx.xcframework/
|
|
elif [[ "${{ matrix.os }}" == windows* ]]; then
|
|
cp -fv build/install/lib/*.dll ./flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}
|
|
echo "Contents of flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}/:"
|
|
ls -lh ./flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}/
|
|
echo "Checking DLL dependencies with objdump:"
|
|
objdump -p ./flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}/sherpa-onnx-c-api.dll | grep -i "DLL Name" || true
|
|
fi
|
|
|
|
- name: Run tests
|
|
shell: bash
|
|
run: |
|
|
# Add DLL directory to PATH on Windows so onnxruntime.dll is found
|
|
if [[ "${{ matrix.os }}" == windows* ]]; then
|
|
export PATH="$PWD/flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}:$PATH"
|
|
echo "PATH includes: $PWD/flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}"
|
|
echo "Checking DLLs in flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}/:"
|
|
ls -lh flutter/sherpa_onnx_windows/windows/${{ matrix.win_arch }}/
|
|
fi
|
|
|
|
cp scripts/dart/vad-pubspec.yaml dart-api-examples/vad/pubspec.yaml
|
|
cp scripts/dart/non-streaming-asr-pubspec.yaml dart-api-examples/non-streaming-asr/pubspec.yaml
|
|
cp scripts/dart/streaming-asr-pubspec.yaml dart-api-examples/streaming-asr/pubspec.yaml
|
|
cp scripts/dart/tts-pubspec.yaml dart-api-examples/tts/pubspec.yaml
|
|
cp scripts/dart/kws-pubspec.yaml dart-api-examples/keyword-spotter/pubspec.yaml
|
|
cp scripts/dart/vad-non-streaming-asr-pubspec.yaml dart-api-examples/vad-with-non-streaming-asr/pubspec.yaml
|
|
cp scripts/dart/audio-tagging-pubspec.yaml dart-api-examples/audio-tagging/pubspec.yaml
|
|
cp scripts/dart/add-punctuations-pubspec.yaml dart-api-examples/add-punctuations/pubspec.yaml
|
|
cp scripts/dart/speaker-id-pubspec.yaml dart-api-examples/speaker-identification/pubspec.yaml
|
|
cp scripts/dart/speaker-diarization-pubspec.yaml dart-api-examples/speaker-diarization/pubspec.yaml
|
|
cp scripts/dart/speech-enhancement-gtcrn-pubspec.yaml dart-api-examples/speech-enhancement-gtcrn/pubspec.yaml
|
|
cp scripts/dart/speech-enhancement-dpdfnet-pubspec.yaml dart-api-examples/speech-enhancement-dpdfnet/pubspec.yaml
|
|
cp scripts/dart/streaming-speech-enhancement-gtcrn-pubspec.yaml dart-api-examples/streaming-speech-enhancement-gtcrn/pubspec.yaml
|
|
cp scripts/dart/streaming-speech-enhancement-dpdfnet-pubspec.yaml dart-api-examples/streaming-speech-enhancement-dpdfnet/pubspec.yaml
|
|
cp scripts/dart/slid-pubspec.yaml dart-api-examples/spoken-language-identification/pubspec.yaml
|
|
cp scripts/dart/version-pubspec.yaml dart-api-examples/version/pubspec.yaml
|
|
|
|
cp scripts/dart/sherpa-onnx-pubspec.yaml flutter/sherpa_onnx/pubspec.yaml
|
|
|
|
.github/scripts/test-dart.sh
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tts-waves-${{ matrix.os }}
|
|
path: dart-api-examples/tts/*.wav
|
|
if-no-files-found: warn
|