Refactor building xcframework for macOS and iOS (#3831)

This commit is contained in:
Fangjun Kuang authored and GitHub committed 2026-08-03 10:32:47 +08:00
1 parent 116a44e72c
commit 2e2659e937
86 files changed
+1653 -792

No files matched your search

+578 -178
View File
@@ -4,9 +4,8 @@ on:
push:
branches:
- master
- test-spm-2
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
- 'release-v[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:
@@ -15,133 +14,8 @@ concurrency:
cancel-in-progress: true
jobs:
build_ios_xcframework:
name: ios tts-${{ matrix.with_tts }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
with_tts: [ON, OFF]
steps:
- uses: actions/checkout@v4
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ios-tts-${{ matrix.with_tts }}
- name: Build iOS shared
# if: matrix.with_tts == 'ON'
if: false
shell: bash
run: |
export CMAKE_VERBOSE_MAKEFILE=ON
./build-ios-shared.sh
- name: Build iOS
if: matrix.with_tts == 'ON'
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-ios.sh
- name: Build iOS (No tts)
if: matrix.with_tts == 'OFF'
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-ios-no-tts.sh
- name: Display artifacts
if: matrix.with_tts == 'ON'
shell: bash
run: |
ls -lh build-ios/*.xcframework.zip
- name: Display artifacts
if: matrix.with_tts == 'OFF'
shell: bash
run: |
ls -lh build-ios-no-tts/*.xcframework.zip
- name: Upload xcframework.zip
if: matrix.with_tts == 'ON'
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-ios-xcframework
path: ./build-ios/*.xcframework.zip
- name: Upload xcframework.zip (no tts)
if: matrix.with_tts == 'OFF'
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-ios-no-tts-xcframework
path: ./build-ios-no-tts/*.xcframework.zip
- name: Release xcframework
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: ./build-ios*/*.xcframework.zip
- name: Release xcframework
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: ./build-ios*/*.xcframework.zip
# repo_name: k2-fsa/sherpa-onnx
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
# tag: v1.13.4
# https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
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_CLONE_PROTECTION_ACTIVE=false
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs huggingface
cd huggingface
cp -v ../build-ios*/*.xcframework.zip ./
git status
git lfs track "*.zip"
git add .
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
git commit -m "upload sherpa-onnx-${SHERPA_ONNX_VERSION} xcframework"
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs main
build_macos_xcframework:
name: macos
build_ios_static_xcframework:
name: ios-static
runs-on: macos-latest
steps:
@@ -156,73 +30,599 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: macos
key: ios-static
- name: Build macOS
- name: Build iOS static
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-swift-macos.sh
./build-ios.sh
- name: Display artifacts
shell: bash
run: |
ls -lh build-swift-macos/*.xcframework.zip
ls -lh build-ios/*.xcframework.zip
- name: Test xcframework
shell: bash
run: |
mkdir -p /tmp/test-xcframework
cd /tmp/test-xcframework
unzip -o $GITHUB_WORKSPACE/build-ios/*.xcframework.zip -d .
ls -lh sherpa-onnx.xcframework/
# Verify xcframework structure (framework bundle)
fw_path=$(find sherpa-onnx.xcframework -path "*simulator*" -name "SherpaOnnxC.framework" -type d | head -1)
echo "fw_path: $fw_path"
test -f "$fw_path/SherpaOnnxC" || { echo "Binary not found"; exit 1; }
test -f "$fw_path/Headers/sherpa-onnx/c-api/c-api.h" || { echo "Header not found"; exit 1; }
test -f "$fw_path/Modules/module.modulemap" || { echo "Modulemap not found"; exit 1; }
test -f "$fw_path/Info.plist" || { echo "Info.plist not found"; exit 1; }
echo "iOS static xcframework structure verified"
- name: Upload xcframework.zip
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-macos-xcframework
path: ./build-swift-macos/*.xcframework.zip
name: sherpa-onnx-ios-static-xcframework
path: ./build-ios/*.xcframework.zip
- name: Release xcframework
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
build_ios_shared_xcframework:
name: ios-shared
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ios-shared
- name: Build iOS shared
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-ios-shared.sh
- name: Display artifacts
shell: bash
run: |
ls -lh build-ios-shared/*.xcframework.zip
- name: Test xcframework
shell: bash
run: |
mkdir -p /tmp/test-xcframework
cd /tmp/test-xcframework
unzip -o $GITHUB_WORKSPACE/build-ios-shared/*.xcframework.zip -d .
ls -lh sherpa-onnx.xcframework/
# Verify xcframework structure (framework bundle)
fw_path=$(find sherpa-onnx.xcframework -path "*simulator*" -name "SherpaOnnxC.framework" -type d | head -1)
echo "fw_path: $fw_path"
test -f "$fw_path/SherpaOnnxC" || { echo "Binary not found"; exit 1; }
test -f "$fw_path/Headers/sherpa-onnx/c-api/c-api.h" || { echo "Header not found"; exit 1; }
test -f "$fw_path/Modules/module.modulemap" || { echo "Modulemap not found"; exit 1; }
test -f "$fw_path/Info.plist" || { echo "Info.plist not found"; exit 1; }
echo "iOS shared xcframework structure verified"
- name: Upload xcframework.zip
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-ios-shared-xcframework
path: ./build-ios-shared/*.xcframework.zip
build_macos_static_xcframework:
name: macos-static
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: macos-static
- name: Build macOS static
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-macos.sh
- name: Display artifacts
shell: bash
run: |
ls -lh build-macos/*.xcframework.zip
- name: Test xcframework
shell: bash
run: |
mkdir -p /tmp/test-xcframework
cd /tmp/test-xcframework
unzip -o $GITHUB_WORKSPACE/build-macos/*.xcframework.zip -d .
ls -lh sherpa-onnx.xcframework/
# Find the framework bundle
fw_path=$(find sherpa-onnx.xcframework -name "SherpaOnnxC.framework" -type d | head -1)
echo "fw_path: $fw_path"
test -f "$fw_path/Versions/A/SherpaOnnxC" || { echo "Binary not found"; exit 1; }
test -f "$fw_path/Versions/A/Headers/sherpa-onnx/c-api/c-api.h" || { echo "Header not found"; exit 1; }
test -f "$fw_path/Versions/A/Modules/module.modulemap" || { echo "Modulemap not found"; exit 1; }
# Use onnxruntime from the build directory
ort_lib=$GITHUB_WORKSPACE/build-macos/_deps/onnxruntime-src/lib
# Headers are at Headers/sherpa-onnx/c-api/c-api.h
# Include path should be Headers/ so #include "sherpa-onnx/c-api/c-api.h" works
clang -o version-c-api $GITHUB_WORKSPACE/c-api-examples/version-c-api.c \
-I "$fw_path/Headers" \
"$fw_path/Versions/A/SherpaOnnxC" \
-L "$ort_lib" \
-l onnxruntime \
-framework CoreFoundation \
-framework Foundation \
-lc++
./version-c-api
- name: Upload xcframework.zip
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-macos-static-xcframework
path: ./build-macos/*.xcframework.zip
build_macos_shared_xcframework:
name: macos-shared
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Update version
shell: bash
run: |
./new-release.sh
git diff .
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: macos-shared
- name: Build macOS shared
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
./build-macos-shared.sh
- name: Display build directory
shell: bash
run: |
ls -lh build-macos-shared
- name: Display artifacts
shell: bash
run: |
ls -lh build-macos-shared/*.xcframework.zip
unzip -l build-macos-shared/*.xcframework.zip
- name: Test xcframework
shell: bash
run: |
mkdir -p /tmp/test-xcframework
cd /tmp/test-xcframework
unzip -o $GITHUB_WORKSPACE/build-macos-shared/*.xcframework.zip -d .
ls -lh sherpa-onnx.xcframework/
# Find the framework bundle
fw_path=$(find sherpa-onnx.xcframework -name "SherpaOnnxC.framework" -type d | head -1)
echo "fw_path: $fw_path"
test -f "$fw_path/Versions/A/SherpaOnnxC" || { echo "Binary not found"; exit 1; }
test -f "$fw_path/Versions/A/Headers/sherpa-onnx/c-api/c-api.h" || { echo "Header not found"; exit 1; }
test -f "$fw_path/Versions/A/Modules/module.modulemap" || { echo "Modulemap not found"; exit 1; }
# Use onnxruntime from the build directory
ort_lib=$GITHUB_WORKSPACE/build-macos-shared/_deps/onnxruntime-src/lib
# Headers are at Headers/sherpa-onnx/c-api/c-api.h
# Include path should be Headers/ so #include "sherpa-onnx/c-api/c-api.h" works
# rpath must point to the directory containing SherpaOnnxC.framework/
fw_parent=$(dirname "$fw_path")
clang -o version-c-api $GITHUB_WORKSPACE/c-api-examples/version-c-api.c \
-I "$fw_path/Headers" \
"$fw_path/Versions/A/SherpaOnnxC" \
-L "$ort_lib" \
-l onnxruntime \
-lc++ \
-Wl,-rpath,"$fw_parent" \
-Wl,-rpath,"$ort_lib"
./version-c-api
- name: Upload xcframework.zip
uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-macos-shared-xcframework
path: ./build-macos-shared/*.xcframework.zip
test_spm:
name: test-spm
needs:
- build_ios_static_xcframework
- build_ios_shared_xcframework
- build_macos_static_xcframework
- build_macos_shared_xcframework
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Download xcframework artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Prepare local xcframeworks
shell: bash
run: |
set -euo pipefail
mkdir -p build-macos build-ios build-macos-shared build-ios-shared
# Extract static xcframeworks
unzip -o artifacts/sherpa-onnx-macos-static-xcframework/*.zip -d build-macos/
unzip -o artifacts/sherpa-onnx-ios-static-xcframework/*.zip -d build-ios/
# Extract shared xcframeworks
unzip -o artifacts/sherpa-onnx-macos-shared-xcframework/*.zip -d build-macos-shared/
unzip -o artifacts/sherpa-onnx-ios-shared-xcframework/*.zip -d build-ios-shared/
echo "=== macOS static xcframework ==="
ls -lh build-macos/sherpa-onnx.xcframework/
echo "=== iOS static xcframework ==="
ls -lh build-ios/sherpa-onnx.xcframework/
echo "=== macOS shared xcframework ==="
ls -lh build-macos-shared/sherpa-onnx.xcframework/
echo "=== iOS shared xcframework ==="
ls -lh build-ios-shared/sherpa-onnx.xcframework/
- name: Test SPM macOS (static)
shell: bash
run: |
set -euo pipefail
cd spm-examples/macOS
# Patch Package.swift to use local package
sed -i.bak 's|.package(url: "https://github.com/k2-fsa/sherpa-onnx", branch: "master")|.package(path: "../../")|' Package.swift
# Patch root Package.swift to use local xcframework paths
cd ../..
cp Package.swift Package.swift.bak
python3 -c "
import re
text = open('Package.swift').read()
# Patch static macOS binary target to local path
text = re.sub(
r'\.binaryTarget\(\s*name: \"SherpaOnnxMacOS\",\s*url:\s*\"[^\"]+\",\s*checksum: \"[a-f0-9]+\"\s*\)',
'.binaryTarget(name: \"SherpaOnnxMacOS\", path: \"build-macos/sherpa-onnx.xcframework\")',
text
)
# Patch static iOS binary target to local path
text = re.sub(
r'\.binaryTarget\(\s*name: \"SherpaOnnxIOS\",\s*url:\s*\"[^\"]+\",\s*checksum: \"[a-f0-9]+\"\s*\)',
'.binaryTarget(name: \"SherpaOnnxIOS\", path: \"build-ios/sherpa-onnx.xcframework\")',
text
)
# Patch shared macOS binary target to local path
text = re.sub(
r'\.binaryTarget\(\s*name: \"SherpaOnnxMacOSShared\",\s*url:\s*\"[^\"]+\",\s*checksum: \"[a-f0-9]+\"\s*\)',
'.binaryTarget(name: \"SherpaOnnxMacOSShared\", path: \"build-macos-shared/sherpa-onnx.xcframework\")',
text
)
# Patch shared iOS binary target to local path
text = re.sub(
r'\.binaryTarget\(\s*name: \"SherpaOnnxIOSShared\",\s*url:\s*\"[^\"]+\",\s*checksum: \"[a-f0-9]+\"\s*\)',
'.binaryTarget(name: \"SherpaOnnxIOSShared\", path: \"build-ios-shared/sherpa-onnx.xcframework\")',
text
)
open('Package.swift', 'w').write(text)
"
cd spm-examples/macOS
echo "=== Package.swift ==="
cat Package.swift
echo "=== Root Package.swift ==="
cat ../../Package.swift
rm -rf .build
swift build --verbose
swift run SherpaOnnxExample
- name: Test SPM iOS (static)
shell: bash
run: |
set -euo pipefail
cd spm-examples/iOS
# Patch Package.swift to use local package
sed -i.bak 's|.package(url: "https://github.com/k2-fsa/sherpa-onnx", branch: "master")|.package(path: "../../")|' Package.swift
echo "=== Package.swift ==="
cat Package.swift
echo "=== Resolving ==="
swift package resolve
echo "=== Building for iOS Simulator ==="
xcodebuild -scheme SherpaOnnxExample \
-destination "generic/platform=iOS Simulator" \
-skipPackagePluginValidation \
-verbose \
build 2>&1
echo "=== Finding built executable ==="
BINARY=$(find ~/Library/Developer/Xcode/DerivedData -path "*/Build/Products/*-iphonesimulator/SherpaOnnxExample" -type f | head -1)
echo "Binary: $BINARY"
echo "=== Booting iOS Simulator ==="
DEVICE=$(xcrun simctl list devices available -j | python3 -c "
import json, sys
devices = json.load(sys.stdin)['devices']
for key in devices:
for d in devices[key]:
if d['isAvailable'] and 'iPhone' in d['name']:
print(d['udid'])
sys.exit(0)
")
echo "Device: $DEVICE"
xcrun simctl boot "$DEVICE" 2>/dev/null || true
echo "=== Running on iOS Simulator ==="
xcrun simctl spawn "$DEVICE" "$BINARY"
- name: Test SPM macOS (shared)
shell: bash
run: |
set -euo pipefail
cd spm-examples/macOS
# Patch Package.swift to use shared product
sed -i.bak2 's|.product(name: "sherpa-onnx", package: "sherpa-onnx")|.product(name: "sherpa-onnx-shared", package: "sherpa-onnx")|' Package.swift
echo "=== Package.swift (shared) ==="
cat Package.swift
echo "=== Root Package.swift ==="
cat ../../Package.swift
rm -rf .build
swift build --verbose
# Find the shared onnxruntime dylib from OnnxruntimeMacOSShared artifact
ort_dylib=$(find .build/artifacts -path "*OnnxruntimeMacOSShared*" -name "onnxruntime" -type f | grep -v Headers | head -1)
if [ -z "$ort_dylib" ]; then
echo "ERROR: shared onnxruntime dylib not found in artifacts"
echo "=== Listing all artifacts ==="
find .build/artifacts -type f | sort
exit 1
fi
echo "Found onnxruntime dylib: $ort_dylib"
file "$ort_dylib"
exe_dir=$(dirname "$(find .build -name "SherpaOnnxExample" -type f -perm +111 | head -1)")
cp "$ort_dylib" "$exe_dir/libonnxruntime.dylib"
install_name_tool -id "@rpath/libonnxruntime.dylib" "$exe_dir/libonnxruntime.dylib"
swift run SherpaOnnxExample
- name: Test SPM iOS (shared)
shell: bash
run: |
set -euo pipefail
cd spm-examples/iOS
# Patch Package.swift to use shared product
sed -i.bak2 's|.product(name: "sherpa-onnx", package: "sherpa-onnx")|.product(name: "sherpa-onnx-shared", package: "sherpa-onnx")|' Package.swift
echo "=== Package.swift (shared) ==="
cat Package.swift
echo "=== Resolving ==="
swift package resolve
echo "=== Building for iOS Simulator ==="
xcodebuild -scheme SherpaOnnxExample \
-destination "generic/platform=iOS Simulator" \
-skipPackagePluginValidation \
-verbose \
build 2>&1
echo "=== Finding built executable ==="
BINARY=$(find ~/Library/Developer/Xcode/DerivedData -path "*/Build/Products/*-iphonesimulator/SherpaOnnxExample" -type f | head -1)
echo "Binary: $BINARY"
PRODUCTS_DIR=$(dirname "$BINARY")
# Ensure dynamic frameworks are accessible next to the binary
# simctl spawn uses @executable_path-relative rpaths, so frameworks must be
# in PackageFrameworks/ or Frameworks/ relative to the binary
echo "=== Checking framework locations ==="
find "$PRODUCTS_DIR" -name "*.framework" -type d
ls -la "$PRODUCTS_DIR/Frameworks/" 2>/dev/null || true
ls -la "$PRODUCTS_DIR/PackageFrameworks/" 2>/dev/null || true
# Copy SherpaOnnxC.framework to PackageFrameworks/ if not already there
pkg_fw_dir="$PRODUCTS_DIR/PackageFrameworks"
mkdir -p "$pkg_fw_dir"
sherpa_fw=$(find "$PRODUCTS_DIR" -path "*/Frameworks/SherpaOnnxC.framework" -type d | head -1)
if [ -n "$sherpa_fw" ] && [ ! -d "$pkg_fw_dir/SherpaOnnxC.framework" ]; then
cp -a "$sherpa_fw" "$pkg_fw_dir/"
fi
ort_fw=$(find "$PRODUCTS_DIR" -path "*/Frameworks/onnxruntime.framework" -type d | head -1)
if [ -n "$ort_fw" ] && [ ! -d "$pkg_fw_dir/onnxruntime.framework" ]; then
cp -a "$ort_fw" "$pkg_fw_dir/"
fi
echo "=== PackageFrameworks contents ==="
ls -la "$pkg_fw_dir/"
echo "=== Booting iOS Simulator ==="
DEVICE=$(xcrun simctl list devices available -j | python3 -c "
import json, sys
devices = json.load(sys.stdin)['devices']
for key in devices:
for d in devices[key]:
if d['isAvailable'] and 'iPhone' in d['name']:
print(d['udid'])
sys.exit(0)
")
echo "Device: $DEVICE"
xcrun simctl boot "$DEVICE" 2>/dev/null || true
echo "=== Running on iOS Simulator ==="
xcrun simctl spawn "$DEVICE" "$BINARY"
- name: Test iOS apps (static, local SPM)
shell: bash
run: |
set -euo pipefail
# Restore root Package.swift for static test (already patched with local paths)
# Patch ios-swiftui/ios-swift xcodeproj files to use local package
find ios-swiftui ios-swift -name "project.pbxproj" -exec sed -i '' \
-e 's|isa = XCRemoteSwiftPackageReference|isa = XCLocalSwiftPackageReference|' \
-e 's|repositoryURL = "https://github.com/k2-fsa/sherpa-onnx"|relativePath = ../../|' \
-e '/requirement = {/,/};/d' \
{} +
# Ensure we're using the static product in spm-examples
# (Root Package.swift already has static binary targets patched to local paths)
for app in SherpaOnnxAsr SherpaOnnx2Pass SherpaOnnxTts; do
echo "=== Building ios-swiftui/$app (static, local SPM) ==="
cd ios-swiftui/$app
xcodebuild -project $app.xcodeproj \
-scheme $app \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build
cd ../..
done
echo "=== Building ios-swift/SherpaOnnxAsr (static, local SPM) ==="
cd ios-swift/SherpaOnnxAsr
xcodebuild -project SherpaOnnxAsr.xcodeproj \
-scheme SherpaOnnxAsr \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build
- name: Test iOS apps (shared, local SPM)
shell: bash
run: |
set -euo pipefail
# Swap static xcframeworks with shared ones in the local paths
rm -rf build-macos/sherpa-onnx.xcframework
cp -a build-macos-shared/sherpa-onnx.xcframework build-macos/
rm -rf build-ios/sherpa-onnx.xcframework
cp -a build-ios-shared/sherpa-onnx.xcframework build-ios/
# Patch root Package.swift to use shared onnxruntime products
python3 -c "
text = open('Package.swift').read()
# In the static wrapper target, swap to shared onnxruntime products
text = text.replace('\"onnxruntime-macos\"', '\"onnxruntime-macos-shared\"')
text = text.replace('\"onnxruntime-ios\"', '\"onnxruntime-ios-shared\"')
open('Package.swift', 'w').write(text)
"
for app in SherpaOnnxAsr SherpaOnnx2Pass SherpaOnnxTts; do
echo "=== Building ios-swiftui/$app (shared, local SPM) ==="
cd ios-swiftui/$app
xcodebuild -project $app.xcodeproj \
-scheme $app \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build
cd ../..
done
echo "=== Building ios-swift/SherpaOnnxAsr (shared, local SPM) ==="
cd ios-swift/SherpaOnnxAsr
xcodebuild -project SherpaOnnxAsr.xcodeproj \
-scheme SherpaOnnxAsr \
-destination 'generic/platform=iOS Simulator' \
-skipPackagePluginValidation \
build
- name: Restore modified files
if: always()
shell: bash
run: |
[ -f spm-examples/macOS/Package.swift.bak ] && mv spm-examples/macOS/Package.swift.bak spm-examples/macOS/Package.swift || true
[ -f Package.swift.bak ] && mv Package.swift.bak Package.swift || true
[ -f spm-examples/iOS/Package.swift.bak ] && mv spm-examples/iOS/Package.swift.bak spm-examples/iOS/Package.swift || true
# Restore xcodeproj files patched for ios app test
git checkout -- ios-swiftui/ ios-swift/ 2>/dev/null || true
release:
name: release
needs:
- build_ios_static_xcframework
- build_ios_shared_xcframework
- build_macos_static_xcframework
- build_macos_shared_xcframework
- test_spm
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download all xcframework artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Release xcframework (k2-fsa)
if: github.repository_owner == 'k2-fsa'
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
overwrite: true
file: ./build-swift-macos/*.xcframework.zip
overwrite: false
file: artifacts/**/*.xcframework.zip
tag: xcframework
- name: Release xcframework
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
- name: Release xcframework (csukuangfj)
if: github.repository_owner == 'csukuangfj'
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
overwrite: true
file: ./build-swift-macos/*.xcframework.zip
# repo_name: k2-fsa/sherpa-onnx
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
# tag: v1.13.4
# https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
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_CLONE_PROTECTION_ACTIVE=false
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs huggingface
cd huggingface
cp -v ../build-swift-macos/*.xcframework.zip ./
git status
git lfs track "*.zip"
git add .
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
git commit -m "upload sherpa-onnx-${SHERPA_ONNX_VERSION} macos xcframework"
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs main
overwrite: false
file: artifacts/**/*.xcframework.zip
repo_name: k2-fsa/sherpa-onnx
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: xcframework
+2 -2
View File
@@ -104,7 +104,7 @@ jobs:
dst=sherpa-onnx/java-api/resources/sherpa-onnx/native/osx-aarch64
mkdir -p $dst
cp -v $src/lib/libonnxruntime.1.27.0.dylib $dst/
cp -v $src/lib/libonnxruntime.dylib $dst/
cp -v $src/lib/libsherpa-onnx-jni.dylib $dst/
ls -lh $dst
@@ -122,7 +122,7 @@ jobs:
dst=sherpa-onnx/java-api/resources/sherpa-onnx/native/osx-x64
mkdir -p $dst
cp -v $src/lib/libonnxruntime.1.27.0.dylib $dst/
cp -v $src/lib/libonnxruntime.dylib $dst/
cp -v $src/lib/libsherpa-onnx-jni.dylib $dst/
ls -lh $dst
+3 -27
View File
@@ -8,7 +8,7 @@ on:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
paths:
- './build-swift-macos.sh'
- 'build-macos.sh'
- '.github/workflows/swift.yaml'
- 'cmake/**'
- 'swift-api-examples/**'
@@ -20,7 +20,7 @@ on:
branches:
- master
paths:
- './build-swift-macos.sh'
- 'build-macos.sh'
- '.github/workflows/swift.yaml'
- 'cmake/**'
- 'swift-api-examples/**'
@@ -70,31 +70,7 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
./build-swift-macos.sh
- name: Copy files
if: matrix.os == 'macos-15-intel' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
shell: bash
run: |
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-xcframework-static
mkdir $dst
mv -v build-swift-macos/sherpa-onnx.xcframework $dst
brew install tree
tree $dst
tar cjvf ${dst}.tar.bz2 $dst
- name: Release pre-compiled binaries and libs for macOS
if: matrix.os == 'macos-15-intel' && (github.repository_owner == 'csukuangfj' || 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-*macos-xcframework-static.tar.bz2
./build-macos.sh
- name: test
shell: bash
+2 -6
View File
@@ -131,15 +131,11 @@ jobs:
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll $upload_dir
else
cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib $upload_dir/
cp -v _deps/onnxruntime-src/lib/libonnxruntime.dylib $upload_dir/
cp -v lib/*.dylib $upload_dir
cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/
cp -v _deps/onnxruntime-src/lib/libonnxruntime.dylib ./lib/
rm ./lib/*.a
rm ./lib/libonnxruntime.dylib
cd lib
ln -s libonnxruntime.1.27.0.dylib libonnxruntime.dylib
cd ..
fi
cd ../scripts/go/_internal/
+2 -1
View File
@@ -26,7 +26,8 @@ offline-tts-c-api
run-decode-file-c-api.sh
sherpa-onnx-ffmpeg
build-ios
build-swift-macos
build-macos
build-macos-shared
aa.sh
client-2.sh
ffmpeg-examples/run-3.sh
+54 -12
View File
@@ -8,30 +8,52 @@ let package = Package(
.macOS(.v10_15),
],
products: [
.library(
name: "sherpa-onnx",
targets: ["SherpaOnnx"]
),
// Static xcframework (default)
.library(name: "sherpa-onnx", targets: ["SherpaOnnx"]),
// Shared/dynamic xcframework
.library(name: "sherpa-onnx-shared", targets: ["SherpaOnnxShared"]),
],
dependencies: [
.package(url: "https://github.com/csukuangfj/onnxruntime-libs", exact: "1.27.1"),
.package(url: "https://github.com/csukuangfj/onnxruntime-libs", exact: "1.27.1")
],
targets: [
// --- Static binary targets ---
.binaryTarget(
name: "SherpaOnnxMacOS",
url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.13.4/sherpa-onnx-v1.13.4-macos.xcframework.zip",
checksum: "4325d8aed99b94be58969005b19f9626f3f3afc4ebd42378b0aad2b84e233552"
url:
"https://github.com/k2-fsa/sherpa-onnx/releases/download/xcframework/sherpa-onnx-v1.13.4-macos-static.xcframework.zip",
checksum: "16690967d863fc8b981ebe77c7764ce5ca3805638489496b87281a866bd8bf3c"
),
.binaryTarget(
name: "SherpaOnnxIOS",
url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.13.4/sherpa-onnx-v1.13.4-ios.xcframework.zip",
checksum: "c5a62904bba73edc4bac89bbf51b4c3db1dd6c1b397a16ee95b2ff94701e9846"
url:
"https://github.com/k2-fsa/sherpa-onnx/releases/download/xcframework/sherpa-onnx-v1.13.4-ios-static.xcframework.zip",
checksum: "b48ec217952a5b82242ce7d8323fcbc8de54ff900a72df1f0b20bfcf7b08881d"
),
// --- Shared binary targets ---
.binaryTarget(
name: "SherpaOnnxMacOSShared",
url:
"https://github.com/k2-fsa/sherpa-onnx/releases/download/xcframework/sherpa-onnx-v1.13.4-macos-shared.xcframework.zip",
checksum: "f821a02c2c8371a143922f29ee971de5ff5946a03037f0b4d6f62eab3204b0c2"
),
.binaryTarget(
name: "SherpaOnnxIOSShared",
url:
"https://github.com/k2-fsa/sherpa-onnx/releases/download/xcframework/sherpa-onnx-v1.13.4-ios-shared.xcframework.zip",
checksum: "b02da91832d281e9b785e6c4040c38f47fbdd076c78dabc7a42d0178afa86ae8"
),
// --- Static wrapper target (default) ---
.target(
name: "SherpaOnnx",
dependencies: [
.product(name: "onnxruntime-macos", package: "onnxruntime-libs", condition: .when(platforms: [.macOS])),
.product(name: "onnxruntime-ios", package: "onnxruntime-libs", condition: .when(platforms: [.iOS])),
.product(
name: "onnxruntime-macos", package: "onnxruntime-libs",
condition: .when(platforms: [.macOS])),
.product(
name: "onnxruntime-ios", package: "onnxruntime-libs", condition: .when(platforms: [.iOS])),
.target(name: "SherpaOnnxMacOS", condition: .when(platforms: [.macOS])),
.target(name: "SherpaOnnxIOS", condition: .when(platforms: [.iOS])),
],
@@ -120,7 +142,27 @@ let package = Package(
],
sources: ["SherpaOnnx.swift"],
linkerSettings: [
.linkedLibrary("c++"),
.linkedLibrary("c++")
]
),
// --- Shared wrapper target ---
.target(
name: "SherpaOnnxShared",
dependencies: [
.product(
name: "onnxruntime-macos-shared", package: "onnxruntime-libs",
condition: .when(platforms: [.macOS])),
.product(
name: "onnxruntime-ios-shared", package: "onnxruntime-libs",
condition: .when(platforms: [.iOS])),
.target(name: "SherpaOnnxMacOSShared", condition: .when(platforms: [.macOS])),
.target(name: "SherpaOnnxIOSShared", condition: .when(platforms: [.iOS])),
],
path: "Sources/SherpaOnnxShared",
sources: ["SherpaOnnx.swift"],
linkerSettings: [
.linkedLibrary("c++")
]
),
]
+1
View File
@@ -0,0 +1 @@
../../swift-api-examples/SherpaOnnx.swift
+65 -12
View File
@@ -5,17 +5,15 @@ set -e
dir=build-ios-no-tts
mkdir -p $dir
cd $dir
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.0}
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.1}
onnxruntime_dir=ios-onnxruntime/$onnxruntime_version
if [ ! -f $onnxruntime_dir/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/onnxruntime ]; then
mkdir -p $onnxruntime_dir
pushd $onnxruntime_dir
wget -c https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
unzip onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
rm onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
mv onnxruntime-ios-static-xcframework-${onnxruntime_version}/onnxruntime.xcframework .
rmdir onnxruntime-ios-static-xcframework-${onnxruntime_version}
wget -c https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
unzip onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
rm onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
cd ..
ln -sf $onnxruntime_version/onnxruntime.xcframework .
popd
@@ -60,7 +58,7 @@ cmake \
-DDEPLOYMENT_TARGET=13.0 \
-B build/simulator_x86_64
cmake --build build/simulator_x86_64 -j 4 --verbose
cmake --build build/simulator_x86_64 -j 4
echo "Building for simulator (arm64)"
@@ -90,7 +88,7 @@ cmake \
-DDEPLOYMENT_TARGET=13.0 \
-B build/simulator_arm64
cmake --build build/simulator_arm64 -j 4 --verbose
cmake --build build/simulator_arm64 -j 4
echo "Building for arm64"
@@ -127,7 +125,6 @@ cmake \
cmake --build build/os64 -j 4
# Generate headers for sherpa-onnx.xcframework
cmake --build build/os64 --target install
cp -v ../sherpa-onnx/c-api/module.modulemap ./install/include/sherpa-onnx/c-api/
echo "Generate xcframework"
@@ -163,12 +160,68 @@ libtool -static -o build/os64/sherpa-onnx.a \
build/os64/lib/libkaldi-decoder-core.a \
build/os64/lib/libssentencepiece_core.a
# Rename to match the shared library naming convention
mv -v build/os64/sherpa-onnx.a build/os64/libsherpa-onnx-c-api.a
mv -v build/simulator/sherpa-onnx.a build/simulator/libsherpa-onnx-c-api.a
rm -rf sherpa-onnx.xcframework
# Create framework bundles (like onnxruntime does) so SPM can resolve the module
create_framework() {
local lib_path=$1
local output_dir=$2
local fw_dir=$output_dir/SherpaOnnxC.framework
rm -rf $fw_dir
mkdir -p $fw_dir/Headers/sherpa-onnx/c-api
mkdir -p $fw_dir/Modules
cp $lib_path $fw_dir/SherpaOnnxC
cp install/include/sherpa-onnx/c-api/c-api.h $fw_dir/Headers/sherpa-onnx/c-api/
cat > $fw_dir/Modules/module.modulemap << 'MEOF'
framework module SherpaOnnxC {
header "sherpa-onnx/c-api/c-api.h"
export *
}
MEOF
cat > $fw_dir/Info.plist << 'PEOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.k2-fsa.sherpa-onnx</string>
<key>CFBundleName</key>
<string>SherpaOnnxC</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleExecutable</key>
<string>SherpaOnnxC</string>
<key>CFBundleVersion</key>
<string>20260707</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
<key>MinimumOSVersion</key>
<string>13.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
</dict>
</plist>
PEOF
}
create_framework build/os64/libsherpa-onnx-c-api.a build/os64
create_framework build/simulator/libsherpa-onnx-c-api.a build/simulator
xcodebuild -create-xcframework \
-library "build/os64/sherpa-onnx.a" -headers install/include/sherpa-onnx/c-api \
-library "build/simulator/sherpa-onnx.a" -headers install/include/sherpa-onnx/c-api \
-output sherpa-onnx.xcframework
-framework "build/os64/SherpaOnnxC.framework" \
-framework "build/simulator/SherpaOnnxC.framework" \
-output sherpa-onnx.xcframework
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
+62 -131
View File
@@ -10,29 +10,17 @@ set -e
dir=build-ios-shared
mkdir -p $dir
cd $dir
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.0}
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.1}
onnxruntime_dir=ios-onnxruntime/$onnxruntime_version
SHERPA_ONNX_GITHUB=github.com
if [ "$SHERPA_ONNX_GITHUB_MIRROW" == true ]; then
SHERPA_ONNX_GITHUB=hub.nuaa.cf
fi
if [ ! -z CMAKE_VERBOSE_MAKEFILE ]; then
CMAKE_VERBOSE_MAKEFILE=ON
else
CMAKE_VERBOSE_MAKEFILE=OFF
fi
CMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF}
if [ ! -f $onnxruntime_dir/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/onnxruntime ]; then
mkdir -p $onnxruntime_dir
pushd $onnxruntime_dir
wget -c https://${SHERPA_ONNX_GITHUB}/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
unzip onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
rm onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
mv onnxruntime-ios-static-xcframework-${onnxruntime_version}/onnxruntime.xcframework .
rmdir onnxruntime-ios-static-xcframework-${onnxruntime_version}
wget -c https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-shared-xcframework-${onnxruntime_version}.xcframework.zip
unzip onnxruntime-ios-shared-xcframework-${onnxruntime_version}.xcframework.zip
rm onnxruntime-ios-shared-xcframework-${onnxruntime_version}.xcframework.zip
cd ..
ln -sf $onnxruntime_version/onnxruntime.xcframework .
popd
@@ -169,136 +157,79 @@ lipo \
-output \
ios-arm64_x86_64-simulator/libsherpa-onnx-c-api.dylib
pushd ios-arm64
rm -rf sherpa_onnx.framework
mkdir sherpa_onnx.framework
rm -rf sherpa-onnx.xcframework
lipo \
-create \
libsherpa-onnx-c-api.dylib \
-output \
sherpa_onnx
# Create framework bundles (like onnxruntime does) so SPM can resolve the module
create_framework() {
local lib_path=$1
local output_dir=$2
mv sherpa_onnx sherpa_onnx.framework/
cd sherpa_onnx.framework
local fw_dir=$output_dir/SherpaOnnxC.framework
rm -rf $fw_dir
install_name_tool \
-change @rpath/libsherpa-onnx-c-api.dylib @rpath/sherpa_onnx.framework/sherpa_onnx \
sherpa_onnx
mkdir -p $fw_dir/Headers/sherpa-onnx/c-api
mkdir -p $fw_dir/Modules
install_name_tool \
-id "@rpath/sherpa_onnx.framework/sherpa_onnx" \
sherpa_onnx
cp $lib_path $fw_dir/SherpaOnnxC
cp build/os64/install/include/sherpa-onnx/c-api/c-api.h $fw_dir/Headers/sherpa-onnx/c-api/
chmod +x sherpa_onnx
strip -x sherpa_onnx
popd
cat > $fw_dir/Modules/module.modulemap << 'MEOF'
framework module SherpaOnnxC {
header "sherpa-onnx/c-api/c-api.h"
export *
}
MEOF
pushd ios-arm64_x86_64-simulator
rm -rf sherpa_onnx.framework
mkdir sherpa_onnx.framework
lipo \
-create \
libsherpa-onnx-c-api.dylib \
-output \
sherpa_onnx
mv sherpa_onnx sherpa_onnx.framework/
cd sherpa_onnx.framework
install_name_tool \
-change @rpath/libsherpa-onnx-c-api.dylib @rpath/sherpa_onnx.framework/sherpa_onnx \
sherpa_onnx
install_name_tool \
-id "@rpath/sherpa_onnx.framework/sherpa_onnx" \
sherpa_onnx
chmod +x sherpa_onnx
strip -x sherpa_onnx
popd
for d in ios-arm64_x86_64-simulator ios-arm64; do
dst=$d/sherpa_onnx.framework
# The Info.plist is modified from
# https://github.com/Spicely/flutter_openim_sdk_ffi/blob/main/ios/openim_sdk_ffi.framework/Info.plist
cat >$dst/Info.plist <<EOF
cat > $fw_dir/Info.plist << 'PEOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>sherpa_onnx</string>
<key>DTSDKName</key>
<string>iphoneos17.0</string>
<key>DTXcode</key>
<string>1501</string>
<key>DTSDKBuild</key>
<string>21A326</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>BuildMachineOSBuild</key>
<string>23B81</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>sherpa_onnx</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>13.0</string>
<key>CFBundleIdentifier</key>
<string>com.k2fsa.sherpa.onnx</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>CFBundleSignature</key>
<string>????</string>
<key>DTPlatformVersion</key>
<string>17.0</string>
<key>DTXcodeBuild</key>
<string>15A507</string>
<key>DTPlatformBuild</key>
<string>21A326</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>CFBundleIdentifier</key>
<string>com.k2-fsa.sherpa-onnx</string>
<key>CFBundleName</key>
<string>SherpaOnnxC</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleExecutable</key>
<string>SherpaOnnxC</string>
<key>CFBundleVersion</key>
<string>20260707</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
<key>MinimumOSVersion</key>
<string>13.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
</dict>
</plist>
EOF
done
PEOF
# Fix dylib install name
install_name_tool -id @rpath/SherpaOnnxC.framework/SherpaOnnxC $fw_dir/SherpaOnnxC
}
create_framework ios-arm64/libsherpa-onnx-c-api.dylib ios-arm64
create_framework ios-arm64_x86_64-simulator/libsherpa-onnx-c-api.dylib ios-arm64_x86_64-simulator
rm -rf sherpa_onnx.xcframework
xcodebuild -create-xcframework \
-framework ios-arm64/sherpa_onnx.framework \
-framework ios-arm64_x86_64-simulator/sherpa_onnx.framework \
-output sherpa_onnx.xcframework
-framework "ios-arm64/SherpaOnnxC.framework" \
-framework "ios-arm64_x86_64-simulator/SherpaOnnxC.framework" \
-output sherpa-onnx.xcframework
cd sherpa_onnx.xcframework
cd sherpa-onnx.xcframework
echo "PWD: $PWD"
ls -lh
echo "---"
ls -lh */*
cd ..
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-shared.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-shared.xcframework.zip sherpa-onnx.xcframework
echo "Checksum:"
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-shared.xcframework.zip | tee checksum.txt
+66 -13
View File
@@ -5,17 +5,15 @@ set -e
dir=build-ios
mkdir -p $dir
cd $dir
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.0}
onnxruntime_version=${SHERPA_ONNX_ONNXRUNTIME_VERSION:-1.27.1}
onnxruntime_dir=ios-onnxruntime/$onnxruntime_version
if [ ! -f $onnxruntime_dir/onnxruntime.xcframework/ios-arm64/onnxruntime.framework/onnxruntime ]; then
mkdir -p $onnxruntime_dir
pushd $onnxruntime_dir
wget -c https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
unzip onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
rm onnxruntime-ios-static-xcframework-${onnxruntime_version}.zip
mv onnxruntime-ios-static-xcframework-${onnxruntime_version}/onnxruntime.xcframework .
rmdir onnxruntime-ios-static-xcframework-${onnxruntime_version}
wget -c https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
unzip onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
rm onnxruntime-ios-static-xcframework-${onnxruntime_version}.xcframework.zip
cd ..
ln -sf $onnxruntime_version/onnxruntime.xcframework .
popd
@@ -123,7 +121,6 @@ cmake \
cmake --build build/os64 -j 4
# Generate headers for sherpa-onnx.xcframework
cmake --build build/os64 --target install
cp -v ../sherpa-onnx/c-api/module.modulemap ./install/include/sherpa-onnx/c-api/
echo "Generate xcframework"
@@ -167,17 +164,73 @@ libtool -static -o build/os64/libsherpa-onnx.a \
build/os64/lib/libespeak-ng.a \
build/os64/lib/libssentencepiece_core.a
# Rename to match the shared library naming convention
mv -v build/os64/libsherpa-onnx.a build/os64/libsherpa-onnx-c-api.a
mv -v build/simulator/libsherpa-onnx.a build/simulator/libsherpa-onnx-c-api.a
rm -rf sherpa-onnx.xcframework
# Create framework bundles (like onnxruntime does) so SPM can resolve the module
create_framework() {
local lib_path=$1
local output_dir=$2
local fw_dir=$output_dir/SherpaOnnxC.framework
rm -rf $fw_dir
mkdir -p $fw_dir/Headers/sherpa-onnx/c-api
mkdir -p $fw_dir/Modules
cp $lib_path $fw_dir/SherpaOnnxC
cp install/include/sherpa-onnx/c-api/c-api.h $fw_dir/Headers/sherpa-onnx/c-api/
cat > $fw_dir/Modules/module.modulemap << 'MEOF'
framework module SherpaOnnxC {
header "sherpa-onnx/c-api/c-api.h"
export *
}
MEOF
cat > $fw_dir/Info.plist << 'PEOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.k2-fsa.sherpa-onnx</string>
<key>CFBundleName</key>
<string>SherpaOnnxC</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleExecutable</key>
<string>SherpaOnnxC</string>
<key>CFBundleVersion</key>
<string>20260707</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
<key>MinimumOSVersion</key>
<string>13.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
</dict>
</plist>
PEOF
}
create_framework build/os64/libsherpa-onnx-c-api.a build/os64
create_framework build/simulator/libsherpa-onnx-c-api.a build/simulator
xcodebuild -create-xcframework \
-library "build/os64/libsherpa-onnx.a" -headers install/include/sherpa-onnx/c-api \
-library "build/simulator/libsherpa-onnx.a" -headers install/include/sherpa-onnx/c-api \
-output sherpa-onnx.xcframework
-framework "build/os64/SherpaOnnxC.framework" \
-framework "build/simulator/SherpaOnnxC.framework" \
-output sherpa-onnx.xcframework
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-ios.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-ios.xcframework.zip sherpa-onnx.xcframework
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-static.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-static.xcframework.zip sherpa-onnx.xcframework
echo "Checksum:"
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-ios.xcframework.zip | tee checksum.txt
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-static.xcframework.zip | tee checksum.txt
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
set -ex
dir=build-macos-shared
mkdir -p $dir
cd $dir
cmake \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_JNI=OFF \
-DSHERPA_ONNX_ENABLE_C_API=ON \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
../
make -j4
make install
rm -fv ./install/include/cargs.h
# Create a framework bundle (like onnxruntime does) so SPM can resolve the module
FRAMEWORK_DIR=SherpaOnnxC.framework
rm -rf $FRAMEWORK_DIR
mkdir -p $FRAMEWORK_DIR/Versions/A/Headers/sherpa-onnx/c-api
mkdir -p $FRAMEWORK_DIR/Versions/A/Modules
mkdir -p $FRAMEWORK_DIR/Versions/A/Resources
# Binary
cp install/lib/libsherpa-onnx-c-api.dylib $FRAMEWORK_DIR/Versions/A/SherpaOnnxC
# Headers (preserve nested path for #include "sherpa-onnx/c-api/c-api.h")
cp install/include/sherpa-onnx/c-api/c-api.h $FRAMEWORK_DIR/Versions/A/Headers/sherpa-onnx/c-api/
# Modulemap
cat > $FRAMEWORK_DIR/Versions/A/Modules/module.modulemap << 'EOF'
framework module SherpaOnnxC {
header "sherpa-onnx/c-api/c-api.h"
export *
}
EOF
# Info.plist
cat > $FRAMEWORK_DIR/Versions/A/Resources/Info.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.k2-fsa.sherpa-onnx</string>
<key>CFBundleName</key>
<string>SherpaOnnxC</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleExecutable</key>
<string>SherpaOnnxC</string>
<key>CFBundleVersion</key>
<string>20260707</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
</dict>
</plist>
EOF
# Versioned symlinks
pushd $FRAMEWORK_DIR/Versions
ln -sf A Current
popd
ln -sf Versions/Current/SherpaOnnxC $FRAMEWORK_DIR/SherpaOnnxC
ln -sf Versions/Current/Headers $FRAMEWORK_DIR/Headers
ln -sf Versions/Current/Modules $FRAMEWORK_DIR/Modules
ln -sf Versions/Current/Resources $FRAMEWORK_DIR/Resources
# Fix dylib install name to use framework-relative path
install_name_tool -id @rpath/SherpaOnnxC.framework/Versions/A/SherpaOnnxC $FRAMEWORK_DIR/Versions/A/SherpaOnnxC
rm -rf sherpa-onnx.xcframework
xcodebuild -create-xcframework \
-framework $FRAMEWORK_DIR \
-output sherpa-onnx.xcframework
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-shared.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-shared.xcframework.zip sherpa-onnx.xcframework
echo "Checksum:"
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-shared.xcframework.zip | tee checksum.txt
Executable
+112
View File
@@ -0,0 +1,112 @@
#!/usr/bin/env bash
set -ex
dir=build-macos
mkdir -p $dir
cd $dir
cmake \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_JNI=OFF \
-DSHERPA_ONNX_ENABLE_C_API=ON \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
../
make -j4
make install
rm -fv ./install/include/cargs.h
libtool -static -o ./install/lib/libsherpa-onnx.a \
./install/lib/libsherpa-onnx-c-api.a \
./install/lib/libsherpa-onnx-core.a \
./install/lib/libkaldi-native-fbank-core.a \
./install/lib/libkissfft-float.a \
./install/lib/libsherpa-onnx-fstfar.a \
./install/lib/libsherpa-onnx-fst.a \
./install/lib/libsherpa-onnx-kaldifst-core.a \
./install/lib/libkaldi-decoder-core.a \
./install/lib/libucd.a \
./install/lib/libpiper_phonemize.a \
./install/lib/libespeak-ng.a \
./install/lib/libssentencepiece_core.a
# Rename to match the expected library name for linking with -l sherpa-onnx-c-api
mv -v install/lib/libsherpa-onnx.a install/lib/libsherpa-onnx-c-api.a
# Create a framework bundle (like onnxruntime does) so SPM can resolve the module
FRAMEWORK_DIR=SherpaOnnxC.framework
rm -rf $FRAMEWORK_DIR
mkdir -p $FRAMEWORK_DIR/Versions/A/Headers/sherpa-onnx/c-api
mkdir -p $FRAMEWORK_DIR/Versions/A/Modules
mkdir -p $FRAMEWORK_DIR/Versions/A/Resources
# Binary
cp install/lib/libsherpa-onnx-c-api.a $FRAMEWORK_DIR/Versions/A/SherpaOnnxC
# Headers (preserve nested path for #include "sherpa-onnx/c-api/c-api.h")
cp install/include/sherpa-onnx/c-api/c-api.h $FRAMEWORK_DIR/Versions/A/Headers/sherpa-onnx/c-api/
# Modulemap
cat > $FRAMEWORK_DIR/Versions/A/Modules/module.modulemap << 'EOF'
framework module SherpaOnnxC {
header "sherpa-onnx/c-api/c-api.h"
export *
}
EOF
# Info.plist
cat > $FRAMEWORK_DIR/Versions/A/Resources/Info.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.k2-fsa.sherpa-onnx</string>
<key>CFBundleName</key>
<string>SherpaOnnxC</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleExecutable</key>
<string>SherpaOnnxC</string>
<key>CFBundleVersion</key>
<string>20260707</string>
<key>CFBundleShortVersionString</key>
<string>1.13.4</string>
</dict>
</plist>
EOF
# Versioned symlinks
pushd $FRAMEWORK_DIR/Versions
ln -sf A Current
popd
ln -sf Versions/Current/SherpaOnnxC $FRAMEWORK_DIR/SherpaOnnxC
ln -sf Versions/Current/Headers $FRAMEWORK_DIR/Headers
ln -sf Versions/Current/Modules $FRAMEWORK_DIR/Modules
ln -sf Versions/Current/Resources $FRAMEWORK_DIR/Resources
rm -rf sherpa-onnx.xcframework
xcodebuild -create-xcframework \
-framework $FRAMEWORK_DIR \
-output sherpa-onnx.xcframework
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-static.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-static.xcframework.zip sherpa-onnx.xcframework
echo "Checksum:"
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-static.xcframework.zip | tee checksum.txt
-60
View File
@@ -1,60 +0,0 @@
#!/usr/bin/env bash
set -ex
dir=build-swift-macos
mkdir -p $dir
cd $dir
cmake \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_JNI=OFF \
-DSHERPA_ONNX_ENABLE_C_API=ON \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
../
make -j4
make install
rm -fv ./install/include/cargs.h
cp -v ../sherpa-onnx/c-api/module.modulemap ./install/include/sherpa-onnx/c-api/
libtool -static -o ./install/lib/libsherpa-onnx.a \
./install/lib/libsherpa-onnx-c-api.a \
./install/lib/libsherpa-onnx-core.a \
./install/lib/libkaldi-native-fbank-core.a \
./install/lib/libkissfft-float.a \
./install/lib/libsherpa-onnx-fstfar.a \
./install/lib/libsherpa-onnx-fst.a \
./install/lib/libsherpa-onnx-kaldifst-core.a \
./install/lib/libkaldi-decoder-core.a \
./install/lib/libucd.a \
./install/lib/libpiper_phonemize.a \
./install/lib/libespeak-ng.a \
./install/lib/libssentencepiece_core.a
xcodebuild -create-xcframework \
-library install/lib/libsherpa-onnx.a \
-headers install/include/sherpa-onnx/c-api \
-output sherpa-onnx.xcframework
# Remove the module map from the install directory to prevent swiftc from
# auto-discovering it. The module map is only needed inside the xcframework
# (used by SPM). For direct swiftc builds, the bridging header is used instead.
rm -fv ./install/include/sherpa-onnx/c-api/module.modulemap
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
rm -f sherpa-onnx-${SHERPA_ONNX_VERSION}-macos.xcframework.zip
zip -r -y sherpa-onnx-${SHERPA_ONNX_VERSION}-macos.xcframework.zip sherpa-onnx.xcframework
echo "Checksum:"
swift package compute-checksum sherpa-onnx-${SHERPA_ONNX_VERSION}-macos.xcframework.zip | tee checksum.txt
+6 -9
View File
@@ -12,18 +12,17 @@ if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-arm64-static_lib-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-arm64-static_lib-1.27.0.zip")
set(onnxruntime_HASH "SHA256=4284d9997a9c03d752172c1375f104327035798fb42c83e5b8d2678b259557fa")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-arm64-static_lib-1.27.1.zip")
set(onnxruntime_HASH "SHA256=3c043b1d5231881d940f0184bd1aaeef29d8e816f2865feed0a268bddcf8b628")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-arm64-static_lib-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-arm64-static_lib-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-arm64-static_lib-1.27.0.zip
/tmp/onnxruntime-osx-arm64-static_lib-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-arm64-static_lib-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-arm64-static_lib-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-arm64-static_lib-1.27.1.zip
/tmp/onnxruntime-osx-arm64-static_lib-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -31,7 +30,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -39,7 +37,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
+6 -9
View File
@@ -12,18 +12,17 @@ if(NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-arm64-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-arm64-1.27.0.zip")
set(onnxruntime_HASH "SHA256=5f05b2653eb0af852dab46c85778f0e012c514ed2e71a6dbb9c9550434b0a514")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-arm64-1.27.1.zip")
set(onnxruntime_HASH "SHA256=8258cf05abc011df06706646f73bdddb735d90348ae3d211bd5c471c20a617b0")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-arm64-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-arm64-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-arm64-1.27.0.zip
/tmp/onnxruntime-osx-arm64-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-arm64-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-arm64-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-arm64-1.27.1.zip
/tmp/onnxruntime-osx-arm64-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -31,7 +30,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -39,7 +37,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
+6 -9
View File
@@ -13,18 +13,17 @@ if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-universal2-static_lib-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-universal2-static_lib-1.27.0.zip")
set(onnxruntime_HASH "SHA256=6794da8dd86d0b83b453e7968771cddfb3004e3db4cda5cea6d4111a616f49cb")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-universal2-static_lib-1.27.1.zip")
set(onnxruntime_HASH "SHA256=f57df541a2e44b59b83dd8523362b11d830573c3a28c62801e7dd2d02232b3ca")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-universal2-static_lib-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-universal2-static_lib-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-universal2-static_lib-1.27.0.zip
/tmp/onnxruntime-osx-universal2-static_lib-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-universal2-static_lib-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-universal2-static_lib-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-universal2-static_lib-1.27.1.zip
/tmp/onnxruntime-osx-universal2-static_lib-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -32,7 +31,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -40,7 +38,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
+6 -9
View File
@@ -13,18 +13,17 @@ if(NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-universal2-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-universal2-1.27.0.zip")
set(onnxruntime_HASH "SHA256=70f8d24701d9c219f76687c54c0060aabeb5cf27aa84aa0a7f87582d450bb83a")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-universal2-1.27.1.zip")
set(onnxruntime_HASH "SHA256=6c9330702aacf333dad197262bd89af1f5819c437dad0d7eb7cd8183f214eb99")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-universal2-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-universal2-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-universal2-1.27.0.zip
/tmp/onnxruntime-osx-universal2-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-universal2-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-universal2-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-universal2-1.27.1.zip
/tmp/onnxruntime-osx-universal2-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -32,7 +31,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -40,7 +38,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
+6 -9
View File
@@ -12,18 +12,17 @@ if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-x86_64-static_lib-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-x86_64-static_lib-1.27.0.zip")
set(onnxruntime_HASH "SHA256=e5a163f434d867b26a62ad8470e93ea8094320319d6172444e6001299b1949fa")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-x86_64-static_lib-1.27.1.zip")
set(onnxruntime_HASH "SHA256=3c043b1d5231881d940f0184bd1aaeef29d8e816f2865feed0a268bddcf8b628")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-x86_64-static_lib-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-x86_64-static_lib-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-x86_64-static_lib-1.27.0.zip
/tmp/onnxruntime-osx-x86_64-static_lib-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-x86_64-static_lib-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-x86_64-static_lib-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-x86_64-static_lib-1.27.1.zip
/tmp/onnxruntime-osx-x86_64-static_lib-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -31,7 +30,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -39,7 +37,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
+6 -9
View File
@@ -12,18 +12,17 @@ if(NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
endif()
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-x86_64-1.27.0.zip")
set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj2/onnxruntime-libs/resolve/main/1.27.0/onnxruntime-osx-x86_64-1.27.0.zip")
set(onnxruntime_HASH "SHA256=691fd31e5b53223d536c664771659ae7be9267590de5504129e30bef352a8295")
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.1/onnxruntime-osx-x86_64-1.27.1.zip")
set(onnxruntime_HASH "SHA256=5511a1497fd8d3e79a4c4294c5bad3e09e66da96d8f1f8c4dcd17b0f8f7507a5")
# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
# You can add more if you want.
set(possible_file_locations
$ENV{HOME}/Downloads/onnxruntime-osx-x86_64-1.27.0.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-x86_64-1.27.0.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-x86_64-1.27.0.zip
/tmp/onnxruntime-osx-x86_64-1.27.0.zip
$ENV{HOME}/Downloads/onnxruntime-osx-x86_64-1.27.1.zip
${CMAKE_SOURCE_DIR}/onnxruntime-osx-x86_64-1.27.1.zip
${CMAKE_BINARY_DIR}/onnxruntime-osx-x86_64-1.27.1.zip
/tmp/onnxruntime-osx-x86_64-1.27.1.zip
)
foreach(f IN LISTS possible_file_locations)
@@ -31,7 +30,6 @@ foreach(f IN LISTS possible_file_locations)
set(onnxruntime_URL "${f}")
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
set(onnxruntime_URL2)
break()
endif()
endforeach()
@@ -39,7 +37,6 @@ endforeach()
FetchContent_Declare(onnxruntime
URL
${onnxruntime_URL}
${onnxruntime_URL2}
URL_HASH ${onnxruntime_HASH}
)
@@ -1,5 +1,11 @@
import Foundation
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
func getResource(_ forResource: String, _ ofType: String) -> String {
@@ -7,7 +7,13 @@
import AVFoundation
import UIKit
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
extension AudioBuffer {
func array() -> [Float] {
+169
View File
@@ -0,0 +1,169 @@
# iOS SwiftUI Examples
## Overview
The sherpa-onnx Swift package provides two products for iOS:
- **`sherpa-onnx`** — uses a **static library** (`.a`) inside an xcframework. The sherpa-onnx code is compiled directly into your app binary at build time. This is the default and recommended option for most apps.
- **`sherpa-onnx-shared`** — uses a **shared library** (`.dylib` / `.framework`) inside an xcframework. The sherpa-onnx code is packaged as a separate dynamic framework and loaded at runtime. Your app bundle will contain an additional `.framework` file.
Both products expose the same Swift API. The only difference is how the native C++ code is linked.
| Product | Library Type | Swift Import |
|---|---|---|
| `sherpa-onnx` | Static library (`.a` in xcframework) | `import SherpaOnnx` |
| `sherpa-onnx-shared` | Shared library (`.dylib` in xcframework) | `import SherpaOnnxShared` |
## Using SPM (Swift Package Manager)
There are two ways to add sherpa-onnx to your Xcode project:
### Option A: Remote Package (from GitHub)
1. In Xcode, open your project
2. Go to **File → Add Package Dependencies...**
3. Enter the repository URL:
```
https://github.com/k2-fsa/sherpa-onnx
```
4. Choose your version rule:
- **Up to Next Major**: e.g. `1.13.0 ..< 2.0.0`
- **Exact**: e.g. `1.13.4`
- **Branch**: e.g. `master`
5. Click **Add Package**
6. Select the product you want (`sherpa-onnx` or `sherpa-onnx-shared`) and click **Add Package**
### Option B: Local Package (from source)
If you have the sherpa-onnx source code checked out locally:
1. In Xcode, open your project
2. Go to **File → Add Package Dependencies...**
3. Click **Add Local...** in the bottom-left corner
4. Navigate to the sherpa-onnx source directory and click **Add Package**
5. Select the product you want (`sherpa-onnx` or `sherpa-onnx-shared`) and click **Add Package**
Alternatively, you can manually edit the `.pbxproj` file:
```
/* XCLocalSwiftPackageReference section */
C96194D3301EED750025FCCA /* XCLocalSwiftPackageReference "../../path/to/sherpa-onnx" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "../../path/to/sherpa-onnx";
};
```
### Verifying the Package is Added
After adding the package, you should see it listed in:
- **Project Navigator** (left sidebar) → under the **Package Dependencies** section
- **Target → General → Frameworks, Libraries, and Embedded Content**
## Choosing Between Static and Shared Libraries
The sherpa-onnx package provides two library variants, each backed by its own xcframework:
| Product | XCFramework Type | Swift Import |
|---|---|---|
| `sherpa-onnx` | Static xcframework (default) | `import SherpaOnnx` |
| `sherpa-onnx-shared` | Shared/dynamic xcframework | `import SherpaOnnxShared` |
- **`sherpa-onnx`** links statically — the sherpa-onnx code is compiled directly into your app binary. This is the default and recommended option for most apps.
- **`sherpa-onnx-shared`** links dynamically — the sherpa-onnx code lives in a separate `.framework` that is embedded into your app bundle at runtime.
### How to Switch
1. **In Xcode**, open your project and go to the target's **General** tab
2. Under **Frameworks, Libraries, and Embedded Content**, remove the current library
3. Click **+** and add the desired product (`sherpa-onnx` or `sherpa-onnx-shared`)
4. Rebuild — no Swift code changes needed (see below)
### Auto-detecting the Import
You do **not** need to manually change your import statements when switching between `sherpa-onnx` and `sherpa-onnx-shared`. Use `#if canImport(...)` in your Swift code to automatically detect which product is available:
```swift
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
```
This way the same source code works with either product. The `#if canImport(...)` check runs at compile time — if `SherpaOnnx` is available it uses that, otherwise it falls back to `SherpaOnnxShared`. If neither is found, the build fails with a clear error message.
## How to Clean Xcode SPM Cache
### Option 1: Xcode Menu
`File → Packages → Reset Package Caches`
### Option 2: Command Line
```bash
# Clear SPM artifact cache
rm -rf ~/Library/Caches/org.swift.swiftpm
# Clear Xcode DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData
```
### Option 3: Clean Build Folder
In Xcode: `Product → Clean Build Folder` (Shift+Cmd+K)
## Troubleshooting
### Checksum Mismatch
If you see an error like:
```
checksum of downloaded artifact of binary target 'SherpaOnnxIOS' (...) does not match checksum specified by the manifest (...)
```
This means Xcode's SPM cache has a stale artifact. Fix:
1. `File → Packages → Reset Package Caches`
2. Restart Xcode
3. Rebuild
### Missing Package Product
If you see `Missing package product 'sherpa-onnx-shared'`:
1. Verify the local package path is correct in project settings
2. Reset package caches
3. Re-resolve packages: `File → Packages → Resolve Package Versions`
### No Such Module
If you see `No such module 'SherpaOnnxShared'` or `No such module 'SherpaOnnx'`:
- Make sure you have added one of the two products (`sherpa-onnx` or `sherpa-onnx-shared`) to your target
- If using `#if canImport(...)` as recommended above, the code will automatically pick the right module
- If importing manually, make sure the import matches the product you added
### Duplicate Output File (Shared Library Only)
If you see an error like:
```
duplicate output file '...SherpaOnnxC.framework' on task: Copy ...
```
This is a known Xcode issue with SPM dynamic (shared) frameworks — Xcode sometimes generates duplicate "Copy" build phases. Fix:
1. Close Xcode
2. Delete DerivedData:
```bash
rm -rf ~/Library/Developer/Xcode/DerivedData/SherpaOnnxTts-*
```
3. Open Xcode
4. `File → Packages → Reset Package Caches`
5. Rebuild
If it still happens, open the target's **Build Phases** tab in Xcode and look for duplicate **Embed Frameworks** or **Copy Files** phases that both reference `SherpaOnnxC.framework`. Remove the duplicate if found.
@@ -5,7 +5,13 @@
// Created by fangjun on 2023/9/11.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
struct ContentView: View {
@@ -5,7 +5,13 @@
// Created by knight on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import AVFoundation
extension AudioBuffer {
@@ -1,4 +1,10 @@
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
import Foundation
@@ -5,7 +5,13 @@
// Created by fangjun on 2023/9/11.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
@main
@@ -5,7 +5,13 @@
// Created by knight on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
import Foundation
import AVFoundation
@@ -5,7 +5,13 @@
// Created by fangjun on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
struct ContentView: View {
@@ -5,7 +5,13 @@
// Created by knight on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import AVFoundation
extension AudioBuffer {
@@ -1,4 +1,10 @@
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
import Foundation
@@ -5,7 +5,13 @@
// Created by fangjun on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
@main
@@ -5,7 +5,13 @@
// Created by knight on 2023/4/5.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import AVFoundation
import Foundation
@@ -6,7 +6,13 @@
//
import XCTest
#if canImport(SherpaOnnx)
@testable import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
@testable import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
final class SherpaOnnxTests: XCTestCase {
@@ -5,7 +5,13 @@
// Created by knight on 2024/4/1.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
struct ContentView: View {
@@ -5,7 +5,13 @@
// Created by knight on 2024/4/1.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
@main
@@ -5,7 +5,13 @@
// Created by knight on 2024/4/1.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
import SwiftUI
import AVFoundation
@@ -5,7 +5,13 @@
// Created by knight on 2023/9/23.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import AVKit
import MediaPlayer
import PhotosUI
@@ -5,7 +5,13 @@
// Created by knight on 2023/9/23.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
@main
@@ -5,7 +5,13 @@
// Created by knight on 2023/9/23.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SherpaOnnxC
import AVFoundation
import PhotosUI
@@ -6,7 +6,13 @@
//
// Text-to-speech with Next-gen Kaldi on iOS without Internet connection
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import SwiftUI
import AVFoundation
import UniformTypeIdentifiers
@@ -5,7 +5,13 @@
// Created by fangjun on 2023/11/23.
//
#if canImport(SherpaOnnx)
import SherpaOnnx
#elseif canImport(SherpaOnnxShared)
import SherpaOnnxShared
#else
#error("SherpaOnnx module not found. Please check your SPM dependency configuration.")
#endif
import Foundation
// used to get the path to espeak-ng-data
+8
View File
@@ -31,7 +31,15 @@ sed -i.bak "s/ static const char \*date.*/ static const char \*date = \"$date\
find scripts/wheel -name "setup.py" -type f -exec sed -i.bak "$replace_str" {} \;
sed -i.bak "$replace_str" ./setup.py
sed -i.bak "$replace_str" ./build-ios.sh
sed -i.bak "$replace_str" ./build-ios-shared.sh
sed -i.bak "$replace_str" ./build-ios-no-tts.sh
sed -i.bak "$replace_str" ./build-macos.sh
sed -i.bak "$replace_str" ./build-macos-shared.sh
for f in ./build-ios.sh ./build-ios-shared.sh ./build-ios-no-tts.sh ./build-macos.sh ./build-macos-shared.sh; do
sed -i.bak "s/$old_version_code/$new_version_code/g" "$f"
done
sed -i.bak "$replace_str" ./pom.xml
sed -i.bak "$replace_str" ./sherpa-onnx/java-api/pom.xml
sed -i.bak "$replace_str" ./sherpa-onnx/java-api/README.md
+3 -2
View File
@@ -52,6 +52,7 @@ def process_android(s, rid):
with open(f"./android-{rid}/sherpa-onnx.runtime.csproj", "w") as f:
f.write(s)
def process_linux(s, rid):
libs = [
"libonnxruntime.so",
@@ -74,9 +75,9 @@ def process_linux(s, rid):
def process_macos(s, rid):
lib_dir = os.path.join(src_dir, f"macos-{rid}")
onnx_libs = glob.glob(os.path.join(lib_dir, "libonnxruntime*.dylib"))
onnx_libs = glob.glob(os.path.join(lib_dir, "libonnxruntime.dylib"))
if not onnx_libs:
raise FileNotFoundError(f"No libonnxruntime*.dylib found in {lib_dir}")
raise FileNotFoundError(f"No libonnxruntime.dylib found in {lib_dir}")
other_libs = [os.path.join(lib_dir, "libsherpa-onnx-c-api.dylib")]
libs = onnx_libs + other_libs
+2 -2
View File
@@ -148,7 +148,7 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.*.dylib libonnxruntime.dylib
# libonnxruntime.dylib is already the correct name (no version suffix)
popd
cd ..
@@ -166,7 +166,7 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.*.dylib libonnxruntime.dylib
# libonnxruntime.dylib is already the correct name (no version suffix)
popd
cd ..
-4
View File
@@ -1,4 +0,0 @@
module SherpaOnnxC {
header "c-api.h"
export *
}
@@ -7,7 +7,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Locale;
import java.util.Objects;
/*
# We support the following loading methods
@@ -96,17 +95,10 @@ public class LibraryUtils {
}
// Load onnxruntime first to avoid picking up a system version
if (Objects.equals(detectedOS, "osx")) {
File onnxruntimeFile = new File(nativeDir, "libonnxruntime.1.27.0.dylib");
if (onnxruntimeFile.exists()) {
System.load(onnxruntimeFile.getAbsolutePath());
}
} else {
String onnxLibFileName = System.mapLibraryName("onnxruntime");
File onnxruntimeFile = new File(nativeDir, onnxLibFileName);
if (onnxruntimeFile.exists()) {
System.load(onnxruntimeFile.getAbsolutePath());
}
String onnxLibFileName = System.mapLibraryName("onnxruntime");
File onnxruntimeFile = new File(nativeDir, onnxLibFileName);
if (onnxruntimeFile.exists()) {
System.load(onnxruntimeFile.getAbsolutePath());
}
System.load(libInDir.getAbsolutePath());
@@ -137,37 +129,21 @@ public class LibraryUtils {
tempDirectory = Files.createTempDirectory("sherpa-onnx-java");
if (Objects.equals(detectedOS, "osx")) {
// for macos, we need to first load libonnxruntime.1.27.0.dylib
String onnxruntimePath = "sherpa-onnx/native/" + getOsArch() + '/' + "libonnxruntime.1.27.0.dylib";
if (!resourceExists(onnxruntimePath)) {
if (debug) {
System.out.printf("%s does not exist\n", onnxruntimePath);
}
return false;
String onnxLibFileName = System.mapLibraryName("onnxruntime");
String onnxruntimePath = "sherpa-onnx/native/" + getOsArch() + '/' + onnxLibFileName;
if (!resourceExists(onnxruntimePath)) {
if (debug) {
System.out.printf("%s does not exist\n", onnxruntimePath);
}
File tempFile = tempDirectory.resolve("libonnxruntime.1.27.0.dylib").toFile();
extractResource(onnxruntimePath, tempFile);
System.load(tempFile.getAbsolutePath());
} else {
String onnxLibFileName = System.mapLibraryName("onnxruntime");
String onnxruntimePath = "sherpa-onnx/native/" + getOsArch() + '/' + onnxLibFileName;
if (!resourceExists(onnxruntimePath)) {
if (debug) {
System.out.printf("%s does not exist\n", onnxruntimePath);
}
return false;
}
File tempFile = tempDirectory.resolve(onnxLibFileName).toFile();
extractResource(onnxruntimePath, tempFile);
System.load(tempFile.getAbsolutePath());
return false;
}
File tempFile = tempDirectory.resolve(libFileName).toFile();
File tempFile = tempDirectory.resolve(onnxLibFileName).toFile();
extractResource(onnxruntimePath, tempFile);
System.load(tempFile.getAbsolutePath());
tempFile = tempDirectory.resolve(libFileName).toFile();
extractResource(sherpaOnnxJniPath, tempFile);
System.load(tempFile.getAbsolutePath());
} finally {
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -18,11 +18,11 @@ if [ ! -e ./add-punctuation-online ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./add-punctuation-online.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o ./add-punctuation-online
@@ -32,5 +32,5 @@ else
fi
# Set library path and run the executable
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./add-punctuation-online
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./add-punctuations ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./add-punctuations.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o ./add-punctuations
@@ -30,5 +30,5 @@ else
echo "./add-punctuations exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./add-punctuations
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -25,11 +25,11 @@ fi
if [ ! -e ./cohere-transcribe ]; then
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./cohere-transcribe.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o cohere-transcribe
@@ -38,5 +38,5 @@ else
echo "./cohere-transcribe exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./cohere-transcribe
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -34,11 +34,11 @@ if [ ! -e ./compute-speaker-embeddings ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./compute-speaker-embeddings.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o compute-speaker-embeddings
@@ -47,5 +47,5 @@ else
echo "./compute-speaker-embeddings exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./compute-speaker-embeddings
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -24,11 +24,11 @@ if [ ! -e ./decode-file-non-streaming ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./decode-file-non-streaming.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o decode-file-non-streaming
@@ -37,5 +37,5 @@ else
echo "./decode-file-non-streaming exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./decode-file-non-streaming
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -23,15 +23,15 @@ if [ ! -d dict ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/hr-files/lexicon.txt
fi
if [ ! -e ./decode-file-sense-voice-with-hr ]; then
if [ ! -e ./decode-file-sense-voice-with-hr ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./decode-file-sense-voice-with-hr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./decode-file-sense-voice-with-hr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o decode-file-sense-voice-with-hr
@@ -40,5 +40,5 @@ else
echo "./decode-file-sense-voice-with-hr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./decode-file-sense-voice-with-hr
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -15,15 +15,15 @@ if [ ! -d ./sherpa-onnx-streaming-t-one-russian-2025-09-08 ]; then
rm sherpa-onnx-streaming-t-one-russian-2025-09-08.tar.bz2
fi
if [ ! -e ./decode-file-t-one-streaming ]; then
if [ ! -e ./decode-file-t-one-streaming ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./decode-file-t-one-streaming ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./decode-file-t-one-streaming.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o decode-file-t-one-streaming
@@ -32,5 +32,5 @@ else
echo "./decode-file-t-one-streaming exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./decode-file-t-one-streaming
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -26,15 +26,15 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13 ]; then
rm sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13.tar.bz2
fi
if [ ! -e ./decode-file ]; then
if [ ! -e ./decode-file ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./decode-file ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./decode-file.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o decode-file
@@ -43,5 +43,5 @@ else
echo "./decode-file exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./decode-file
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -21,15 +21,15 @@ if [ ! -f ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.o
ls -lh sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02
fi
if [ ! -e ./dolphin-ctc-asr ]; then
if [ ! -e ./dolphin-ctc-asr ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./dolphin-ctc-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./dolphin-ctc-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o dolphin-ctc-asr
@@ -38,5 +38,5 @@ else
echo "./dolphin-ctc-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./dolphin-ctc-asr
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -22,15 +22,15 @@ if [ ! -f ./sherpa-onnx-fire-red-asr2-ctc-zh_en-int8-2026-02-25/model.int8.onnx
ls -lh sherpa-onnx-fire-red-asr2-ctc-zh_en-int8-2026-02-25
fi
if [ ! -e ./fire-red-asr-ctc ]; then
if [ ! -e ./fire-red-asr-ctc ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./fire-red-asr-ctc ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./fire-red-asr-ctc.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o fire-red-asr-ctc
@@ -39,5 +39,5 @@ else
echo "./fire-red-asr-ctc exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./fire-red-asr-ctc
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -25,11 +25,11 @@ if [ ! -e ./fire-red-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./fire-red-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o fire-red-asr
@@ -38,5 +38,5 @@ else
echo "./fire-red-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./fire-red-asr
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./funasr-nano ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./funasr-nano.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o funasr-nano
@@ -30,6 +30,6 @@ else
echo "./funasr-nano exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./funasr-nano
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -29,11 +29,11 @@ if [ ! -e ./generate-subtitles-ten-vad ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./generate-subtitles.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o generate-subtitles-ten-vad
@@ -42,5 +42,5 @@ else
echo "./generate-subtitles-ten-vad exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./generate-subtitles-ten-vad
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -29,11 +29,11 @@ if [ ! -e ./generate-subtitles ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./generate-subtitles.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o generate-subtitles
@@ -42,5 +42,5 @@ else
echo "./generate-subtitles exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./generate-subtitles
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./keyword-spotting-from-file ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./keyword-spotting-from-file.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o keyword-spotting-from-file
@@ -30,5 +30,5 @@ else
echo "./keyword-spotting-from-file exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./keyword-spotting-from-file
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./medasr-ctc ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./medasr-ctc.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o medasr-ctc
@@ -30,5 +30,5 @@ else
echo "./medasr-ctc exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./medasr-ctc
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -25,11 +25,11 @@ if [ ! -e ./moonshine-v2-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./moonshine-v2-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o moonshine-v2-asr
@@ -38,5 +38,5 @@ else
echo "./moonshine-v2-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./moonshine-v2-asr
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./omnilingual-asr-ctc ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./omnilingual-asr-ctc.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o omnilingual-asr-ctc
@@ -30,5 +30,5 @@ else
echo "./omnilingual-asr-ctc exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./omnilingual-asr-ctc
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -18,11 +18,11 @@ fi
if [ ! -e ./online-speech-enhancement-dpdfnet ]; then
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./online-speech-enhancement-dpdfnet.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o online-speech-enhancement-dpdfnet
@@ -31,5 +31,5 @@ else
echo "./online-speech-enhancement-dpdfnet exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./online-speech-enhancement-dpdfnet
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -18,11 +18,11 @@ fi
if [ ! -e ./online-speech-enhancement-gtcrn ]; then
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./online-speech-enhancement-gtcrn.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o online-speech-enhancement-gtcrn
@@ -31,5 +31,5 @@ else
echo "./online-speech-enhancement-gtcrn exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./online-speech-enhancement-gtcrn
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -26,11 +26,11 @@ if [ ! -e ./qwen3-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./qwen3-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o qwen3-asr
@@ -39,5 +39,5 @@ else
echo "./qwen3-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./qwen3-asr
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -21,11 +21,11 @@ if [ ! -e ./source-separation-spleeter ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./source-separation-spleeter.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o source-separation-spleeter
@@ -34,5 +34,5 @@ else
echo "./source-separation-spleeter exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./source-separation-spleeter
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -19,11 +19,11 @@ if [ ! -e ./source-separation-uvr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./source-separation-uvr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o source-separation-uvr
@@ -32,5 +32,5 @@ else
echo "./source-separation-uvr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./source-separation-uvr
@@ -18,11 +18,11 @@ if [ ! -e ./speaker-diarization ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./speaker-diarization.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o speaker-diarization
@@ -31,5 +31,5 @@ else
echo "./speaker-diarization exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./speaker-diarization
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -18,11 +18,11 @@ fi
if [ ! -e ./speech-enhancement-dpdfnet ]; then
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./speech-enhancement-dpdfnet.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o speech-enhancement-dpdfnet
@@ -31,5 +31,5 @@ else
echo "./speech-enhancement-dpdfnet exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./speech-enhancement-dpdfnet
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -19,11 +19,11 @@ if [ ! -e ./speech-enhancement-gtcrn ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./speech-enhancement-gtcrn.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o speech-enhancement-gtcrn
@@ -32,5 +32,5 @@ else
echo "./speech-enhancement-gtcrn exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./speech-enhancement-gtcrn
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -19,11 +19,11 @@ if [ ! -e ./spoken-language-identification ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./spoken-language-identification.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o spoken-language-identification
@@ -32,5 +32,5 @@ else
echo "./spoken-language-identification exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./spoken-language-identification
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -15,15 +15,15 @@ if [ ! -f ./sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18/HLG.fst ]; then
rm sherpa-onnx-streaming-zipformer-ctc-small-2024-03-18.tar.bz2
fi
if [ ! -e ./streaming-hlg-decode-file ]; then
if [ ! -e ./streaming-hlg-decode-file ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./streaming-hlg-decode-file ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./streaming-hlg-decode-file.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o streaming-hlg-decode-file
@@ -32,5 +32,5 @@ else
echo "./streaming-hlg-decode-file exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./streaming-hlg-decode-file
+7 -7
View File
@@ -2,20 +2,20 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
if [ ! -e ./test-version ]; then
if [ ! -e ./test-version ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./test-version ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./test-version.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o ./test-version
@@ -24,5 +24,5 @@ else
echo "./test-version exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./test-version
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -44,15 +44,15 @@ if [ ! -d "${model_dir}/espeak-ng-data" ]; then
mv espeak-ng-data "${model_dir}/"
fi
if [ ! -e ./tts-kitten-en ] || [ ./tts-kitten-en.swift -nt ./tts-kitten-en ] || [ ./SherpaOnnx.swift -nt ./tts-kitten-en ]; then
if [ ! -e ./tts-kitten-en ] || [ ./tts-kitten-en.swift -nt ./tts-kitten-en ] || [ ./SherpaOnnx.swift -nt ./tts-kitten-en ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./tts-kitten-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-kitten-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-kitten-en
@@ -61,5 +61,5 @@ else
echo "./tts-kitten-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-kitten-en
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -16,15 +16,15 @@ if [ ! -f ./kokoro-en-v0_19/model.onnx ]; then
rm kokoro-en-v0_19.tar.bz2
fi
if [ ! -e ./tts-kokoro-en ]; then
if [ ! -e ./tts-kokoro-en ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./tts-kokoro-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-kokoro-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-kokoro-en
@@ -33,5 +33,5 @@ else
echo "./tts-kokoro-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-kokoro-en
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -16,15 +16,15 @@ if [ ! -f ./kokoro-multi-lang-v1_0/model.onnx ]; then
rm kokoro-multi-lang-v1_0.tar.bz2
fi
if [ ! -e ./tts-kokoro-zh-en ]; then
if [ ! -e ./tts-kokoro-zh-en ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./tts-kokoro-zh-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-kokoro-zh-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-kokoro-zh-en
@@ -33,5 +33,5 @@ else
echo "./tts-kokoro-zh-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-kokoro-zh-en
+7 -7
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -21,15 +21,15 @@ if [ ! -f ./vocos-22khz-univ.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/vocoder-models/vocos-22khz-univ.onnx
fi
if [ ! -e ./tts-matcha-en ]; then
if [ ! -e ./tts-matcha-en ] || [ ../build-macos/install/lib/libsherpa-onnx-c-api.a -nt ./tts-matcha-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-matcha-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-matcha-en
@@ -38,5 +38,5 @@ else
echo "./tts-matcha-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-matcha-en
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -24,11 +24,11 @@ if [ ! -e ./tts-matcha-zh ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-matcha-zh.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-matcha-zh
@@ -37,5 +37,5 @@ else
echo "./tts-matcha-zh exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-matcha-zh
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -20,11 +20,11 @@ if [ ! -e ./tts-pocket-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-pocket-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-pocket-en
@@ -33,5 +33,5 @@ else
echo "./tts-pocket-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-pocket-en
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -20,11 +20,11 @@ if [ ! -e ./tts-supertonic-en ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-supertonic-en.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-supertonic-en
@@ -33,5 +33,5 @@ else
echo "./tts-supertonic-en exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-supertonic-en
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -19,11 +19,11 @@ if [ ! -e ./tts-vits ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-vits.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-vits
@@ -32,5 +32,5 @@ else
echo "./tts-vits exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-vits
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -23,11 +23,11 @@ fi
if [ ! -e ./tts-zipvoice ]; then
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./tts-zipvoice.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o tts-zipvoice
@@ -36,5 +36,5 @@ else
echo "./tts-zipvoice exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./tts-zipvoice
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -17,11 +17,11 @@ if [ ! -e ./wenet-ctc-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./wenet-ctc-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o wenet-ctc-asr
@@ -30,5 +30,5 @@ else
echo "./wenet-ctc-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./wenet-ctc-asr
+6 -6
View File
@@ -2,8 +2,8 @@
set -ex
if [ ! -d ../build-swift-macos ]; then
echo "Please run ../build-swift-macos.sh first!"
if [ ! -d ../build-macos ]; then
echo "Please run ../build-macos.sh first!"
exit 1
fi
@@ -26,11 +26,11 @@ if [ ! -e ./zipformer-ctc-asr ]; then
# Note: We use -lc++ to link against libc++ instead of libstdc++
swiftc \
-lc++ \
-I ../build-swift-macos/install/include \
-I ../build-macos/install/include \
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
./zipformer-ctc-asr.swift ./SherpaOnnx.swift \
-L ../build-swift-macos/install/lib/ \
-l sherpa-onnx \
-L ../build-macos/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime \
-o zipformer-ctc-asr
@@ -39,5 +39,5 @@ else
echo "./zipformer-ctc-asr exists - skip building"
fi
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/../build-macos/install/lib:$DYLD_LIBRARY_PATH
./zipformer-ctc-asr