Fangjun Kuang
Committed by GitHub

Build sherpa-onnx as a single shared library (#1078)

When `-D BUILD_SHARED_LIBS=ON` is passed to `cmake`, it builds a single shared library.

Specifically, 

- For C APIs, it builds `libsherpa-onnx-c-api.so`
- For Python APIs, it builds `_sherpa_onnx.cpython-xx-xx.so`
- For Kotlin and Java APIs, it builds `libsherpa-onnx-jni.so`

There is no `libsherpa-onnx-core.so` any longer.

Note it affects only shared libraries.
正在显示 69 个修改的文件 包含 570 行增加323 行删除
... ... @@ -6,17 +6,6 @@ cd dart-api-examples
pushd non-streaming-asr
echo '----------paraformer itn----------'
./run-paraformer-itn.sh
echo '----------paraformer----------'
./run-paraformer.sh
rm -rf sherpa-onnx-*
echo '----------VAD with paraformer----------'
./run-vad-with-paraformer.sh
rm -rf sherpa-onnx-*
echo '----------NeMo transducer----------'
./run-nemo-transducer.sh
rm -rf sherpa-onnx-*
... ... @@ -37,6 +26,17 @@ echo '----------zipformer transducer----------'
./run-zipformer-transducer.sh
rm -rf sherpa-onnx-*
echo '----------paraformer itn----------'
./run-paraformer-itn.sh
echo '----------paraformer----------'
./run-paraformer.sh
rm -rf sherpa-onnx-*
echo '----------VAD with paraformer----------'
./run-vad-with-paraformer.sh
rm -rf sherpa-onnx-*
popd # non-streaming-asr
pushd tts
... ...
... ... @@ -32,6 +32,7 @@ concurrency:
jobs:
flutter_linux:
if: false
name: linux
runs-on: ${{ matrix.os }}
container: ubuntu:18.04
... ... @@ -49,7 +50,7 @@ jobs:
shell: bash
run: |
apt-get update -y
apt-get install -y build-essential jq git cmake
apt-get install -y build-essential jq git cmake
apt-get install -y curl
- name: Setup Flutter SDK
... ...
... ... @@ -37,7 +37,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-14]
os: [ubuntu-latest, macos-latest, macos-13]
steps:
- uses: actions/checkout@v4
... ...
... ... @@ -72,7 +72,12 @@ jobs:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_GPU=ON ..
cmake \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D CMAKE_INSTALL_PREFIX=./install \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_ENABLE_GPU=ON \
..
- name: Build sherpa-onnx for ubuntu
shell: bash
... ... @@ -86,6 +91,12 @@ jobs:
ls -lh lib
ls -lh bin
echo "----"
ls -lh install/lib
echo "----"
ls -lh install/bin
- name: Display dependencies of sherpa-onnx for linux
shell: bash
run: |
... ...
... ... @@ -95,7 +95,13 @@ jobs:
mkdir build
cd build
cmake -DSHERPA_ONNX_ENABLE_TTS=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install -DSHERPA_ONNX_ENABLE_JNI=ON ..
cmake \
-D SHERPA_ONNX_ENABLE_TTS=ON \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D CMAKE_INSTALL_PREFIX=./install \
-D SHERPA_ONNX_ENABLE_JNI=ON \
..
make -j2
make install
... ... @@ -105,6 +111,12 @@ jobs:
rm -rf ./install/pkgconfig
rm -rf ./install/share
echo "----"
ls -lh install/lib
echo "----"
ls -lh install/bin
- name: Display dependencies of sherpa-onnx for linux
shell: bash
run: |
... ...
... ... @@ -99,7 +99,12 @@ jobs:
mkdir build
cd build
cmake -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install ..
cmake \
-D SHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-D CMAKE_INSTALL_PREFIX=./install \
..
make -j2
make install
... ... @@ -107,6 +112,12 @@ jobs:
ls -lh lib
ls -lh bin
echo "----"
ls -lh install/lib
echo "----"
ls -lh install/bin
- name: Display dependencies of sherpa-onnx for linux
shell: bash
run: |
... ...
... ... @@ -52,8 +52,8 @@ jobs:
cmake \
-D BUILD_SHARED_LIBS=ON \
-D CMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DSHERPA_ONNX_ENABLE_JNI=ON \
-D CMAKE_OSX_ARCHITECTURES=$arch \
-D SHERPA_ONNX_ENABLE_JNI=ON \
-DCMAKE_INSTALL_PREFIX=./install \
..
... ...
... ... @@ -84,7 +84,13 @@ jobs:
BUILD_SHARED_LIBS=ON
fi
cmake -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} -D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_INSTALL_PREFIX=./install ..
cmake \
-DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
-D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D CMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-D CMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for macos
shell: bash
... ...
... ... @@ -93,17 +93,12 @@ jobs:
make install
ls -lh ./install/lib
rm -v ./install/lib/libonnxruntime.so
- name: Copy pre-built libs
shell: bash
run: |
cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/
pushd flutter/sherpa_onnx_linux/linux/
rm libonnxruntime.so
ln -s libonnxruntime.so.* ./libonnxruntime.so
popd
mv -v flutter/sherpa_onnx_linux /tmp/to_be_published
... ... @@ -197,27 +192,19 @@ jobs:
cd build
make -j2 install
ls -lh install/lib/libsherpa-onnx-core.dylib
file install/lib/libsherpa-onnx-core.dylib
ls -lh install/lib/libsherpa-onnx-c-api.dylib
file install/lib/libsherpa-onnx-c-api.dylib
rm -v install/lib/libonnxruntime.dylib
- name: Copy pre-built libs
shell: bash
run: |
cp -v build/install/lib/lib*.dylib* flutter/sherpa_onnx_macos/macos/
mv -v flutter/sherpa_onnx_macos /tmp/to_be_published
ls -lh /tmp/to_be_published/macos
pushd /tmp/to_be_published/macos
rm libonnxruntime.dylib
ls -lh
popd
- name: Release
shell: bash
run: |
... ... @@ -283,7 +270,7 @@ jobs:
shell: bash
run: |
cd build
cmake --build . --target install --config Release
cmake --build . --target install --config Release -- -m:2
ls -lh install/lib/*.dll
... ...
... ... @@ -123,8 +123,16 @@ jobs:
ls -lh build-riscv64-linux-gnu/bin
ls -lh build-riscv64-linux-gnu/lib
echo "---install/lib---"
ls -lh build-riscv64-linux-gnu/install/lib
echo "---install/bin---"
ls -lh build-riscv64-linux-gnu/install/bin
file build-riscv64-linux-gnu/bin/sherpa-onnx
readelf -d build-riscv64-linux-gnu/bin/sherpa-onnx
- name: Test sherpa-onnx
shell: bash
run: |
... ...
... ... @@ -78,7 +78,7 @@ jobs:
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile setuptools wheel
- name: Install sherpa-onnx
shell: bash
... ... @@ -87,7 +87,7 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
python3 setup.py install
python3 -m pip install .
- name: Test sherpa-onnx
shell: bash
... ...
... ... @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-14]
os: [macos-latest, macos-13]
steps:
- uses: actions/checkout@v4
... ...
... ... @@ -110,10 +110,20 @@ jobs:
python3 setup.py bdist_wheel
ls -lh dist
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.python-version }}
path: ./dist/*.whl
- name: Display wheel
shell: bash
run: |
ls -lh dist
cd dist
mkdir t
cd t
unzip ../*.whl
- name: Install wheel
shell: bash
... ...
... ... @@ -70,7 +70,7 @@ jobs:
cd build
cmake \
-D BUILD_SHARED_LIBS=ON \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
... ...
... ... @@ -26,8 +26,10 @@ jobs:
include:
- os: ubuntu-latest
arch: amd64
- os: macos-latest
- os: macos-13
arch: amd64
- os: macos-14
arch: arm64
- os: windows-latest
arch: x64
- os: windows-latest
... ...
... ... @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, macos-14]
os: [macos-latest, macos-13, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
... ... @@ -67,12 +67,63 @@ jobs:
- name: Build sherpa-onnx
shell: bash
run: |
upload_dir=$PWD/to-upload
mkdir -p $upload_dir
echo "upload_dir"
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
mkdir build
cd build
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF ..
make -j1
cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/
cmake \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..
if [[ ${{ matrix.os }} == windows-latest ]]; then
cmake --build . --target install --config Release -- -m:2
else
make -j2 install
fi
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
cp -v ./lib/*.so $upload_dir
cp -v _deps/onnxruntime-src/lib/libonnxruntime*so* $upload_dir
cp -v _deps/onnxruntime-src/lib/libonnxruntime*so* ./lib/
rm -v ./lib/libonnxruntime.so
cd lib
ln -s libonnxruntime.so.1.17.1 libonnxruntime.so
cd ..
rm -v ./lib/*.a
ls -h ./lib
elif [[ ${{ matrix.os }} == windows-latest ]]; then
cp -v ./install/lib/sherpa-onnx-c-api.dll ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
cp -v ./install/lib/onnxruntime.dll ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
ls -lh ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/speaker-identification/
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/streaming-hlg-decoding/
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/non-streaming-tts/
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/non-streaming-decode-files/
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/streaming-decode-files/
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 lib/*.dylib $upload_dir
cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/
rm ./lib/*.a
rm ./lib/libonnxruntime.dylib
cd lib
ln -s libonnxruntime.1.17.1.dylib libonnxruntime.dylib
cd ..
fi
cd ../scripts/go/_internal/
ls -lh lib
... ... @@ -83,6 +134,11 @@ jobs:
go mod tidy
go build
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-libs
path: to-upload/
- name: Test speaker identification
shell: bash
run: |
... ... @@ -95,7 +151,7 @@ jobs:
cd scripts/go/_internal/streaming-hlg-decoding/
./run.sh
- name: Test non-streaming TTS (macOS)
- name: Test non-streaming TTS
shell: bash
run: |
mkdir tts-waves
... ... @@ -130,7 +186,7 @@ jobs:
name: tts-waves-${{ matrix.os }}
path: tts-waves
- name: Test non-streaming decoding files (macOS)
- name: Test non-streaming decoding files
shell: bash
run: |
cd scripts/go/_internal/non-streaming-decode-files/
... ...
... ... @@ -57,7 +57,7 @@ jobs:
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel
- name: Install sherpa-onnx
shell: bash
... ... @@ -66,7 +66,7 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
python3 setup.py install
python3 -m pip install .
python3 -m pip install websockets
- name: Start server for transducer models
... ...
... ... @@ -57,7 +57,7 @@ jobs:
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel
- name: Install sherpa-onnx
shell: bash
... ... @@ -66,7 +66,7 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
python3 setup.py install
python3 -m pip install .
python3 -m pip install websockets
- name: Start server for zipformer2 CTC models
... ...
... ... @@ -47,7 +47,14 @@ jobs:
run: |
mkdir build
cd build
cmake -A ARM64 -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_ESPEAK_NG_EXE=OFF ..
cmake \
-A ARM64 \
-DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-D CMAKE_INSTALL_PREFIX=./install \
-D BUILD_ESPEAK_NG_EXE=OFF \
..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -57,7 +57,13 @@ jobs:
run: |
mkdir build
cd build
cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install -DSHERPA_ONNX_ENABLE_GPU=ON ..
cmake \
-A x64 \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D CMAKE_INSTALL_PREFIX=./install \
-D SHERPA_ONNX_ENABLE_GPU=ON \
..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -59,7 +59,12 @@ jobs:
run: |
mkdir build
cd build
cmake -A x64 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install ..
cmake \
-A x64 \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-D CMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -37,7 +37,13 @@ jobs:
run: |
mkdir build
cd build
cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX=./install ..
cmake \
-A x64 \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D SHERPA_ONNX_ENABLE_JNI=ON \
-D CMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -63,7 +63,13 @@ jobs:
run: |
mkdir build
cd build
cmake -A x64 -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install ..
cmake \
-A x64 \
-DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-DCMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -59,7 +59,11 @@ jobs:
run: |
mkdir build
cd build
cmake -A Win32 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install ..
cmake \
-A Win32 \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-D CMAKE_INSTALL_PREFIX=./install ..
- name: Build sherpa-onnx for windows
shell: bash
... ...
... ... @@ -63,14 +63,20 @@ jobs:
run: |
mkdir build
cd build
cmake -A Win32 -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install ..
cmake \
-A Win32 \
-DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
-D CMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for windows
shell: bash
run: |
cd build
cmake --build . --config Release -- -m:2
cmake --build . --config Release --target install -- -m:2
cmake --build . --config Release
cmake --build . --config Release --target install
ls -lh ./bin/Release/sherpa-onnx.exe
... ...
## 1.10.10
* Build sherpa-onnx into a single shared library.
## 1.10.9
* Fix released packages. piper-phonemize was not included in v1.10.8.
... ...
... ... @@ -2,13 +2,16 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version. Used only for macOS")
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
project(sherpa-onnx)
# Remember to update
# ./nodejs-addon-examples
# ./dart-api-examples/
# ./sherpa-onnx/flutter/CHANGELOG.md
set(SHERPA_ONNX_VERSION "1.10.9")
set(SHERPA_ONNX_VERSION "1.10.10")
# Disable warning about
#
... ... @@ -18,6 +21,21 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo)
if(ipo)
message(STATUS "IPO is enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
else()
message(STATUS "IPO is not available")
endif()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(SHERPA_ONNX_ENABLE_PYTHON "Whether to build Python" OFF)
option(SHERPA_ONNX_ENABLE_TESTS "Whether to build tests" OFF)
option(SHERPA_ONNX_ENABLE_CHECK "Whether to build with assert" OFF)
... ... @@ -53,8 +71,10 @@ else()
set(SHERPA_ONNX_RPATH_ORIGIN "@loader_path")
endif()
set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
if(NOT WIN32)
set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
endif()
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
... ... @@ -89,22 +109,16 @@ to install CUDA toolkit if you have not installed it.")
endif()
endif()
if(BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
if(NOT BUILD_SHARED_LIBS AND MSVC)
# see https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
# https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
if(MSVC)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
$<$<CONFIG:RelWithDebInfo>:/MT>
$<$<CONFIG:MinSizeRel>:/MT>
)
endif()
# see https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
# https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
if(MSVC)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
$<$<CONFIG:RelWithDebInfo>:/MT>
$<$<CONFIG:MinSizeRel>:/MT>
)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
... ... @@ -325,17 +339,21 @@ if(NOT BUILD_SHARED_LIBS)
endif()
endif()
if(NOT BUILD_SHARED_LIBS)
# See https://people.freedesktop.org/~dbn/pkg-config-guide.html
if(SHERPA_ONNX_ENABLE_TTS)
configure_file(cmake/sherpa-onnx.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
if(SHERPA_ONNX_ENABLE_TTS)
configure_file(cmake/sherpa-onnx-static.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
else()
configure_file(cmake/sherpa-onnx-static-no-tts.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
endif()
else()
configure_file(cmake/sherpa-onnx-no-tts.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
configure_file(cmake/sherpa-onnx-shared.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
endif()
install(
FILES
${PROJECT_BINARY_DIR}/sherpa-onnx.pc
DESTINATION
.
./
)
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
... ...
... ... @@ -118,18 +118,6 @@ rm -rf install/lib/pkgconfig
# cd /data/local/tmp
# ./sherpa-onnx
#
# which shows the following error log:
#
# CANNOT LINK EXECUTABLE "./sherpa-onnx": library "libsherpa-onnx-core.so" not found: needed by main executable
#
# Please run:
#
# export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
#
# and then you can run:
#
# ./sherpa-onnx
#
# It should show the help message of sherpa-onnx.
#
# Please use the above approach to copy model files to your phone.
... ...
... ... @@ -11,7 +11,7 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
exit 1
fi
if [[ ! -f ../build/lib/libsherpa-onnx-core.a && ! -f ../build/lib/libsherpa-onnx-core.dylib && ! -f ../build/lib/libsherpa-onnx-core.so ]]; then
if [[ ! -f ../build/lib/libsherpa-onnx-c-api.a && ! -f ../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../build/lib/libsherpa-onnx-c-api.so ]]; then
echo "Please build sherpa-onnx first. You can use"
echo ""
echo " cd /path/to/sherpa-onnx"
... ...
... ... @@ -76,19 +76,8 @@ def get_binaries():
if is_windows():
binaries += [
"espeak-ng.dll",
"kaldi-decoder-core.dll",
"kaldi-native-fbank-core.dll",
"onnxruntime.dll",
"ssentencepiece_core.dll",
"piper_phonemize.dll",
"sherpa-onnx-c-api.dll",
"sherpa-onnx-core.dll",
"sherpa-onnx-fstfar.dll",
"sherpa-onnx-fst.dll",
"sherpa-onnx-kaldifst-core.dll",
"sherpa-onnx-portaudio.dll",
"ucd.dll",
]
return binaries
... ... @@ -145,6 +134,7 @@ class BuildExtension(build_ext):
extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF "
extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF "
extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON "
extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF "
extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF "
... ... @@ -161,7 +151,7 @@ class BuildExtension(build_ext):
if is_windows():
build_cmd = f"""
cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
cmake --build {self.build_temp} --target install --config Release -- -m
cmake --build {self.build_temp} --target install --config Release -- -m:2
"""
print(f"build command is:\n{build_cmd}")
ret = os.system(
... ... @@ -171,7 +161,7 @@ class BuildExtension(build_ext):
raise Exception("Failed to configure sherpa")
ret = os.system(
f"cmake --build {self.build_temp} --target install --config Release -- -m" # noqa
f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa
)
if ret != 0:
raise Exception("Failed to build and install sherpa")
... ... @@ -226,5 +216,11 @@ class BuildExtension(build_ext):
shutil.rmtree(f"{install_dir}/share")
shutil.rmtree(f"{install_dir}/lib/pkgconfig")
if is_linux():
os.remove(f"{install_dir}/lib/libonnxruntime.so")
if is_macos():
os.remove(f"{install_dir}/lib/libonnxruntime.dylib")
if is_windows():
shutil.rmtree(f"{install_dir}/lib")
... ...
function(download_espeak_ng_for_piper)
include(FetchContent)
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
set(espeak_ng_HASH "SHA256=745e35b21ece6804b4a1839722f9e625ac909380c8f85873ad71bf145877075a")
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
set(espeak_ng_HASH "SHA256=70cbf4050e7a014aae19140b05e57249da4720f56128459fbe3a93beaf971ae6")
set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE)
set(USE_ASYNC OFF CACHE BOOL "" FORCE)
... ... @@ -21,11 +21,11 @@ function(download_espeak_ng_for_piper)
# If you don't have access to the Internet,
# please pre-download kaldi-decoder
set(possible_file_locations
$ENV{HOME}/Downloads/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
${CMAKE_SOURCE_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
${CMAKE_BINARY_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
/tmp/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
/star-fj/fangjun/download/github/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
$ENV{HOME}/Downloads/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
${CMAKE_SOURCE_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
${CMAKE_BINARY_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
/tmp/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
/star-fj/fangjun/download/github/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
)
foreach(f IN LISTS possible_file_locations)
... ... @@ -53,7 +53,23 @@ function(download_espeak_ng_for_piper)
message(STATUS "espeak-ng is downloaded to ${espeak_ng_SOURCE_DIR}")
message(STATUS "espeak-ng binary dir is ${espeak_ng_BINARY_DIR}")
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${espeak_ng_SOURCE_DIR} ${espeak_ng_BINARY_DIR})
if(_build_shared_libs_bak)
set_target_properties(espeak-ng
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
set(espeak_ng_SOURCE_DIR ${espeak_ng_SOURCE_DIR} PARENT_SCOPE)
if(WIN32 AND MSVC)
... ... @@ -107,27 +123,11 @@ function(download_espeak_ng_for_piper)
${espeak_ng_SOURCE_DIR}/src/ucd-tools/src/include
)
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS
espeak-ng
ucd
DESTINATION ..)
else()
install(TARGETS
espeak-ng
ucd
DESTINATION lib)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ucd DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS
espeak-ng
ucd
DESTINATION bin)
DESTINATION lib)
endif()
endfunction()
... ...
... ... @@ -45,8 +45,25 @@ function(download_kaldi_decoder)
message(STATUS "kaldi-decoder's binary dir is ${kaldi_decoder_BINARY_DIR}")
include_directories(${kaldi_decoder_SOURCE_DIR})
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${kaldi_decoder_SOURCE_DIR} ${kaldi_decoder_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(
kaldi-decoder-core
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
if(WIN32 AND MSVC)
target_compile_options(kaldi-decoder-core PUBLIC
/wd4018
... ... @@ -58,14 +75,7 @@ function(download_kaldi_decoder)
INTERFACE
${kaldi-decoder_SOURCE_DIR}/
)
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS
kaldi-decoder-core
kaldifst_core
fst
fstfar
DESTINATION ..)
else()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS
kaldi-decoder-core
kaldifst_core
... ... @@ -73,15 +83,6 @@ function(download_kaldi_decoder)
fstfar
DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS
kaldi-decoder-core
kaldifst_core
fst
fstfar
DESTINATION bin)
endif()
endfunction()
download_kaldi_decoder()
... ...
... ... @@ -44,20 +44,30 @@ function(download_kaldi_native_fbank)
message(STATUS "kaldi-native-fbank is downloaded to ${kaldi_native_fbank_SOURCE_DIR}")
message(STATUS "kaldi-native-fbank's binary dir is ${kaldi_native_fbank_BINARY_DIR}")
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${kaldi_native_fbank_SOURCE_DIR} ${kaldi_native_fbank_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(kaldi-native-fbank-core
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
target_include_directories(kaldi-native-fbank-core
INTERFACE
${kaldi_native_fbank_SOURCE_DIR}/
)
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS kaldi-native-fbank-core DESTINATION ..)
else()
install(TARGETS kaldi-native-fbank-core DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS kaldi-native-fbank-core DESTINATION bin)
if(NOT BUILD_SHARED_LIBS)
install(TARGETS kaldi-native-fbank-core DESTINATION lib)
endif()
endfunction()
... ...
... ... @@ -43,8 +43,23 @@ function(download_kaldifst)
list(APPEND CMAKE_MODULE_PATH ${kaldifst_SOURCE_DIR}/cmake)
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${kaldifst_SOURCE_DIR} ${kaldifst_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(kaldifst_core
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
target_include_directories(kaldifst_core
PUBLIC
${kaldifst_SOURCE_DIR}/
... ...
... ... @@ -67,7 +67,24 @@ function(download_openfst)
FetchContent_Populate(openfst)
endif()
message(STATUS "openfst is downloaded to ${openfst_SOURCE_DIR}")
if(_build_shared_libs_bak)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(fst fstfar
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE)
set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst")
... ...
... ... @@ -40,8 +40,23 @@ function(download_piper_phonemize)
message(STATUS "piper-phonemize is downloaded to ${piper_phonemize_SOURCE_DIR}")
message(STATUS "piper-phonemize binary dir is ${piper_phonemize_BINARY_DIR}")
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${piper_phonemize_SOURCE_DIR} ${piper_phonemize_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(piper_phonemize
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
if(WIN32 AND MSVC)
target_compile_options(piper_phonemize PUBLIC
/wd4309
... ... @@ -53,21 +68,11 @@ function(download_piper_phonemize)
${piper_phonemize_SOURCE_DIR}/src/include
)
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS
piper_phonemize
DESTINATION ..)
else()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS
piper_phonemize
DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS
piper_phonemize
DESTINATION bin)
endif()
endfunction()
download_piper_phonemize()
... ...
... ... @@ -26,13 +26,9 @@ function(download_portaudio)
endif()
endforeach()
if(BUILD_SHARED_LIBS)
set(PA_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(PA_BUILD_STATIC OFF CACHE BOOL "" FORCE)
else()
set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)
endif()
# Always use static build
set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)
FetchContent_Declare(portaudio
URL
... ... @@ -55,28 +51,17 @@ function(download_portaudio)
add_subdirectory(${portaudio_SOURCE_DIR} ${portaudio_BINARY_DIR} EXCLUDE_FROM_ALL)
if(BUILD_SHARED_LIBS)
set_target_properties(portaudio PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio")
if(NOT WIN32)
target_compile_options(portaudio PRIVATE "-Wno-deprecated-declarations")
endif()
set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")
if(NOT WIN32)
target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")
endif()
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS portaudio DESTINATION ..)
else()
install(TARGETS portaudio DESTINATION lib)
endif()
else()
set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")
if(NOT WIN32)
target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")
endif()
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS portaudio_static DESTINATION ..)
else()
install(TARGETS portaudio_static DESTINATION lib)
endif()
if(NOT BUILD_SHARED_LIBS AND SHERPA_ONNX_ENABLE_BINARY)
install(TARGETS
portaudio_static
DESTINATION lib)
endif()
endfunction()
download_portaudio()
... ...
# Note: If you use Python, then the prefix might not be correct.
#
# You need to either manually modify this file to change the prefix to the location
# where this sherpa-onnx.pc file actually resides
# or
# you can use
#
# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
includedir="${prefix}/include"
libdir="${exec_prefix}/lib"
Name: sherpa-onnx
Description: pkg-config for sherpa-onnx
URL: https://github.com/k2-fsa/sherpa-onnx
Version: @SHERPA_ONNX_VERSION@
Cflags: -I"${includedir}"
# Note: -lcargs is required only for the following file
# https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
# We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c
Libs: -L"${libdir}" -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@
... ...
# Note: If you use Python, then the prefix might not be correct.
#
# You need to either manually modify this file to change the prefix to the location
# where this sherpa-onnx.pc file actually resides
# or
# you can use
#
# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
includedir="${prefix}/include"
... ...
# Note: If you use Python, then the prefix might not be correct.
#
# You need to either manually modify this file to change the prefix to the location
# where this sherpa-onnx.pc file actually resides
# or
# you can use
#
# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
includedir="${prefix}/include"
... ...
... ... @@ -42,22 +42,32 @@ function(download_simple_sentencepiece)
FetchContent_Populate(simple-sentencepiece)
endif()
message(STATUS "simple-sentencepiece is downloaded to ${simple-sentencepiece_SOURCE_DIR}")
if(BUILD_SHARED_LIBS)
set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(${simple-sentencepiece_SOURCE_DIR} ${simple-sentencepiece_BINARY_DIR} EXCLUDE_FROM_ALL)
if(_build_shared_libs_bak)
set_target_properties(ssentencepiece_core
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
set(BUILD_SHARED_LIBS ON)
endif()
target_include_directories(ssentencepiece_core
PUBLIC
${simple-sentencepiece_SOURCE_DIR}/
)
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS ssentencepiece_core DESTINATION ..)
else()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ssentencepiece_core DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS ssentencepiece_core DESTINATION bin)
endif()
endfunction()
download_simple_sentencepiece()
... ...
... ... @@ -10,7 +10,7 @@ environment:
# Add regular dependencies here.
dependencies:
sherpa_onnx: ^1.10.9
sherpa_onnx: ^1.10.10
path: ^1.9.0
args: ^2.5.0
... ...
... ... @@ -11,7 +11,7 @@ environment:
# Add regular dependencies here.
dependencies:
sherpa_onnx: ^1.10.9
sherpa_onnx: ^1.10.10
path: ^1.9.0
args: ^2.5.0
... ...
... ... @@ -8,7 +8,7 @@ environment:
# Add regular dependencies here.
dependencies:
sherpa_onnx: ^1.10.9
sherpa_onnx: ^1.10.10
path: ^1.9.0
args: ^2.5.0
... ...
... ... @@ -9,7 +9,7 @@ environment:
sdk: ^3.4.0
dependencies:
sherpa_onnx: ^1.10.9
sherpa_onnx: ^1.10.10
path: ^1.9.0
args: ^2.5.0
... ...
... ... @@ -11,7 +11,7 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
exit 1
fi
if [[ ! -f ../build/lib/libsherpa-onnx-core.a && ! -f ../build/lib/libsherpa-onnx-core.dylib && ! -f ../build/lib/libsherpa-onnx-core.so ]]; then
if [[ ! -f ../build/lib/libsherpa-onnx-c-api.a && ! -f ../build/lib/libsherpa-onnx-c-api.dylib && ! -f ../build/lib/libsherpa-onnx-c-api.so ]]; then
echo "Please build sherpa-onnx first. You can use"
echo ""
echo " cd /path/to/sherpa-onnx"
... ...
... ... @@ -5,7 +5,7 @@ description: >
publish_to: 'none'
version: 1.10.1
version: 1.10.10
topics:
- speech-recognition
... ... @@ -30,7 +30,7 @@ dependencies:
record: ^5.1.0
url_launcher: ^6.2.6
sherpa_onnx: ^1.10.9
sherpa_onnx: ^1.10.10
# sherpa_onnx:
# path: ../../flutter/sherpa_onnx
... ...
... ... @@ -17,7 +17,7 @@ topics:
- voice-activity-detection
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
version: 1.10.9
version: 1.10.10
homepage: https://github.com/k2-fsa/sherpa-onnx
... ... @@ -30,16 +30,16 @@ dependencies:
flutter:
sdk: flutter
sherpa_onnx_android: ^1.10.9
sherpa_onnx_android: ^1.10.10
# path: ../sherpa_onnx_android
sherpa_onnx_macos: ^1.10.9
sherpa_onnx_macos: ^1.10.10
# path: ../sherpa_onnx_macos
sherpa_onnx_linux: ^1.10.9
sherpa_onnx_linux: ^1.10.10
# path: ../sherpa_onnx_linux
#
sherpa_onnx_windows: ^1.10.9
sherpa_onnx_windows: ^1.10.10
# path: ../sherpa_onnx_windows
flutter:
... ...
... ... @@ -12,16 +12,6 @@ project(${PROJECT_NAME} LANGUAGES CXX)
# external build triggered from this build file.
set(sherpa_onnx_linux_bundled_libraries
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-core.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-decoder-core.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-kaldifst-core.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fstfar.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fst.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-native-fbank-core.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libpiper_phonemize.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libespeak-ng.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libucd.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libssentencepiece_core.so"
"${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so.1.17.1"
PARENT_SCOPE
)
... ...
... ... @@ -13,16 +13,6 @@ project(${PROJECT_NAME} LANGUAGES CXX)
# external build triggered from this build file.
set(sherpa_onnx_windows_bundled_libraries
"${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-core.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/kaldi-decoder-core.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-kaldifst-core.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fstfar.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fst.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/kaldi-native-fbank-core.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/piper_phonemize.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/espeak-ng.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/ucd.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/ssentencepiece_core.dll"
PARENT_SCOPE
)
... ...
... ... @@ -14,6 +14,7 @@ if [[ ! -f ../build/lib/libsherpa-onnx-jni.dylib && ! -f ../build/lib/libsherpa
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_JNI=ON \
..
... ...
... ... @@ -44,10 +44,6 @@ function process_linux() {
pushd linux
rm -v libpiper_phonemize.so libpiper_phonemize.so.1.2.0
rm -v libonnxruntime.so
rm -v libcargs.so
popd
}
... ... @@ -69,12 +65,6 @@ function process_macos() {
cp -v sherpa_onnx/lib/*.dylib ../macos
cd ..
rm -rf t
pushd macos
rm -v libcargs.dylib
rm -v libonnxruntime.dylib
rm -v libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
popd
}
process_linux
... ...
... ... @@ -36,18 +36,8 @@ def get_dict():
def process_linux(s):
libs = [
"libespeak-ng.so",
"libkaldi-decoder-core.so",
"libkaldi-native-fbank-core.so",
"libonnxruntime.so.1.17.1",
"libssentencepiece_core.so",
"libpiper_phonemize.so.1",
"libsherpa-onnx-c-api.so",
"libsherpa-onnx-core.so",
"libsherpa-onnx-fstfar.so",
"libsherpa-onnx-fst.so",
"libsherpa-onnx-kaldifst-core.so",
"libucd.so",
]
prefix = f"{src_dir}/linux/"
libs = [prefix + lib for lib in libs]
... ... @@ -66,18 +56,8 @@ def process_linux(s):
def process_macos(s, rid):
libs = [
"libespeak-ng.dylib",
"libkaldi-decoder-core.dylib",
"libkaldi-native-fbank-core.dylib",
"libonnxruntime.1.17.1.dylib",
"libssentencepiece_core.dylib",
"libpiper_phonemize.1.dylib",
"libsherpa-onnx-c-api.dylib",
"libsherpa-onnx-core.dylib",
"libsherpa-onnx-fstfar.dylib",
"libsherpa-onnx-fst.dylib",
"libsherpa-onnx-kaldifst-core.dylib",
"libucd.dylib",
]
prefix = f"{src_dir}/macos-{rid}/"
libs = [prefix + lib for lib in libs]
... ... @@ -96,18 +76,8 @@ def process_macos(s, rid):
def process_windows(s, rid):
libs = [
"espeak-ng.dll",
"kaldi-decoder-core.dll",
"kaldi-native-fbank-core.dll",
"onnxruntime.dll",
"ssentencepiece_core.dll",
"piper_phonemize.dll",
"sherpa-onnx-c-api.dll",
"sherpa-onnx-core.dll",
"sherpa-onnx-fstfar.dll",
"sherpa-onnx-fst.dll",
"sherpa-onnx-kaldifst-core.dll",
"ucd.dll",
]
version = get_version()
... ...
... ... @@ -44,7 +44,7 @@ windows_x86_wheel=$src_dir/$windows_x86_wheel_filename
windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2
windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
if [ ! -f $src_dir/linux/libsherpa-onnx-c-api.so ]; then
echo "---linux x86_64---"
cd linux
mkdir -p wheel
... ... @@ -57,15 +57,12 @@ if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
unzip $linux_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
cd ..
rm -fv libpiper_phonemize.so libpiper_phonemize.so.1.2.0
rm -fv libonnxruntime.so
rm -fv libcargs.so
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS x86_64---"
cd macos-x64
mkdir -p wheel
... ... @@ -80,15 +77,12 @@ if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
cd ..
rm -fv libcargs.dylib
rm -fv libonnxruntime.dylib
rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS arm64---"
cd macos-arm64
mkdir -p wheel
... ... @@ -103,15 +97,12 @@ if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
cd ..
rm -fv libcargs.dylib
rm -fv libonnxruntime.dylib
rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-x64/sherpa-onnx-c-api.dll ]; then
echo "---windows x64---"
cd windows-x64
mkdir -p wheel
... ... @@ -130,7 +121,7 @@ if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
cd ..
fi
if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-x86/sherpa-onnx-c-api.dll ]; then
echo "---windows x86---"
cd windows-x86
mkdir -p wheel
... ... @@ -149,7 +140,7 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then
cd ..
fi
if [ ! -f $src_dir/windows-arm64/sherpa-onnx-core.dll ]; then
if [ ! -f $src_dir/windows-arm64/sherpa-onnx-c-api.dll ]; then
echo "---windows arm64---"
cd windows-arm64
mkdir -p wheel
... ...
... ... @@ -2,5 +2,5 @@
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-apple-darwin -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-native-fbank-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -lssentencepiece_core -Wl,-rpath,${SRCDIR}/lib/x86_64-apple-darwin
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-apple-darwin -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-apple-darwin
import "C"
... ...
... ... @@ -2,5 +2,5 @@
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/aarch64-apple-darwin -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-native-fbank-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -lssentencepiece_core -Wl,-rpath,${SRCDIR}/lib/aarch64-apple-darwin
// #cgo LDFLAGS: -L ${SRCDIR}/lib/aarch64-apple-darwin -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/aarch64-apple-darwin
import "C"
... ...
//go:build !android && linux && amd64 && !musl
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-unknown-linux-gnu -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-unknown-linux-gnu
import "C"
... ...
//go:build linux && arm && !arm7
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/arm-unknown-linux-gnueabihf -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/arm-unknown-linux-gnueabihf
import "C"
... ...
//go:build linux && arm64
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/aarch64-unknown-linux-gnu -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-native-fbank-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -lssentencepiece_core -Wl,-rpath,${SRCDIR}/lib/aarch64-unknown-linux-gnu
import "C"
... ...
//go:build windows && 386
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/i686-pc-windows-gnu -lsherpa-onnx-c-api -lonnxruntime
import "C"
... ...
//go:build windows && amd64
package sherpa_onnx
// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-pc-windows-gnu -lsherpa-onnx-c-api -lonnxruntime
import "C"
... ...
../../../../build/lib
\ No newline at end of file
... ...
... ... @@ -17,8 +17,11 @@ echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
function linux() {
echo "Process linux"
git clone git@github.com:k2-fsa/sherpa-onnx-go-linux.git
rm -v ./sherpa-onnx-go-linux/*.go
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-linux/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-linux/
cp -v ./_internal/build_linux_*.go ./sherpa-onnx-go-linux/
rm -rf sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/lib*
dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
... ... @@ -29,6 +32,10 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
... ... @@ -41,6 +48,10 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
... ... @@ -53,6 +64,10 @@ function linux() {
cp -v sherpa_onnx/lib/*.so* $dst
pushd $dst
cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
popd
cd ..
rm -rf t
... ... @@ -71,8 +86,10 @@ function linux() {
function osx() {
echo "Process osx-x64"
git clone git@github.com:k2-fsa/sherpa-onnx-go-macos.git
rm -v ./sherpa-onnx-go-macos/*.go
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-macos/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-macos/
cp -v ./_internal/build_darwin_*.go ./sherpa-onnx-go-macos/
rm -rf sherpa-onnx-go-macos/lib/x86_64-apple-darwin/lib*
dst=$(realpath sherpa-onnx-go-macos/lib/x86_64-apple-darwin/)
... ... @@ -84,6 +101,10 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
popd
cd ..
rm -rf t
... ... @@ -98,6 +119,10 @@ function osx() {
cp -v sherpa_onnx/lib/*.dylib $dst/
pushd $dst
cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
popd
cd ..
rm -rf t
echo "------------------------------"
... ... @@ -115,8 +140,10 @@ function osx() {
function windows() {
echo "Process windows"
git clone git@github.com:k2-fsa/sherpa-onnx-go-windows.git
rm -v ./sherpa-onnx-go-windows/*.go
cp -v ./sherpa_onnx.go ./sherpa-onnx-go-windows/
cp -v ./_internal/c-api.h ./sherpa-onnx-go-windows/
cp -v ./_internal/build_windows_*.go ./sherpa-onnx-go-windows/
rm -fv sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu/*
dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
... ...
... ... @@ -67,15 +67,6 @@ target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
target_link_libraries(${PROJECT_NAME}
sherpa-onnx-c-api
sherpa-onnx-core
kaldi-decoder-core
sherpa-onnx-kaldifst-core
sherpa-onnx-fstfar
sherpa-onnx-fst
kaldi-native-fbank-core
piper_phonemize
espeak-ng
ucd
onnxruntime
-Wl,-rpath,$ENV{SHERPA_ONNX_INSTALL_DIR}/lib
)
... ...
... ... @@ -2,11 +2,16 @@
set -ex
if [[ ! -f ../../build/install/lib/libsherpa-onnx-core.dylib && ! -f ../../build/install/lib/libsherpa-onnx-core.so ]]; then
if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-c-api.so ]]; then
pushd ../../
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON ..
cmake \
-DCMAKE_INSTALL_PREFIX=./install \
-DBUILD_SHARED_LIBS=ON \
..
make install
popd
fi
... ...
... ... @@ -155,7 +155,18 @@ endif()
if(SHERPA_ONNX_ENABLE_CHECK)
list(APPEND sources log.cc)
endif()
add_library(sherpa-onnx-core ${sources})
# Always static build
add_library(sherpa-onnx-core STATIC ${sources})
set_target_properties(
sherpa-onnx-core
PROPERTIES
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
if(APPLE)
target_compile_options(sherpa-onnx-core PRIVATE
-Wno-deprecated-declarations
... ... @@ -213,6 +224,7 @@ if(SHERPA_ONNX_ENABLE_CHECK)
endif()
if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Linux)
# This is for linux arm32 and arm64
target_link_libraries(sherpa-onnx-core -ldl)
endif()
... ... @@ -264,16 +276,10 @@ if(SHERPA_ONNX_ENABLE_BINARY)
endif()
endif()
if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)
install(TARGETS sherpa-onnx-core DESTINATION ..)
else()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS sherpa-onnx-core DESTINATION lib)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS sherpa-onnx-core DESTINATION bin)
endif()
if(SHERPA_ONNX_ENABLE_BINARY)
install(
TARGETS
... ... @@ -311,6 +317,9 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
)
endif()
# # To fix the following error for Windows when building exe
# # mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_Dynamic Release'
foreach(exe IN LISTS exes)
target_link_libraries(${exe} sherpa-onnx-core)
endforeach()
... ... @@ -386,12 +395,6 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
microphone.cc
)
if(BUILD_SHARED_LIBS)
set(PA_LIB portaudio)
else()
set(PA_LIB portaudio_static)
endif()
set(exes
sherpa-onnx-microphone
sherpa-onnx-keyword-spotter-microphone
... ... @@ -408,7 +411,7 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
endif()
foreach(exe IN LISTS exes)
target_link_libraries(${exe} ${PA_LIB} sherpa-onnx-core)
target_link_libraries(${exe} portaudio_static sherpa-onnx-core)
endforeach()
if(NOT WIN32)
... ... @@ -473,7 +476,7 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")
if(SHERPA_ONNX_ENABLE_PYTHON)
if(SHERPA_ONNX_ENABLE_PYTHON AND NOT WIN32)
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
... ... @@ -550,4 +553,3 @@ add_custom_target(
DEPENDS ${sources})
add_custom_target(check DEPENDS clang-tidy-check)
... ...
... ... @@ -35,5 +35,8 @@ endif()
add_library(sherpa-onnx-jni ${sources})
target_compile_definitions(sherpa-onnx-jni PRIVATE SHERPA_ONNX_BUILD_SHARED_LIBS=1)
target_compile_definitions(sherpa-onnx-jni PRIVATE SHERPA_ONNX_BUILD_MAIN_LIB=1)
target_link_libraries(sherpa-onnx-jni sherpa-onnx-core)
install(TARGETS sherpa-onnx-jni DESTINATION lib)
... ...
... ... @@ -12,11 +12,31 @@
#include "android/asset_manager_jni.h"
#endif
#if defined(_WIN32)
#if defined(SHERPA_ONNX_BUILD_SHARED_LIBS)
#define SHERPA_ONNX_EXPORT __declspec(dllexport)
#define SHERPA_ONNX_IMPORT __declspec(dllimport)
#else
#define SHERPA_ONNX_EXPORT
#define SHERPA_ONNX_IMPORT
#endif
#else // WIN32
#define SHERPA_ONNX_EXPORT __attribute__((visibility("default")))
#define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT
#endif // WIN32
#if defined(SHERPA_ONNX_BUILD_MAIN_LIB)
#define SHERPA_ONNX_API SHERPA_ONNX_EXPORT
#else
#define SHERPA_ONNX_API SHERPA_ONNX_IMPORT
#endif
// If you use ndk, you can find "jni.h" inside
// android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
#include "jni.h" // NOLINT
#define SHERPA_ONNX_EXTERN_C extern "C"
#define SHERPA_ONNX_EXTERN_C extern "C" SHERPA_ONNX_API
// defined in jni.cc
jobject NewInteger(JNIEnv *env, int32_t value);
... ...