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 @@ -6,17 +6,6 @@ cd dart-api-examples
6 6
7 pushd non-streaming-asr 7 pushd non-streaming-asr
8 8
9 -echo '----------paraformer itn----------'  
10 -./run-paraformer-itn.sh  
11 -  
12 -echo '----------paraformer----------'  
13 -./run-paraformer.sh  
14 -rm -rf sherpa-onnx-*  
15 -  
16 -echo '----------VAD with paraformer----------'  
17 -./run-vad-with-paraformer.sh  
18 -rm -rf sherpa-onnx-*  
19 -  
20 echo '----------NeMo transducer----------' 9 echo '----------NeMo transducer----------'
21 ./run-nemo-transducer.sh 10 ./run-nemo-transducer.sh
22 rm -rf sherpa-onnx-* 11 rm -rf sherpa-onnx-*
@@ -37,6 +26,17 @@ echo '----------zipformer transducer----------' @@ -37,6 +26,17 @@ echo '----------zipformer transducer----------'
37 ./run-zipformer-transducer.sh 26 ./run-zipformer-transducer.sh
38 rm -rf sherpa-onnx-* 27 rm -rf sherpa-onnx-*
39 28
  29 +echo '----------paraformer itn----------'
  30 +./run-paraformer-itn.sh
  31 +
  32 +echo '----------paraformer----------'
  33 +./run-paraformer.sh
  34 +rm -rf sherpa-onnx-*
  35 +
  36 +echo '----------VAD with paraformer----------'
  37 +./run-vad-with-paraformer.sh
  38 +rm -rf sherpa-onnx-*
  39 +
40 popd # non-streaming-asr 40 popd # non-streaming-asr
41 41
42 pushd tts 42 pushd tts
@@ -32,6 +32,7 @@ concurrency: @@ -32,6 +32,7 @@ concurrency:
32 32
33 jobs: 33 jobs:
34 flutter_linux: 34 flutter_linux:
  35 + if: false
35 name: linux 36 name: linux
36 runs-on: ${{ matrix.os }} 37 runs-on: ${{ matrix.os }}
37 container: ubuntu:18.04 38 container: ubuntu:18.04
@@ -49,7 +50,7 @@ jobs: @@ -49,7 +50,7 @@ jobs:
49 shell: bash 50 shell: bash
50 run: | 51 run: |
51 apt-get update -y 52 apt-get update -y
52 - apt-get install -y build-essential jq git cmake 53 + apt-get install -y build-essential jq git cmake
53 apt-get install -y curl 54 apt-get install -y curl
54 55
55 - name: Setup Flutter SDK 56 - name: Setup Flutter SDK
@@ -37,7 +37,7 @@ jobs: @@ -37,7 +37,7 @@ jobs:
37 strategy: 37 strategy:
38 fail-fast: false 38 fail-fast: false
39 matrix: 39 matrix:
40 - os: [ubuntu-latest, macos-latest, macos-14] 40 + os: [ubuntu-latest, macos-latest, macos-13]
41 41
42 steps: 42 steps:
43 - uses: actions/checkout@v4 43 - uses: actions/checkout@v4
@@ -72,7 +72,12 @@ jobs: @@ -72,7 +72,12 @@ jobs:
72 72
73 mkdir build 73 mkdir build
74 cd build 74 cd build
75 - cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_GPU=ON .. 75 + cmake \
  76 + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  77 + -D CMAKE_INSTALL_PREFIX=./install \
  78 + -D BUILD_SHARED_LIBS=ON \
  79 + -D SHERPA_ONNX_ENABLE_GPU=ON \
  80 + ..
76 81
77 - name: Build sherpa-onnx for ubuntu 82 - name: Build sherpa-onnx for ubuntu
78 shell: bash 83 shell: bash
@@ -86,6 +91,12 @@ jobs: @@ -86,6 +91,12 @@ jobs:
86 ls -lh lib 91 ls -lh lib
87 ls -lh bin 92 ls -lh bin
88 93
  94 + echo "----"
  95 + ls -lh install/lib
  96 +
  97 + echo "----"
  98 + ls -lh install/bin
  99 +
89 - name: Display dependencies of sherpa-onnx for linux 100 - name: Display dependencies of sherpa-onnx for linux
90 shell: bash 101 shell: bash
91 run: | 102 run: |
@@ -95,7 +95,13 @@ jobs: @@ -95,7 +95,13 @@ jobs:
95 mkdir build 95 mkdir build
96 cd build 96 cd build
97 97
98 - 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 .. 98 + cmake \
  99 + -D SHERPA_ONNX_ENABLE_TTS=ON \
  100 + -D CMAKE_BUILD_TYPE=Release \
  101 + -D BUILD_SHARED_LIBS=ON \
  102 + -D CMAKE_INSTALL_PREFIX=./install \
  103 + -D SHERPA_ONNX_ENABLE_JNI=ON \
  104 + ..
99 105
100 make -j2 106 make -j2
101 make install 107 make install
@@ -105,6 +111,12 @@ jobs: @@ -105,6 +111,12 @@ jobs:
105 rm -rf ./install/pkgconfig 111 rm -rf ./install/pkgconfig
106 rm -rf ./install/share 112 rm -rf ./install/share
107 113
  114 + echo "----"
  115 + ls -lh install/lib
  116 +
  117 + echo "----"
  118 + ls -lh install/bin
  119 +
108 - name: Display dependencies of sherpa-onnx for linux 120 - name: Display dependencies of sherpa-onnx for linux
109 shell: bash 121 shell: bash
110 run: | 122 run: |
@@ -99,7 +99,12 @@ jobs: @@ -99,7 +99,12 @@ jobs:
99 mkdir build 99 mkdir build
100 cd build 100 cd build
101 101
102 - 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 .. 102 + cmake \
  103 + -D SHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
  104 + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  105 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  106 + -D CMAKE_INSTALL_PREFIX=./install \
  107 + ..
103 108
104 make -j2 109 make -j2
105 make install 110 make install
@@ -107,6 +112,12 @@ jobs: @@ -107,6 +112,12 @@ jobs:
107 ls -lh lib 112 ls -lh lib
108 ls -lh bin 113 ls -lh bin
109 114
  115 + echo "----"
  116 + ls -lh install/lib
  117 +
  118 + echo "----"
  119 + ls -lh install/bin
  120 +
110 - name: Display dependencies of sherpa-onnx for linux 121 - name: Display dependencies of sherpa-onnx for linux
111 shell: bash 122 shell: bash
112 run: | 123 run: |
@@ -52,8 +52,8 @@ jobs: @@ -52,8 +52,8 @@ jobs:
52 cmake \ 52 cmake \
53 -D BUILD_SHARED_LIBS=ON \ 53 -D BUILD_SHARED_LIBS=ON \
54 -D CMAKE_BUILD_TYPE=Release \ 54 -D CMAKE_BUILD_TYPE=Release \
55 - -DCMAKE_OSX_ARCHITECTURES=$arch \  
56 - -DSHERPA_ONNX_ENABLE_JNI=ON \ 55 + -D CMAKE_OSX_ARCHITECTURES=$arch \
  56 + -D SHERPA_ONNX_ENABLE_JNI=ON \
57 -DCMAKE_INSTALL_PREFIX=./install \ 57 -DCMAKE_INSTALL_PREFIX=./install \
58 .. 58 ..
59 59
@@ -84,7 +84,13 @@ jobs: @@ -84,7 +84,13 @@ jobs:
84 BUILD_SHARED_LIBS=ON 84 BUILD_SHARED_LIBS=ON
85 fi 85 fi
86 86
87 - 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 .. 87 + cmake \
  88 + -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
  89 + -D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
  90 + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  91 + -D CMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
  92 + -D CMAKE_INSTALL_PREFIX=./install \
  93 + ..
88 94
89 - name: Build sherpa-onnx for macos 95 - name: Build sherpa-onnx for macos
90 shell: bash 96 shell: bash
@@ -93,17 +93,12 @@ jobs: @@ -93,17 +93,12 @@ jobs:
93 make install 93 make install
94 94
95 ls -lh ./install/lib 95 ls -lh ./install/lib
  96 + rm -v ./install/lib/libonnxruntime.so
96 97
97 - name: Copy pre-built libs 98 - name: Copy pre-built libs
98 shell: bash 99 shell: bash
99 run: | 100 run: |
100 cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/ 101 cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/
101 - pushd flutter/sherpa_onnx_linux/linux/  
102 -  
103 - rm libonnxruntime.so  
104 - ln -s libonnxruntime.so.* ./libonnxruntime.so  
105 -  
106 - popd  
107 102
108 mv -v flutter/sherpa_onnx_linux /tmp/to_be_published 103 mv -v flutter/sherpa_onnx_linux /tmp/to_be_published
109 104
@@ -197,27 +192,19 @@ jobs: @@ -197,27 +192,19 @@ jobs:
197 cd build 192 cd build
198 make -j2 install 193 make -j2 install
199 194
200 - ls -lh install/lib/libsherpa-onnx-core.dylib  
201 - file install/lib/libsherpa-onnx-core.dylib 195 + ls -lh install/lib/libsherpa-onnx-c-api.dylib
  196 + file install/lib/libsherpa-onnx-c-api.dylib
  197 + rm -v install/lib/libonnxruntime.dylib
202 198
203 - name: Copy pre-built libs 199 - name: Copy pre-built libs
204 shell: bash 200 shell: bash
205 run: | 201 run: |
206 cp -v build/install/lib/lib*.dylib* flutter/sherpa_onnx_macos/macos/ 202 cp -v build/install/lib/lib*.dylib* flutter/sherpa_onnx_macos/macos/
207 203
208 -  
209 mv -v flutter/sherpa_onnx_macos /tmp/to_be_published 204 mv -v flutter/sherpa_onnx_macos /tmp/to_be_published
210 205
211 ls -lh /tmp/to_be_published/macos 206 ls -lh /tmp/to_be_published/macos
212 207
213 - pushd /tmp/to_be_published/macos  
214 -  
215 - rm libonnxruntime.dylib  
216 -  
217 - ls -lh  
218 -  
219 - popd  
220 -  
221 - name: Release 208 - name: Release
222 shell: bash 209 shell: bash
223 run: | 210 run: |
@@ -283,7 +270,7 @@ jobs: @@ -283,7 +270,7 @@ jobs:
283 shell: bash 270 shell: bash
284 run: | 271 run: |
285 cd build 272 cd build
286 - cmake --build . --target install --config Release 273 + cmake --build . --target install --config Release -- -m:2
287 274
288 ls -lh install/lib/*.dll 275 ls -lh install/lib/*.dll
289 276
@@ -123,8 +123,16 @@ jobs: @@ -123,8 +123,16 @@ jobs:
123 ls -lh build-riscv64-linux-gnu/bin 123 ls -lh build-riscv64-linux-gnu/bin
124 ls -lh build-riscv64-linux-gnu/lib 124 ls -lh build-riscv64-linux-gnu/lib
125 125
  126 + echo "---install/lib---"
  127 + ls -lh build-riscv64-linux-gnu/install/lib
  128 +
  129 + echo "---install/bin---"
  130 + ls -lh build-riscv64-linux-gnu/install/bin
  131 +
126 file build-riscv64-linux-gnu/bin/sherpa-onnx 132 file build-riscv64-linux-gnu/bin/sherpa-onnx
127 133
  134 + readelf -d build-riscv64-linux-gnu/bin/sherpa-onnx
  135 +
128 - name: Test sherpa-onnx 136 - name: Test sherpa-onnx
129 shell: bash 137 shell: bash
130 run: | 138 run: |
@@ -78,7 +78,7 @@ jobs: @@ -78,7 +78,7 @@ jobs:
78 - name: Install Python dependencies 78 - name: Install Python dependencies
79 shell: bash 79 shell: bash
80 run: | 80 run: |
81 - python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile 81 + python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile setuptools wheel
82 82
83 - name: Install sherpa-onnx 83 - name: Install sherpa-onnx
84 shell: bash 84 shell: bash
@@ -87,7 +87,7 @@ jobs: @@ -87,7 +87,7 @@ jobs:
87 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 87 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
88 cmake --version 88 cmake --version
89 89
90 - python3 setup.py install 90 + python3 -m pip install .
91 91
92 - name: Test sherpa-onnx 92 - name: Test sherpa-onnx
93 shell: bash 93 shell: bash
@@ -39,7 +39,7 @@ jobs: @@ -39,7 +39,7 @@ jobs:
39 strategy: 39 strategy:
40 fail-fast: false 40 fail-fast: false
41 matrix: 41 matrix:
42 - os: [macos-latest, macos-14] 42 + os: [macos-latest, macos-13]
43 43
44 steps: 44 steps:
45 - uses: actions/checkout@v4 45 - uses: actions/checkout@v4
@@ -110,10 +110,20 @@ jobs: @@ -110,10 +110,20 @@ jobs:
110 python3 setup.py bdist_wheel 110 python3 setup.py bdist_wheel
111 ls -lh dist 111 ls -lh dist
112 112
  113 + - uses: actions/upload-artifact@v4
  114 + with:
  115 + name: wheel-${{ matrix.os }}-${{ matrix.python-version }}
  116 + path: ./dist/*.whl
  117 +
113 - name: Display wheel 118 - name: Display wheel
114 shell: bash 119 shell: bash
115 run: | 120 run: |
116 ls -lh dist 121 ls -lh dist
  122 + cd dist
  123 +
  124 + mkdir t
  125 + cd t
  126 + unzip ../*.whl
117 127
118 - name: Install wheel 128 - name: Install wheel
119 shell: bash 129 shell: bash
@@ -70,7 +70,7 @@ jobs: @@ -70,7 +70,7 @@ jobs:
70 cd build 70 cd build
71 71
72 cmake \ 72 cmake \
73 - -D BUILD_SHARED_LIBS=ON \ 73 + -DBUILD_SHARED_LIBS=ON \
74 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ 74 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
75 -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ 75 -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
76 -DBUILD_ESPEAK_NG_EXE=OFF \ 76 -DBUILD_ESPEAK_NG_EXE=OFF \
@@ -26,8 +26,10 @@ jobs: @@ -26,8 +26,10 @@ jobs:
26 include: 26 include:
27 - os: ubuntu-latest 27 - os: ubuntu-latest
28 arch: amd64 28 arch: amd64
29 - - os: macos-latest 29 + - os: macos-13
30 arch: amd64 30 arch: amd64
  31 + - os: macos-14
  32 + arch: arm64
31 - os: windows-latest 33 - os: windows-latest
32 arch: x64 34 arch: x64
33 - os: windows-latest 35 - os: windows-latest
@@ -35,7 +35,7 @@ jobs: @@ -35,7 +35,7 @@ jobs:
35 strategy: 35 strategy:
36 fail-fast: false 36 fail-fast: false
37 matrix: 37 matrix:
38 - os: [macos-latest, macos-14] 38 + os: [macos-latest, macos-13, ubuntu-latest, windows-latest]
39 39
40 steps: 40 steps:
41 - uses: actions/checkout@v4 41 - uses: actions/checkout@v4
@@ -67,12 +67,63 @@ jobs: @@ -67,12 +67,63 @@ jobs:
67 - name: Build sherpa-onnx 67 - name: Build sherpa-onnx
68 shell: bash 68 shell: bash
69 run: | 69 run: |
  70 + upload_dir=$PWD/to-upload
  71 + mkdir -p $upload_dir
  72 + echo "upload_dir"
  73 +
70 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 74 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
71 mkdir build 75 mkdir build
72 cd build 76 cd build
73 - 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 ..  
74 - make -j1  
75 - cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/ 77 + cmake \
  78 + -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  79 + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  80 + -DBUILD_SHARED_LIBS=ON \
  81 + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
  82 + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
  83 + -DCMAKE_INSTALL_PREFIX=./install \
  84 + ..
  85 +
  86 + if [[ ${{ matrix.os }} == windows-latest ]]; then
  87 + cmake --build . --target install --config Release -- -m:2
  88 + else
  89 + make -j2 install
  90 + fi
  91 +
  92 + if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
  93 + cp -v ./lib/*.so $upload_dir
  94 + cp -v _deps/onnxruntime-src/lib/libonnxruntime*so* $upload_dir
  95 +
  96 + cp -v _deps/onnxruntime-src/lib/libonnxruntime*so* ./lib/
  97 + rm -v ./lib/libonnxruntime.so
  98 +
  99 + cd lib
  100 + ln -s libonnxruntime.so.1.17.1 libonnxruntime.so
  101 + cd ..
  102 +
  103 + rm -v ./lib/*.a
  104 + ls -h ./lib
  105 + elif [[ ${{ matrix.os }} == windows-latest ]]; then
  106 + cp -v ./install/lib/sherpa-onnx-c-api.dll ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
  107 + cp -v ./install/lib/onnxruntime.dll ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
  108 + ls -lh ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/
  109 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/speaker-identification/
  110 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/streaming-hlg-decoding/
  111 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/non-streaming-tts/
  112 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/non-streaming-decode-files/
  113 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/streaming-decode-files/
  114 +
  115 + cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll $upload_dir
  116 + else
  117 + cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib $upload_dir/
  118 + cp -v lib/*.dylib $upload_dir
  119 +
  120 + cp -v _deps/onnxruntime-src/lib/libonnxruntime*dylib ./lib/
  121 + rm ./lib/*.a
  122 + rm ./lib/libonnxruntime.dylib
  123 + cd lib
  124 + ln -s libonnxruntime.1.17.1.dylib libonnxruntime.dylib
  125 + cd ..
  126 + fi
76 127
77 cd ../scripts/go/_internal/ 128 cd ../scripts/go/_internal/
78 ls -lh lib 129 ls -lh lib
@@ -83,6 +134,11 @@ jobs: @@ -83,6 +134,11 @@ jobs:
83 go mod tidy 134 go mod tidy
84 go build 135 go build
85 136
  137 + - uses: actions/upload-artifact@v4
  138 + with:
  139 + name: ${{ matrix.os }}-libs
  140 + path: to-upload/
  141 +
86 - name: Test speaker identification 142 - name: Test speaker identification
87 shell: bash 143 shell: bash
88 run: | 144 run: |
@@ -95,7 +151,7 @@ jobs: @@ -95,7 +151,7 @@ jobs:
95 cd scripts/go/_internal/streaming-hlg-decoding/ 151 cd scripts/go/_internal/streaming-hlg-decoding/
96 ./run.sh 152 ./run.sh
97 153
98 - - name: Test non-streaming TTS (macOS) 154 + - name: Test non-streaming TTS
99 shell: bash 155 shell: bash
100 run: | 156 run: |
101 mkdir tts-waves 157 mkdir tts-waves
@@ -130,7 +186,7 @@ jobs: @@ -130,7 +186,7 @@ jobs:
130 name: tts-waves-${{ matrix.os }} 186 name: tts-waves-${{ matrix.os }}
131 path: tts-waves 187 path: tts-waves
132 188
133 - - name: Test non-streaming decoding files (macOS) 189 + - name: Test non-streaming decoding files
134 shell: bash 190 shell: bash
135 run: | 191 run: |
136 cd scripts/go/_internal/non-streaming-decode-files/ 192 cd scripts/go/_internal/non-streaming-decode-files/
@@ -57,7 +57,7 @@ jobs: @@ -57,7 +57,7 @@ jobs:
57 - name: Install Python dependencies 57 - name: Install Python dependencies
58 shell: bash 58 shell: bash
59 run: | 59 run: |
60 - python3 -m pip install --upgrade pip numpy pypinyin sentencepiece 60 + python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel
61 61
62 - name: Install sherpa-onnx 62 - name: Install sherpa-onnx
63 shell: bash 63 shell: bash
@@ -66,7 +66,7 @@ jobs: @@ -66,7 +66,7 @@ jobs:
66 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 66 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
67 cmake --version 67 cmake --version
68 68
69 - python3 setup.py install 69 + python3 -m pip install .
70 python3 -m pip install websockets 70 python3 -m pip install websockets
71 71
72 - name: Start server for transducer models 72 - name: Start server for transducer models
@@ -57,7 +57,7 @@ jobs: @@ -57,7 +57,7 @@ jobs:
57 - name: Install Python dependencies 57 - name: Install Python dependencies
58 shell: bash 58 shell: bash
59 run: | 59 run: |
60 - python3 -m pip install --upgrade pip numpy pypinyin sentencepiece 60 + python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel
61 61
62 - name: Install sherpa-onnx 62 - name: Install sherpa-onnx
63 shell: bash 63 shell: bash
@@ -66,7 +66,7 @@ jobs: @@ -66,7 +66,7 @@ jobs:
66 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" 66 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
67 cmake --version 67 cmake --version
68 68
69 - python3 setup.py install 69 + python3 -m pip install .
70 python3 -m pip install websockets 70 python3 -m pip install websockets
71 71
72 - name: Start server for zipformer2 CTC models 72 - name: Start server for zipformer2 CTC models
@@ -47,7 +47,14 @@ jobs: @@ -47,7 +47,14 @@ jobs:
47 run: | 47 run: |
48 mkdir build 48 mkdir build
49 cd build 49 cd build
50 - 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 .. 50 + cmake \
  51 + -A ARM64 \
  52 + -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
  53 + -D CMAKE_BUILD_TYPE=Release \
  54 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  55 + -D CMAKE_INSTALL_PREFIX=./install \
  56 + -D BUILD_ESPEAK_NG_EXE=OFF \
  57 + ..
51 58
52 - name: Build sherpa-onnx for windows 59 - name: Build sherpa-onnx for windows
53 shell: bash 60 shell: bash
@@ -57,7 +57,13 @@ jobs: @@ -57,7 +57,13 @@ jobs:
57 run: | 57 run: |
58 mkdir build 58 mkdir build
59 cd build 59 cd build
60 - cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install -DSHERPA_ONNX_ENABLE_GPU=ON .. 60 + cmake \
  61 + -A x64 \
  62 + -D CMAKE_BUILD_TYPE=Release \
  63 + -D BUILD_SHARED_LIBS=ON \
  64 + -D CMAKE_INSTALL_PREFIX=./install \
  65 + -D SHERPA_ONNX_ENABLE_GPU=ON \
  66 + ..
61 67
62 - name: Build sherpa-onnx for windows 68 - name: Build sherpa-onnx for windows
63 shell: bash 69 shell: bash
@@ -59,7 +59,12 @@ jobs: @@ -59,7 +59,12 @@ jobs:
59 run: | 59 run: |
60 mkdir build 60 mkdir build
61 cd build 61 cd build
62 - cmake -A x64 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install .. 62 + cmake \
  63 + -A x64 \
  64 + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  65 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  66 + -D CMAKE_INSTALL_PREFIX=./install \
  67 + ..
63 68
64 - name: Build sherpa-onnx for windows 69 - name: Build sherpa-onnx for windows
65 shell: bash 70 shell: bash
@@ -37,7 +37,13 @@ jobs: @@ -37,7 +37,13 @@ jobs:
37 run: | 37 run: |
38 mkdir build 38 mkdir build
39 cd build 39 cd build
40 - cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX=./install .. 40 + cmake \
  41 + -A x64 \
  42 + -D CMAKE_BUILD_TYPE=Release \
  43 + -D BUILD_SHARED_LIBS=ON \
  44 + -D SHERPA_ONNX_ENABLE_JNI=ON \
  45 + -D CMAKE_INSTALL_PREFIX=./install \
  46 + ..
41 47
42 - name: Build sherpa-onnx for windows 48 - name: Build sherpa-onnx for windows
43 shell: bash 49 shell: bash
@@ -63,7 +63,13 @@ jobs: @@ -63,7 +63,13 @@ jobs:
63 run: | 63 run: |
64 mkdir build 64 mkdir build
65 cd build 65 cd build
66 - 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 .. 66 + cmake \
  67 + -A x64 \
  68 + -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
  69 + -D CMAKE_BUILD_TYPE=Release \
  70 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  71 + -DCMAKE_INSTALL_PREFIX=./install \
  72 + ..
67 73
68 - name: Build sherpa-onnx for windows 74 - name: Build sherpa-onnx for windows
69 shell: bash 75 shell: bash
@@ -59,7 +59,11 @@ jobs: @@ -59,7 +59,11 @@ jobs:
59 run: | 59 run: |
60 mkdir build 60 mkdir build
61 cd build 61 cd build
62 - cmake -A Win32 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install .. 62 + cmake \
  63 + -A Win32 \
  64 + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  65 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  66 + -D CMAKE_INSTALL_PREFIX=./install ..
63 67
64 - name: Build sherpa-onnx for windows 68 - name: Build sherpa-onnx for windows
65 shell: bash 69 shell: bash
@@ -63,14 +63,20 @@ jobs: @@ -63,14 +63,20 @@ jobs:
63 run: | 63 run: |
64 mkdir build 64 mkdir build
65 cd build 65 cd build
66 - 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 .. 66 + cmake \
  67 + -A Win32 \
  68 + -DSHERPA_ONNX_ENABLE_TTS=${{ matrix.with_tts }} \
  69 + -D CMAKE_BUILD_TYPE=Release \
  70 + -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \
  71 + -D CMAKE_INSTALL_PREFIX=./install \
  72 + ..
67 73
68 - name: Build sherpa-onnx for windows 74 - name: Build sherpa-onnx for windows
69 shell: bash 75 shell: bash
70 run: | 76 run: |
71 cd build 77 cd build
72 - cmake --build . --config Release -- -m:2  
73 - cmake --build . --config Release --target install -- -m:2 78 + cmake --build . --config Release
  79 + cmake --build . --config Release --target install
74 80
75 ls -lh ./bin/Release/sherpa-onnx.exe 81 ls -lh ./bin/Release/sherpa-onnx.exe
76 82
  1 +## 1.10.10
  2 +
  3 +* Build sherpa-onnx into a single shared library.
  4 +
1 ## 1.10.9 5 ## 1.10.9
2 6
3 * Fix released packages. piper-phonemize was not included in v1.10.8. 7 * Fix released packages. piper-phonemize was not included in v1.10.8.
@@ -2,13 +2,16 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) @@ -2,13 +2,16 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2 2
3 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version. Used only for macOS") 3 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version. Used only for macOS")
4 4
  5 +set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
  6 +set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
  7 +
5 project(sherpa-onnx) 8 project(sherpa-onnx)
6 9
7 # Remember to update 10 # Remember to update
8 # ./nodejs-addon-examples 11 # ./nodejs-addon-examples
9 # ./dart-api-examples/ 12 # ./dart-api-examples/
10 # ./sherpa-onnx/flutter/CHANGELOG.md 13 # ./sherpa-onnx/flutter/CHANGELOG.md
11 -set(SHERPA_ONNX_VERSION "1.10.9") 14 +set(SHERPA_ONNX_VERSION "1.10.10")
12 15
13 # Disable warning about 16 # Disable warning about
14 # 17 #
@@ -18,6 +21,21 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") @@ -18,6 +21,21 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
18 cmake_policy(SET CMP0135 NEW) 21 cmake_policy(SET CMP0135 NEW)
19 endif() 22 endif()
20 23
  24 +
  25 +include(CheckIPOSupported)
  26 +check_ipo_supported(RESULT ipo)
  27 +
  28 +if(ipo)
  29 + message(STATUS "IPO is enabled")
  30 + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
  31 +else()
  32 + message(STATUS "IPO is not available")
  33 +endif()
  34 +
  35 +set(CMAKE_CXX_VISIBILITY_PRESET hidden)
  36 +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
  37 +set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  38 +
21 option(SHERPA_ONNX_ENABLE_PYTHON "Whether to build Python" OFF) 39 option(SHERPA_ONNX_ENABLE_PYTHON "Whether to build Python" OFF)
22 option(SHERPA_ONNX_ENABLE_TESTS "Whether to build tests" OFF) 40 option(SHERPA_ONNX_ENABLE_TESTS "Whether to build tests" OFF)
23 option(SHERPA_ONNX_ENABLE_CHECK "Whether to build with assert" OFF) 41 option(SHERPA_ONNX_ENABLE_CHECK "Whether to build with assert" OFF)
@@ -53,8 +71,10 @@ else() @@ -53,8 +71,10 @@ else()
53 set(SHERPA_ONNX_RPATH_ORIGIN "@loader_path") 71 set(SHERPA_ONNX_RPATH_ORIGIN "@loader_path")
54 endif() 72 endif()
55 73
56 -set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})  
57 -set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) 74 +if(NOT WIN32)
  75 + set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
  76 + set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
  77 +endif()
58 78
59 if(NOT CMAKE_BUILD_TYPE) 79 if(NOT CMAKE_BUILD_TYPE)
60 message(STATUS "No CMAKE_BUILD_TYPE given, default to Release") 80 message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
@@ -89,22 +109,16 @@ to install CUDA toolkit if you have not installed it.") @@ -89,22 +109,16 @@ to install CUDA toolkit if you have not installed it.")
89 endif() 109 endif()
90 endif() 110 endif()
91 111
92 -if(BUILD_SHARED_LIBS AND MSVC)  
93 - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)  
94 -endif()  
95 -  
96 -if(NOT BUILD_SHARED_LIBS AND MSVC)  
97 - # see https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html  
98 - # https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake  
99 - if(MSVC)  
100 - add_compile_options(  
101 - $<$<CONFIG:>:/MT> #---------|  
102 - $<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries  
103 - $<$<CONFIG:Release>:/MT> #--|  
104 - $<$<CONFIG:RelWithDebInfo>:/MT>  
105 - $<$<CONFIG:MinSizeRel>:/MT>  
106 - )  
107 - endif() 112 +# see https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
  113 +# https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
  114 +if(MSVC)
  115 + add_compile_options(
  116 + $<$<CONFIG:>:/MT> #---------|
  117 + $<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
  118 + $<$<CONFIG:Release>:/MT> #--|
  119 + $<$<CONFIG:RelWithDebInfo>:/MT>
  120 + $<$<CONFIG:MinSizeRel>:/MT>
  121 + )
108 endif() 122 endif()
109 123
110 message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") 124 message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
@@ -325,17 +339,21 @@ if(NOT BUILD_SHARED_LIBS) @@ -325,17 +339,21 @@ if(NOT BUILD_SHARED_LIBS)
325 endif() 339 endif()
326 endif() 340 endif()
327 341
  342 +if(NOT BUILD_SHARED_LIBS)
328 # See https://people.freedesktop.org/~dbn/pkg-config-guide.html 343 # See https://people.freedesktop.org/~dbn/pkg-config-guide.html
329 -if(SHERPA_ONNX_ENABLE_TTS)  
330 - configure_file(cmake/sherpa-onnx.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY) 344 + if(SHERPA_ONNX_ENABLE_TTS)
  345 + configure_file(cmake/sherpa-onnx-static.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
  346 + else()
  347 + configure_file(cmake/sherpa-onnx-static-no-tts.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
  348 + endif()
331 else() 349 else()
332 - configure_file(cmake/sherpa-onnx-no-tts.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY) 350 + configure_file(cmake/sherpa-onnx-shared.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY)
333 endif() 351 endif()
334 352
335 install( 353 install(
336 FILES 354 FILES
337 ${PROJECT_BINARY_DIR}/sherpa-onnx.pc 355 ${PROJECT_BINARY_DIR}/sherpa-onnx.pc
338 DESTINATION 356 DESTINATION
339 - . 357 + ./
340 ) 358 )
341 message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") 359 message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
@@ -118,18 +118,6 @@ rm -rf install/lib/pkgconfig @@ -118,18 +118,6 @@ rm -rf install/lib/pkgconfig
118 # cd /data/local/tmp 118 # cd /data/local/tmp
119 # ./sherpa-onnx 119 # ./sherpa-onnx
120 # 120 #
121 -# which shows the following error log:  
122 -#  
123 -# CANNOT LINK EXECUTABLE "./sherpa-onnx": library "libsherpa-onnx-core.so" not found: needed by main executable  
124 -#  
125 -# Please run:  
126 -#  
127 -# export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH  
128 -#  
129 -# and then you can run:  
130 -#  
131 -# ./sherpa-onnx  
132 -#  
133 # It should show the help message of sherpa-onnx. 121 # It should show the help message of sherpa-onnx.
134 # 122 #
135 # Please use the above approach to copy model files to your phone. 123 # 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 @@ -11,7 +11,7 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
11 exit 1 11 exit 1
12 fi 12 fi
13 13
14 -if [[ ! -f ../build/lib/libsherpa-onnx-core.a && ! -f ../build/lib/libsherpa-onnx-core.dylib && ! -f ../build/lib/libsherpa-onnx-core.so ]]; then 14 +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
15 echo "Please build sherpa-onnx first. You can use" 15 echo "Please build sherpa-onnx first. You can use"
16 echo "" 16 echo ""
17 echo " cd /path/to/sherpa-onnx" 17 echo " cd /path/to/sherpa-onnx"
@@ -76,19 +76,8 @@ def get_binaries(): @@ -76,19 +76,8 @@ def get_binaries():
76 76
77 if is_windows(): 77 if is_windows():
78 binaries += [ 78 binaries += [
79 - "espeak-ng.dll",  
80 - "kaldi-decoder-core.dll",  
81 - "kaldi-native-fbank-core.dll",  
82 "onnxruntime.dll", 79 "onnxruntime.dll",
83 - "ssentencepiece_core.dll",  
84 - "piper_phonemize.dll",  
85 "sherpa-onnx-c-api.dll", 80 "sherpa-onnx-c-api.dll",
86 - "sherpa-onnx-core.dll",  
87 - "sherpa-onnx-fstfar.dll",  
88 - "sherpa-onnx-fst.dll",  
89 - "sherpa-onnx-kaldifst-core.dll",  
90 - "sherpa-onnx-portaudio.dll",  
91 - "ucd.dll",  
92 ] 81 ]
93 82
94 return binaries 83 return binaries
@@ -145,6 +134,7 @@ class BuildExtension(build_ext): @@ -145,6 +134,7 @@ class BuildExtension(build_ext):
145 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF " 134 extra_cmake_args += " -DBUILD_PIPER_PHONMIZE_TESTS=OFF "
146 extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF " 135 extra_cmake_args += " -DBUILD_ESPEAK_NG_EXE=OFF "
147 extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF " 136 extra_cmake_args += " -DBUILD_ESPEAK_NG_TESTS=OFF "
  137 + extra_cmake_args += " -DSHERPA_ONNX_ENABLE_C_API=ON "
148 138
149 extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF " 139 extra_cmake_args += " -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF "
150 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF " 140 extra_cmake_args += " -DSHERPA_ONNX_ENABLE_CHECK=OFF "
@@ -161,7 +151,7 @@ class BuildExtension(build_ext): @@ -161,7 +151,7 @@ class BuildExtension(build_ext):
161 if is_windows(): 151 if is_windows():
162 build_cmd = f""" 152 build_cmd = f"""
163 cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir} 153 cmake {cmake_args} -B {self.build_temp} -S {sherpa_onnx_dir}
164 - cmake --build {self.build_temp} --target install --config Release -- -m 154 + cmake --build {self.build_temp} --target install --config Release -- -m:2
165 """ 155 """
166 print(f"build command is:\n{build_cmd}") 156 print(f"build command is:\n{build_cmd}")
167 ret = os.system( 157 ret = os.system(
@@ -171,7 +161,7 @@ class BuildExtension(build_ext): @@ -171,7 +161,7 @@ class BuildExtension(build_ext):
171 raise Exception("Failed to configure sherpa") 161 raise Exception("Failed to configure sherpa")
172 162
173 ret = os.system( 163 ret = os.system(
174 - f"cmake --build {self.build_temp} --target install --config Release -- -m" # noqa 164 + f"cmake --build {self.build_temp} --target install --config Release -- -m:2" # noqa
175 ) 165 )
176 if ret != 0: 166 if ret != 0:
177 raise Exception("Failed to build and install sherpa") 167 raise Exception("Failed to build and install sherpa")
@@ -226,5 +216,11 @@ class BuildExtension(build_ext): @@ -226,5 +216,11 @@ class BuildExtension(build_ext):
226 shutil.rmtree(f"{install_dir}/share") 216 shutil.rmtree(f"{install_dir}/share")
227 shutil.rmtree(f"{install_dir}/lib/pkgconfig") 217 shutil.rmtree(f"{install_dir}/lib/pkgconfig")
228 218
  219 + if is_linux():
  220 + os.remove(f"{install_dir}/lib/libonnxruntime.so")
  221 +
  222 + if is_macos():
  223 + os.remove(f"{install_dir}/lib/libonnxruntime.dylib")
  224 +
229 if is_windows(): 225 if is_windows():
230 shutil.rmtree(f"{install_dir}/lib") 226 shutil.rmtree(f"{install_dir}/lib")
1 function(download_espeak_ng_for_piper) 1 function(download_espeak_ng_for_piper)
2 include(FetchContent) 2 include(FetchContent)
3 3
4 - set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")  
5 - set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")  
6 - set(espeak_ng_HASH "SHA256=745e35b21ece6804b4a1839722f9e625ac909380c8f85873ad71bf145877075a") 4 + set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
  5 + set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip")
  6 + set(espeak_ng_HASH "SHA256=70cbf4050e7a014aae19140b05e57249da4720f56128459fbe3a93beaf971ae6")
7 7
8 set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE) 8 set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE)
9 set(USE_ASYNC OFF CACHE BOOL "" FORCE) 9 set(USE_ASYNC OFF CACHE BOOL "" FORCE)
@@ -21,11 +21,11 @@ function(download_espeak_ng_for_piper) @@ -21,11 +21,11 @@ function(download_espeak_ng_for_piper)
21 # If you don't have access to the Internet, 21 # If you don't have access to the Internet,
22 # please pre-download kaldi-decoder 22 # please pre-download kaldi-decoder
23 set(possible_file_locations 23 set(possible_file_locations
24 - $ENV{HOME}/Downloads/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip  
25 - ${CMAKE_SOURCE_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip  
26 - ${CMAKE_BINARY_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip  
27 - /tmp/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip  
28 - /star-fj/fangjun/download/github/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip 24 + $ENV{HOME}/Downloads/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
  25 + ${CMAKE_SOURCE_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
  26 + ${CMAKE_BINARY_DIR}/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
  27 + /tmp/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
  28 + /star-fj/fangjun/download/github/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip
29 ) 29 )
30 30
31 foreach(f IN LISTS possible_file_locations) 31 foreach(f IN LISTS possible_file_locations)
@@ -53,7 +53,23 @@ function(download_espeak_ng_for_piper) @@ -53,7 +53,23 @@ function(download_espeak_ng_for_piper)
53 message(STATUS "espeak-ng is downloaded to ${espeak_ng_SOURCE_DIR}") 53 message(STATUS "espeak-ng is downloaded to ${espeak_ng_SOURCE_DIR}")
54 message(STATUS "espeak-ng binary dir is ${espeak_ng_BINARY_DIR}") 54 message(STATUS "espeak-ng binary dir is ${espeak_ng_BINARY_DIR}")
55 55
  56 + if(BUILD_SHARED_LIBS)
  57 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  58 + set(BUILD_SHARED_LIBS OFF)
  59 + endif()
  60 +
56 add_subdirectory(${espeak_ng_SOURCE_DIR} ${espeak_ng_BINARY_DIR}) 61 add_subdirectory(${espeak_ng_SOURCE_DIR} ${espeak_ng_BINARY_DIR})
  62 +
  63 + if(_build_shared_libs_bak)
  64 + set_target_properties(espeak-ng
  65 + PROPERTIES
  66 + POSITION_INDEPENDENT_CODE ON
  67 + C_VISIBILITY_PRESET hidden
  68 + CXX_VISIBILITY_PRESET hidden
  69 + )
  70 + set(BUILD_SHARED_LIBS ON)
  71 + endif()
  72 +
57 set(espeak_ng_SOURCE_DIR ${espeak_ng_SOURCE_DIR} PARENT_SCOPE) 73 set(espeak_ng_SOURCE_DIR ${espeak_ng_SOURCE_DIR} PARENT_SCOPE)
58 74
59 if(WIN32 AND MSVC) 75 if(WIN32 AND MSVC)
@@ -107,27 +123,11 @@ function(download_espeak_ng_for_piper) @@ -107,27 +123,11 @@ function(download_espeak_ng_for_piper)
107 ${espeak_ng_SOURCE_DIR}/src/ucd-tools/src/include 123 ${espeak_ng_SOURCE_DIR}/src/ucd-tools/src/include
108 ) 124 )
109 125
110 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
111 - install(TARGETS  
112 - espeak-ng  
113 - ucd  
114 - DESTINATION ..)  
115 - else()  
116 - install(TARGETS  
117 - espeak-ng  
118 - ucd  
119 - DESTINATION lib)  
120 - endif()  
121 -  
122 if(NOT BUILD_SHARED_LIBS) 126 if(NOT BUILD_SHARED_LIBS)
123 - install(TARGETS ucd DESTINATION lib)  
124 - endif()  
125 -  
126 - if(WIN32 AND BUILD_SHARED_LIBS)  
127 install(TARGETS 127 install(TARGETS
128 espeak-ng 128 espeak-ng
129 ucd 129 ucd
130 - DESTINATION bin) 130 + DESTINATION lib)
131 endif() 131 endif()
132 endfunction() 132 endfunction()
133 133
@@ -45,8 +45,25 @@ function(download_kaldi_decoder) @@ -45,8 +45,25 @@ function(download_kaldi_decoder)
45 message(STATUS "kaldi-decoder's binary dir is ${kaldi_decoder_BINARY_DIR}") 45 message(STATUS "kaldi-decoder's binary dir is ${kaldi_decoder_BINARY_DIR}")
46 46
47 include_directories(${kaldi_decoder_SOURCE_DIR}) 47 include_directories(${kaldi_decoder_SOURCE_DIR})
  48 +
  49 + if(BUILD_SHARED_LIBS)
  50 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  51 + set(BUILD_SHARED_LIBS OFF)
  52 + endif()
  53 +
48 add_subdirectory(${kaldi_decoder_SOURCE_DIR} ${kaldi_decoder_BINARY_DIR} EXCLUDE_FROM_ALL) 54 add_subdirectory(${kaldi_decoder_SOURCE_DIR} ${kaldi_decoder_BINARY_DIR} EXCLUDE_FROM_ALL)
49 55
  56 + if(_build_shared_libs_bak)
  57 + set_target_properties(
  58 + kaldi-decoder-core
  59 + PROPERTIES
  60 + POSITION_INDEPENDENT_CODE ON
  61 + C_VISIBILITY_PRESET hidden
  62 + CXX_VISIBILITY_PRESET hidden
  63 + )
  64 + set(BUILD_SHARED_LIBS ON)
  65 + endif()
  66 +
50 if(WIN32 AND MSVC) 67 if(WIN32 AND MSVC)
51 target_compile_options(kaldi-decoder-core PUBLIC 68 target_compile_options(kaldi-decoder-core PUBLIC
52 /wd4018 69 /wd4018
@@ -58,14 +75,7 @@ function(download_kaldi_decoder) @@ -58,14 +75,7 @@ function(download_kaldi_decoder)
58 INTERFACE 75 INTERFACE
59 ${kaldi-decoder_SOURCE_DIR}/ 76 ${kaldi-decoder_SOURCE_DIR}/
60 ) 77 )
61 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
62 - install(TARGETS  
63 - kaldi-decoder-core  
64 - kaldifst_core  
65 - fst  
66 - fstfar  
67 - DESTINATION ..)  
68 - else() 78 + if(NOT BUILD_SHARED_LIBS)
69 install(TARGETS 79 install(TARGETS
70 kaldi-decoder-core 80 kaldi-decoder-core
71 kaldifst_core 81 kaldifst_core
@@ -73,15 +83,6 @@ function(download_kaldi_decoder) @@ -73,15 +83,6 @@ function(download_kaldi_decoder)
73 fstfar 83 fstfar
74 DESTINATION lib) 84 DESTINATION lib)
75 endif() 85 endif()
76 -  
77 - if(WIN32 AND BUILD_SHARED_LIBS)  
78 - install(TARGETS  
79 - kaldi-decoder-core  
80 - kaldifst_core  
81 - fst  
82 - fstfar  
83 - DESTINATION bin)  
84 - endif()  
85 endfunction() 86 endfunction()
86 87
87 download_kaldi_decoder() 88 download_kaldi_decoder()
@@ -44,20 +44,30 @@ function(download_kaldi_native_fbank) @@ -44,20 +44,30 @@ function(download_kaldi_native_fbank)
44 message(STATUS "kaldi-native-fbank is downloaded to ${kaldi_native_fbank_SOURCE_DIR}") 44 message(STATUS "kaldi-native-fbank is downloaded to ${kaldi_native_fbank_SOURCE_DIR}")
45 message(STATUS "kaldi-native-fbank's binary dir is ${kaldi_native_fbank_BINARY_DIR}") 45 message(STATUS "kaldi-native-fbank's binary dir is ${kaldi_native_fbank_BINARY_DIR}")
46 46
  47 + if(BUILD_SHARED_LIBS)
  48 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  49 + set(BUILD_SHARED_LIBS OFF)
  50 + endif()
  51 +
47 add_subdirectory(${kaldi_native_fbank_SOURCE_DIR} ${kaldi_native_fbank_BINARY_DIR} EXCLUDE_FROM_ALL) 52 add_subdirectory(${kaldi_native_fbank_SOURCE_DIR} ${kaldi_native_fbank_BINARY_DIR} EXCLUDE_FROM_ALL)
48 53
  54 + if(_build_shared_libs_bak)
  55 + set_target_properties(kaldi-native-fbank-core
  56 + PROPERTIES
  57 + POSITION_INDEPENDENT_CODE ON
  58 + C_VISIBILITY_PRESET hidden
  59 + CXX_VISIBILITY_PRESET hidden
  60 + )
  61 + set(BUILD_SHARED_LIBS ON)
  62 + endif()
  63 +
49 target_include_directories(kaldi-native-fbank-core 64 target_include_directories(kaldi-native-fbank-core
50 INTERFACE 65 INTERFACE
51 ${kaldi_native_fbank_SOURCE_DIR}/ 66 ${kaldi_native_fbank_SOURCE_DIR}/
52 ) 67 )
53 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
54 - install(TARGETS kaldi-native-fbank-core DESTINATION ..)  
55 - else()  
56 - install(TARGETS kaldi-native-fbank-core DESTINATION lib)  
57 - endif()  
58 68
59 - if(WIN32 AND BUILD_SHARED_LIBS)  
60 - install(TARGETS kaldi-native-fbank-core DESTINATION bin) 69 + if(NOT BUILD_SHARED_LIBS)
  70 + install(TARGETS kaldi-native-fbank-core DESTINATION lib)
61 endif() 71 endif()
62 endfunction() 72 endfunction()
63 73
@@ -43,8 +43,23 @@ function(download_kaldifst) @@ -43,8 +43,23 @@ function(download_kaldifst)
43 43
44 list(APPEND CMAKE_MODULE_PATH ${kaldifst_SOURCE_DIR}/cmake) 44 list(APPEND CMAKE_MODULE_PATH ${kaldifst_SOURCE_DIR}/cmake)
45 45
  46 + if(BUILD_SHARED_LIBS)
  47 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  48 + set(BUILD_SHARED_LIBS OFF)
  49 + endif()
  50 +
46 add_subdirectory(${kaldifst_SOURCE_DIR} ${kaldifst_BINARY_DIR} EXCLUDE_FROM_ALL) 51 add_subdirectory(${kaldifst_SOURCE_DIR} ${kaldifst_BINARY_DIR} EXCLUDE_FROM_ALL)
47 52
  53 + if(_build_shared_libs_bak)
  54 + set_target_properties(kaldifst_core
  55 + PROPERTIES
  56 + POSITION_INDEPENDENT_CODE ON
  57 + C_VISIBILITY_PRESET hidden
  58 + CXX_VISIBILITY_PRESET hidden
  59 + )
  60 + set(BUILD_SHARED_LIBS ON)
  61 + endif()
  62 +
48 target_include_directories(kaldifst_core 63 target_include_directories(kaldifst_core
49 PUBLIC 64 PUBLIC
50 ${kaldifst_SOURCE_DIR}/ 65 ${kaldifst_SOURCE_DIR}/
@@ -67,7 +67,24 @@ function(download_openfst) @@ -67,7 +67,24 @@ function(download_openfst)
67 FetchContent_Populate(openfst) 67 FetchContent_Populate(openfst)
68 endif() 68 endif()
69 message(STATUS "openfst is downloaded to ${openfst_SOURCE_DIR}") 69 message(STATUS "openfst is downloaded to ${openfst_SOURCE_DIR}")
  70 +
  71 + if(_build_shared_libs_bak)
  72 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  73 + set(BUILD_SHARED_LIBS OFF)
  74 + endif()
  75 +
70 add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL) 76 add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL)
  77 +
  78 + if(_build_shared_libs_bak)
  79 + set_target_properties(fst fstfar
  80 + PROPERTIES
  81 + POSITION_INDEPENDENT_CODE ON
  82 + C_VISIBILITY_PRESET hidden
  83 + CXX_VISIBILITY_PRESET hidden
  84 + )
  85 + set(BUILD_SHARED_LIBS ON)
  86 + endif()
  87 +
71 set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE) 88 set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE)
72 89
73 set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst") 90 set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst")
@@ -40,8 +40,23 @@ function(download_piper_phonemize) @@ -40,8 +40,23 @@ function(download_piper_phonemize)
40 message(STATUS "piper-phonemize is downloaded to ${piper_phonemize_SOURCE_DIR}") 40 message(STATUS "piper-phonemize is downloaded to ${piper_phonemize_SOURCE_DIR}")
41 message(STATUS "piper-phonemize binary dir is ${piper_phonemize_BINARY_DIR}") 41 message(STATUS "piper-phonemize binary dir is ${piper_phonemize_BINARY_DIR}")
42 42
  43 + if(BUILD_SHARED_LIBS)
  44 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  45 + set(BUILD_SHARED_LIBS OFF)
  46 + endif()
  47 +
43 add_subdirectory(${piper_phonemize_SOURCE_DIR} ${piper_phonemize_BINARY_DIR} EXCLUDE_FROM_ALL) 48 add_subdirectory(${piper_phonemize_SOURCE_DIR} ${piper_phonemize_BINARY_DIR} EXCLUDE_FROM_ALL)
44 49
  50 + if(_build_shared_libs_bak)
  51 + set_target_properties(piper_phonemize
  52 + PROPERTIES
  53 + POSITION_INDEPENDENT_CODE ON
  54 + C_VISIBILITY_PRESET hidden
  55 + CXX_VISIBILITY_PRESET hidden
  56 + )
  57 + set(BUILD_SHARED_LIBS ON)
  58 + endif()
  59 +
45 if(WIN32 AND MSVC) 60 if(WIN32 AND MSVC)
46 target_compile_options(piper_phonemize PUBLIC 61 target_compile_options(piper_phonemize PUBLIC
47 /wd4309 62 /wd4309
@@ -53,21 +68,11 @@ function(download_piper_phonemize) @@ -53,21 +68,11 @@ function(download_piper_phonemize)
53 ${piper_phonemize_SOURCE_DIR}/src/include 68 ${piper_phonemize_SOURCE_DIR}/src/include
54 ) 69 )
55 70
56 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
57 - install(TARGETS  
58 - piper_phonemize  
59 - DESTINATION ..)  
60 - else() 71 + if(NOT BUILD_SHARED_LIBS)
61 install(TARGETS 72 install(TARGETS
62 piper_phonemize 73 piper_phonemize
63 DESTINATION lib) 74 DESTINATION lib)
64 endif() 75 endif()
65 -  
66 - if(WIN32 AND BUILD_SHARED_LIBS)  
67 - install(TARGETS  
68 - piper_phonemize  
69 - DESTINATION bin)  
70 - endif()  
71 endfunction() 76 endfunction()
72 77
73 download_piper_phonemize() 78 download_piper_phonemize()
@@ -26,13 +26,9 @@ function(download_portaudio) @@ -26,13 +26,9 @@ function(download_portaudio)
26 endif() 26 endif()
27 endforeach() 27 endforeach()
28 28
29 - if(BUILD_SHARED_LIBS)  
30 - set(PA_BUILD_SHARED ON CACHE BOOL "" FORCE)  
31 - set(PA_BUILD_STATIC OFF CACHE BOOL "" FORCE)  
32 - else()  
33 - set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)  
34 - set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)  
35 - endif() 29 + # Always use static build
  30 + set(PA_BUILD_SHARED OFF CACHE BOOL "" FORCE)
  31 + set(PA_BUILD_STATIC ON CACHE BOOL "" FORCE)
36 32
37 FetchContent_Declare(portaudio 33 FetchContent_Declare(portaudio
38 URL 34 URL
@@ -55,28 +51,17 @@ function(download_portaudio) @@ -55,28 +51,17 @@ function(download_portaudio)
55 51
56 add_subdirectory(${portaudio_SOURCE_DIR} ${portaudio_BINARY_DIR} EXCLUDE_FROM_ALL) 52 add_subdirectory(${portaudio_SOURCE_DIR} ${portaudio_BINARY_DIR} EXCLUDE_FROM_ALL)
57 53
58 - if(BUILD_SHARED_LIBS)  
59 - set_target_properties(portaudio PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio")  
60 - if(NOT WIN32)  
61 - target_compile_options(portaudio PRIVATE "-Wno-deprecated-declarations")  
62 - endif() 54 + set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")
  55 + if(NOT WIN32)
  56 + target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")
  57 + endif()
63 58
64 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
65 - install(TARGETS portaudio DESTINATION ..)  
66 - else()  
67 - install(TARGETS portaudio DESTINATION lib)  
68 - endif()  
69 - else()  
70 - set_target_properties(portaudio_static PROPERTIES OUTPUT_NAME "sherpa-onnx-portaudio_static")  
71 - if(NOT WIN32)  
72 - target_compile_options(portaudio_static PRIVATE "-Wno-deprecated-declarations")  
73 - endif()  
74 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
75 - install(TARGETS portaudio_static DESTINATION ..)  
76 - else()  
77 - install(TARGETS portaudio_static DESTINATION lib)  
78 - endif() 59 + if(NOT BUILD_SHARED_LIBS AND SHERPA_ONNX_ENABLE_BINARY)
  60 + install(TARGETS
  61 + portaudio_static
  62 + DESTINATION lib)
79 endif() 63 endif()
  64 +
80 endfunction() 65 endfunction()
81 66
82 download_portaudio() 67 download_portaudio()
  1 +# Note: If you use Python, then the prefix might not be correct.
  2 +#
  3 +# You need to either manually modify this file to change the prefix to the location
  4 +# where this sherpa-onnx.pc file actually resides
  5 +# or
  6 +# you can use
  7 +#
  8 +# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
  9 +
  10 +prefix="@CMAKE_INSTALL_PREFIX@"
  11 +exec_prefix="${prefix}"
  12 +includedir="${prefix}/include"
  13 +libdir="${exec_prefix}/lib"
  14 +
  15 +Name: sherpa-onnx
  16 +Description: pkg-config for sherpa-onnx
  17 +URL: https://github.com/k2-fsa/sherpa-onnx
  18 +
  19 +Version: @SHERPA_ONNX_VERSION@
  20 +Cflags: -I"${includedir}"
  21 +
  22 +# Note: -lcargs is required only for the following file
  23 +# https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
  24 +# We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c
  25 +Libs: -L"${libdir}" -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@
  1 +# Note: If you use Python, then the prefix might not be correct.
  2 +#
  3 +# You need to either manually modify this file to change the prefix to the location
  4 +# where this sherpa-onnx.pc file actually resides
  5 +# or
  6 +# you can use
  7 +#
  8 +# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
  9 +
1 prefix="@CMAKE_INSTALL_PREFIX@" 10 prefix="@CMAKE_INSTALL_PREFIX@"
2 exec_prefix="${prefix}" 11 exec_prefix="${prefix}"
3 includedir="${prefix}/include" 12 includedir="${prefix}/include"
  1 +# Note: If you use Python, then the prefix might not be correct.
  2 +#
  3 +# You need to either manually modify this file to change the prefix to the location
  4 +# where this sherpa-onnx.pc file actually resides
  5 +# or
  6 +# you can use
  7 +#
  8 +# pkg-config --define-variable=prefix=/path/to/the/dir/containing/this/file --cflags sherpa-onnx
  9 +
1 prefix="@CMAKE_INSTALL_PREFIX@" 10 prefix="@CMAKE_INSTALL_PREFIX@"
2 exec_prefix="${prefix}" 11 exec_prefix="${prefix}"
3 includedir="${prefix}/include" 12 includedir="${prefix}/include"
@@ -42,22 +42,32 @@ function(download_simple_sentencepiece) @@ -42,22 +42,32 @@ function(download_simple_sentencepiece)
42 FetchContent_Populate(simple-sentencepiece) 42 FetchContent_Populate(simple-sentencepiece)
43 endif() 43 endif()
44 message(STATUS "simple-sentencepiece is downloaded to ${simple-sentencepiece_SOURCE_DIR}") 44 message(STATUS "simple-sentencepiece is downloaded to ${simple-sentencepiece_SOURCE_DIR}")
  45 +
  46 + if(BUILD_SHARED_LIBS)
  47 + set(_build_shared_libs_bak ${BUILD_SHARED_LIBS})
  48 + set(BUILD_SHARED_LIBS OFF)
  49 + endif()
  50 +
45 add_subdirectory(${simple-sentencepiece_SOURCE_DIR} ${simple-sentencepiece_BINARY_DIR} EXCLUDE_FROM_ALL) 51 add_subdirectory(${simple-sentencepiece_SOURCE_DIR} ${simple-sentencepiece_BINARY_DIR} EXCLUDE_FROM_ALL)
46 52
  53 + if(_build_shared_libs_bak)
  54 + set_target_properties(ssentencepiece_core
  55 + PROPERTIES
  56 + POSITION_INDEPENDENT_CODE ON
  57 + C_VISIBILITY_PRESET hidden
  58 + CXX_VISIBILITY_PRESET hidden
  59 + )
  60 + set(BUILD_SHARED_LIBS ON)
  61 + endif()
  62 +
47 target_include_directories(ssentencepiece_core 63 target_include_directories(ssentencepiece_core
48 PUBLIC 64 PUBLIC
49 ${simple-sentencepiece_SOURCE_DIR}/ 65 ${simple-sentencepiece_SOURCE_DIR}/
50 ) 66 )
51 67
52 - if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
53 - install(TARGETS ssentencepiece_core DESTINATION ..)  
54 - else() 68 + if(NOT BUILD_SHARED_LIBS)
55 install(TARGETS ssentencepiece_core DESTINATION lib) 69 install(TARGETS ssentencepiece_core DESTINATION lib)
56 endif() 70 endif()
57 -  
58 - if(WIN32 AND BUILD_SHARED_LIBS)  
59 - install(TARGETS ssentencepiece_core DESTINATION bin)  
60 - endif()  
61 endfunction() 71 endfunction()
62 72
63 download_simple_sentencepiece() 73 download_simple_sentencepiece()
@@ -10,7 +10,7 @@ environment: @@ -10,7 +10,7 @@ environment:
10 10
11 # Add regular dependencies here. 11 # Add regular dependencies here.
12 dependencies: 12 dependencies:
13 - sherpa_onnx: ^1.10.9 13 + sherpa_onnx: ^1.10.10
14 path: ^1.9.0 14 path: ^1.9.0
15 args: ^2.5.0 15 args: ^2.5.0
16 16
@@ -11,7 +11,7 @@ environment: @@ -11,7 +11,7 @@ environment:
11 11
12 # Add regular dependencies here. 12 # Add regular dependencies here.
13 dependencies: 13 dependencies:
14 - sherpa_onnx: ^1.10.9 14 + sherpa_onnx: ^1.10.10
15 path: ^1.9.0 15 path: ^1.9.0
16 args: ^2.5.0 16 args: ^2.5.0
17 17
@@ -8,7 +8,7 @@ environment: @@ -8,7 +8,7 @@ environment:
8 8
9 # Add regular dependencies here. 9 # Add regular dependencies here.
10 dependencies: 10 dependencies:
11 - sherpa_onnx: ^1.10.9 11 + sherpa_onnx: ^1.10.10
12 path: ^1.9.0 12 path: ^1.9.0
13 args: ^2.5.0 13 args: ^2.5.0
14 14
@@ -9,7 +9,7 @@ environment: @@ -9,7 +9,7 @@ environment:
9 sdk: ^3.4.0 9 sdk: ^3.4.0
10 10
11 dependencies: 11 dependencies:
12 - sherpa_onnx: ^1.10.9 12 + sherpa_onnx: ^1.10.10
13 path: ^1.9.0 13 path: ^1.9.0
14 args: ^2.5.0 14 args: ^2.5.0
15 15
@@ -11,7 +11,7 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then @@ -11,7 +11,7 @@ if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
11 exit 1 11 exit 1
12 fi 12 fi
13 13
14 -if [[ ! -f ../build/lib/libsherpa-onnx-core.a && ! -f ../build/lib/libsherpa-onnx-core.dylib && ! -f ../build/lib/libsherpa-onnx-core.so ]]; then 14 +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
15 echo "Please build sherpa-onnx first. You can use" 15 echo "Please build sherpa-onnx first. You can use"
16 echo "" 16 echo ""
17 echo " cd /path/to/sherpa-onnx" 17 echo " cd /path/to/sherpa-onnx"
@@ -5,7 +5,7 @@ description: > @@ -5,7 +5,7 @@ description: >
5 5
6 publish_to: 'none' 6 publish_to: 'none'
7 7
8 -version: 1.10.1 8 +version: 1.10.10
9 9
10 topics: 10 topics:
11 - speech-recognition 11 - speech-recognition
@@ -30,7 +30,7 @@ dependencies: @@ -30,7 +30,7 @@ dependencies:
30 record: ^5.1.0 30 record: ^5.1.0
31 url_launcher: ^6.2.6 31 url_launcher: ^6.2.6
32 32
33 - sherpa_onnx: ^1.10.9 33 + sherpa_onnx: ^1.10.10
34 # sherpa_onnx: 34 # sherpa_onnx:
35 # path: ../../flutter/sherpa_onnx 35 # path: ../../flutter/sherpa_onnx
36 36
@@ -17,7 +17,7 @@ topics: @@ -17,7 +17,7 @@ topics:
17 - voice-activity-detection 17 - voice-activity-detection
18 18
19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec 19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
20 -version: 1.10.9 20 +version: 1.10.10
21 21
22 homepage: https://github.com/k2-fsa/sherpa-onnx 22 homepage: https://github.com/k2-fsa/sherpa-onnx
23 23
@@ -30,16 +30,16 @@ dependencies: @@ -30,16 +30,16 @@ dependencies:
30 flutter: 30 flutter:
31 sdk: flutter 31 sdk: flutter
32 32
33 - sherpa_onnx_android: ^1.10.9 33 + sherpa_onnx_android: ^1.10.10
34 # path: ../sherpa_onnx_android 34 # path: ../sherpa_onnx_android
35 35
36 - sherpa_onnx_macos: ^1.10.9 36 + sherpa_onnx_macos: ^1.10.10
37 # path: ../sherpa_onnx_macos 37 # path: ../sherpa_onnx_macos
38 38
39 - sherpa_onnx_linux: ^1.10.9 39 + sherpa_onnx_linux: ^1.10.10
40 # path: ../sherpa_onnx_linux 40 # path: ../sherpa_onnx_linux
41 # 41 #
42 - sherpa_onnx_windows: ^1.10.9 42 + sherpa_onnx_windows: ^1.10.10
43 # path: ../sherpa_onnx_windows 43 # path: ../sherpa_onnx_windows
44 44
45 flutter: 45 flutter:
@@ -12,16 +12,6 @@ project(${PROJECT_NAME} LANGUAGES CXX) @@ -12,16 +12,6 @@ project(${PROJECT_NAME} LANGUAGES CXX)
12 # external build triggered from this build file. 12 # external build triggered from this build file.
13 set(sherpa_onnx_linux_bundled_libraries 13 set(sherpa_onnx_linux_bundled_libraries
14 "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so" 14 "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so"
15 - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-core.so"  
16 - "${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-decoder-core.so"  
17 - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-kaldifst-core.so"  
18 - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fstfar.so"  
19 - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fst.so"  
20 - "${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-native-fbank-core.so"  
21 - "${CMAKE_CURRENT_SOURCE_DIR}/libpiper_phonemize.so"  
22 - "${CMAKE_CURRENT_SOURCE_DIR}/libespeak-ng.so"  
23 - "${CMAKE_CURRENT_SOURCE_DIR}/libucd.so"  
24 - "${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so"  
25 - "${CMAKE_CURRENT_SOURCE_DIR}/libssentencepiece_core.so" 15 + "${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so.1.17.1"
26 PARENT_SCOPE 16 PARENT_SCOPE
27 ) 17 )
@@ -13,16 +13,6 @@ project(${PROJECT_NAME} LANGUAGES CXX) @@ -13,16 +13,6 @@ project(${PROJECT_NAME} LANGUAGES CXX)
13 # external build triggered from this build file. 13 # external build triggered from this build file.
14 set(sherpa_onnx_windows_bundled_libraries 14 set(sherpa_onnx_windows_bundled_libraries
15 "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll" 15 "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll"
16 - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-core.dll"  
17 - "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-decoder-core.dll"  
18 - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-kaldifst-core.dll"  
19 - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fstfar.dll"  
20 - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fst.dll"  
21 - "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-native-fbank-core.dll"  
22 - "${CMAKE_CURRENT_SOURCE_DIR}/piper_phonemize.dll"  
23 - "${CMAKE_CURRENT_SOURCE_DIR}/espeak-ng.dll"  
24 - "${CMAKE_CURRENT_SOURCE_DIR}/ucd.dll"  
25 "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime.dll" 16 "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime.dll"
26 - "${CMAKE_CURRENT_SOURCE_DIR}/ssentencepiece_core.dll"  
27 PARENT_SCOPE 17 PARENT_SCOPE
28 ) 18 )
@@ -14,6 +14,7 @@ if [[ ! -f ../build/lib/libsherpa-onnx-jni.dylib && ! -f ../build/lib/libsherpa @@ -14,6 +14,7 @@ if [[ ! -f ../build/lib/libsherpa-onnx-jni.dylib && ! -f ../build/lib/libsherpa
14 -DSHERPA_ONNX_ENABLE_TESTS=OFF \ 14 -DSHERPA_ONNX_ENABLE_TESTS=OFF \
15 -DSHERPA_ONNX_ENABLE_CHECK=OFF \ 15 -DSHERPA_ONNX_ENABLE_CHECK=OFF \
16 -DBUILD_SHARED_LIBS=ON \ 16 -DBUILD_SHARED_LIBS=ON \
  17 + -DBUILD_SHARED_LIBS=ON \
17 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ 18 -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
18 -DSHERPA_ONNX_ENABLE_JNI=ON \ 19 -DSHERPA_ONNX_ENABLE_JNI=ON \
19 .. 20 ..
@@ -44,10 +44,6 @@ function process_linux() { @@ -44,10 +44,6 @@ function process_linux() {
44 44
45 pushd linux 45 pushd linux
46 46
47 - rm -v libpiper_phonemize.so libpiper_phonemize.so.1.2.0  
48 - rm -v libonnxruntime.so  
49 - rm -v libcargs.so  
50 -  
51 popd 47 popd
52 } 48 }
53 49
@@ -69,12 +65,6 @@ function process_macos() { @@ -69,12 +65,6 @@ function process_macos() {
69 cp -v sherpa_onnx/lib/*.dylib ../macos 65 cp -v sherpa_onnx/lib/*.dylib ../macos
70 cd .. 66 cd ..
71 rm -rf t 67 rm -rf t
72 -  
73 - pushd macos  
74 - rm -v libcargs.dylib  
75 - rm -v libonnxruntime.dylib  
76 - rm -v libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib  
77 - popd  
78 } 68 }
79 69
80 process_linux 70 process_linux
@@ -36,18 +36,8 @@ def get_dict(): @@ -36,18 +36,8 @@ def get_dict():
36 36
37 def process_linux(s): 37 def process_linux(s):
38 libs = [ 38 libs = [
39 - "libespeak-ng.so",  
40 - "libkaldi-decoder-core.so",  
41 - "libkaldi-native-fbank-core.so",  
42 "libonnxruntime.so.1.17.1", 39 "libonnxruntime.so.1.17.1",
43 - "libssentencepiece_core.so",  
44 - "libpiper_phonemize.so.1",  
45 "libsherpa-onnx-c-api.so", 40 "libsherpa-onnx-c-api.so",
46 - "libsherpa-onnx-core.so",  
47 - "libsherpa-onnx-fstfar.so",  
48 - "libsherpa-onnx-fst.so",  
49 - "libsherpa-onnx-kaldifst-core.so",  
50 - "libucd.so",  
51 ] 41 ]
52 prefix = f"{src_dir}/linux/" 42 prefix = f"{src_dir}/linux/"
53 libs = [prefix + lib for lib in libs] 43 libs = [prefix + lib for lib in libs]
@@ -66,18 +56,8 @@ def process_linux(s): @@ -66,18 +56,8 @@ def process_linux(s):
66 56
67 def process_macos(s, rid): 57 def process_macos(s, rid):
68 libs = [ 58 libs = [
69 - "libespeak-ng.dylib",  
70 - "libkaldi-decoder-core.dylib",  
71 - "libkaldi-native-fbank-core.dylib",  
72 "libonnxruntime.1.17.1.dylib", 59 "libonnxruntime.1.17.1.dylib",
73 - "libssentencepiece_core.dylib",  
74 - "libpiper_phonemize.1.dylib",  
75 "libsherpa-onnx-c-api.dylib", 60 "libsherpa-onnx-c-api.dylib",
76 - "libsherpa-onnx-core.dylib",  
77 - "libsherpa-onnx-fstfar.dylib",  
78 - "libsherpa-onnx-fst.dylib",  
79 - "libsherpa-onnx-kaldifst-core.dylib",  
80 - "libucd.dylib",  
81 ] 61 ]
82 prefix = f"{src_dir}/macos-{rid}/" 62 prefix = f"{src_dir}/macos-{rid}/"
83 libs = [prefix + lib for lib in libs] 63 libs = [prefix + lib for lib in libs]
@@ -96,18 +76,8 @@ def process_macos(s, rid): @@ -96,18 +76,8 @@ def process_macos(s, rid):
96 76
97 def process_windows(s, rid): 77 def process_windows(s, rid):
98 libs = [ 78 libs = [
99 - "espeak-ng.dll",  
100 - "kaldi-decoder-core.dll",  
101 - "kaldi-native-fbank-core.dll",  
102 "onnxruntime.dll", 79 "onnxruntime.dll",
103 - "ssentencepiece_core.dll",  
104 - "piper_phonemize.dll",  
105 "sherpa-onnx-c-api.dll", 80 "sherpa-onnx-c-api.dll",
106 - "sherpa-onnx-core.dll",  
107 - "sherpa-onnx-fstfar.dll",  
108 - "sherpa-onnx-fst.dll",  
109 - "sherpa-onnx-kaldifst-core.dll",  
110 - "ucd.dll",  
111 ] 81 ]
112 82
113 version = get_version() 83 version = get_version()
@@ -44,7 +44,7 @@ windows_x86_wheel=$src_dir/$windows_x86_wheel_filename @@ -44,7 +44,7 @@ windows_x86_wheel=$src_dir/$windows_x86_wheel_filename
44 windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2 44 windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2
45 windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename 45 windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
46 46
47 -if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then 47 +if [ ! -f $src_dir/linux/libsherpa-onnx-c-api.so ]; then
48 echo "---linux x86_64---" 48 echo "---linux x86_64---"
49 cd linux 49 cd linux
50 mkdir -p wheel 50 mkdir -p wheel
@@ -57,15 +57,12 @@ if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then @@ -57,15 +57,12 @@ if [ ! -f $src_dir/linux/libsherpa-onnx-core.so ]; then
57 unzip $linux_wheel_filename 57 unzip $linux_wheel_filename
58 cp -v sherpa_onnx/lib/*.so* ../ 58 cp -v sherpa_onnx/lib/*.so* ../
59 cd .. 59 cd ..
60 - rm -fv libpiper_phonemize.so libpiper_phonemize.so.1.2.0  
61 - rm -fv libonnxruntime.so  
62 - rm -fv libcargs.so  
63 rm -rf wheel 60 rm -rf wheel
64 ls -lh 61 ls -lh
65 cd .. 62 cd ..
66 fi 63 fi
67 64
68 -if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then 65 +if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
69 echo "--- macOS x86_64---" 66 echo "--- macOS x86_64---"
70 cd macos-x64 67 cd macos-x64
71 mkdir -p wheel 68 mkdir -p wheel
@@ -80,15 +77,12 @@ if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then @@ -80,15 +77,12 @@ if [ ! -f $src_dir/macos-x64/libsherpa-onnx-core.dylib ]; then
80 77
81 cd .. 78 cd ..
82 79
83 - rm -fv libcargs.dylib  
84 - rm -fv libonnxruntime.dylib  
85 - rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib  
86 rm -rf wheel 80 rm -rf wheel
87 ls -lh 81 ls -lh
88 cd .. 82 cd ..
89 fi 83 fi
90 84
91 -if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then 85 +if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-c-api.dylib ]; then
92 echo "--- macOS arm64---" 86 echo "--- macOS arm64---"
93 cd macos-arm64 87 cd macos-arm64
94 mkdir -p wheel 88 mkdir -p wheel
@@ -103,15 +97,12 @@ if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then @@ -103,15 +97,12 @@ if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-core.dylib ]; then
103 97
104 cd .. 98 cd ..
105 99
106 - rm -fv libcargs.dylib  
107 - rm -fv libonnxruntime.dylib  
108 - rm -fv libpiper_phonemize.1.2.0.dylib libpiper_phonemize.dylib  
109 rm -rf wheel 100 rm -rf wheel
110 ls -lh 101 ls -lh
111 cd .. 102 cd ..
112 fi 103 fi
113 104
114 -if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then 105 +if [ ! -f $src_dir/windows-x64/sherpa-onnx-c-api.dll ]; then
115 echo "---windows x64---" 106 echo "---windows x64---"
116 cd windows-x64 107 cd windows-x64
117 mkdir -p wheel 108 mkdir -p wheel
@@ -130,7 +121,7 @@ if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then @@ -130,7 +121,7 @@ if [ ! -f $src_dir/windows-x64/sherpa-onnx-core.dll ]; then
130 cd .. 121 cd ..
131 fi 122 fi
132 123
133 -if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then 124 +if [ ! -f $src_dir/windows-x86/sherpa-onnx-c-api.dll ]; then
134 echo "---windows x86---" 125 echo "---windows x86---"
135 cd windows-x86 126 cd windows-x86
136 mkdir -p wheel 127 mkdir -p wheel
@@ -149,7 +140,7 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then @@ -149,7 +140,7 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then
149 cd .. 140 cd ..
150 fi 141 fi
151 142
152 -if [ ! -f $src_dir/windows-arm64/sherpa-onnx-core.dll ]; then 143 +if [ ! -f $src_dir/windows-arm64/sherpa-onnx-c-api.dll ]; then
153 echo "---windows arm64---" 144 echo "---windows arm64---"
154 cd windows-arm64 145 cd windows-arm64
155 mkdir -p wheel 146 mkdir -p wheel
@@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
2 2
3 package sherpa_onnx 3 package sherpa_onnx
4 4
5 -// #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 5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-apple-darwin -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-apple-darwin
6 import "C" 6 import "C"
@@ -2,5 +2,5 @@ @@ -2,5 +2,5 @@
2 2
3 package sherpa_onnx 3 package sherpa_onnx
4 4
5 -// #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 5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/aarch64-apple-darwin -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/aarch64-apple-darwin
6 import "C" 6 import "C"
  1 +//go:build !android && linux && amd64 && !musl
  2 +
  3 +package sherpa_onnx
  4 +
  5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-unknown-linux-gnu -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/x86_64-unknown-linux-gnu
  6 +import "C"
  1 +//go:build linux && arm && !arm7
  2 +
  3 +package sherpa_onnx
  4 +
  5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/arm-unknown-linux-gnueabihf -lsherpa-onnx-c-api -lonnxruntime -Wl,-rpath,${SRCDIR}/lib/arm-unknown-linux-gnueabihf
  6 +import "C"
  1 +//go:build linux && arm64
  2 +
  3 +package sherpa_onnx
  4 +
  5 +// #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
  6 +import "C"
  1 +//go:build windows && 386
  2 +
  3 +package sherpa_onnx
  4 +
  5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/i686-pc-windows-gnu -lsherpa-onnx-c-api -lonnxruntime
  6 +import "C"
  1 +//go:build windows && amd64
  2 +
  3 +package sherpa_onnx
  4 +
  5 +// #cgo LDFLAGS: -L ${SRCDIR}/lib/x86_64-pc-windows-gnu -lsherpa-onnx-c-api -lonnxruntime
  6 +import "C"
@@ -17,8 +17,11 @@ echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION" @@ -17,8 +17,11 @@ echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
17 function linux() { 17 function linux() {
18 echo "Process linux" 18 echo "Process linux"
19 git clone git@github.com:k2-fsa/sherpa-onnx-go-linux.git 19 git clone git@github.com:k2-fsa/sherpa-onnx-go-linux.git
  20 + rm -v ./sherpa-onnx-go-linux/*.go
  21 +
20 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-linux/ 22 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-linux/
21 cp -v ./_internal/c-api.h ./sherpa-onnx-go-linux/ 23 cp -v ./_internal/c-api.h ./sherpa-onnx-go-linux/
  24 + cp -v ./_internal/build_linux_*.go ./sherpa-onnx-go-linux/
22 25
23 rm -rf sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/lib* 26 rm -rf sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu/lib*
24 dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu) 27 dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
@@ -29,6 +32,10 @@ function linux() { @@ -29,6 +32,10 @@ function linux() {
29 32
30 cp -v sherpa_onnx/lib/*.so* $dst 33 cp -v sherpa_onnx/lib/*.so* $dst
31 34
  35 + pushd $dst
  36 + cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
  37 + popd
  38 +
32 cd .. 39 cd ..
33 rm -rf t 40 rm -rf t
34 41
@@ -41,6 +48,10 @@ function linux() { @@ -41,6 +48,10 @@ function linux() {
41 48
42 cp -v sherpa_onnx/lib/*.so* $dst 49 cp -v sherpa_onnx/lib/*.so* $dst
43 50
  51 + pushd $dst
  52 + cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
  53 + popd
  54 +
44 cd .. 55 cd ..
45 rm -rf t 56 rm -rf t
46 57
@@ -53,6 +64,10 @@ function linux() { @@ -53,6 +64,10 @@ function linux() {
53 64
54 cp -v sherpa_onnx/lib/*.so* $dst 65 cp -v sherpa_onnx/lib/*.so* $dst
55 66
  67 + pushd $dst
  68 + cp -v libonnxruntime.so.1.17.1 libonnxruntime.so
  69 + popd
  70 +
56 cd .. 71 cd ..
57 rm -rf t 72 rm -rf t
58 73
@@ -71,8 +86,10 @@ function linux() { @@ -71,8 +86,10 @@ function linux() {
71 function osx() { 86 function osx() {
72 echo "Process osx-x64" 87 echo "Process osx-x64"
73 git clone git@github.com:k2-fsa/sherpa-onnx-go-macos.git 88 git clone git@github.com:k2-fsa/sherpa-onnx-go-macos.git
  89 + rm -v ./sherpa-onnx-go-macos/*.go
74 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-macos/ 90 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-macos/
75 cp -v ./_internal/c-api.h ./sherpa-onnx-go-macos/ 91 cp -v ./_internal/c-api.h ./sherpa-onnx-go-macos/
  92 + cp -v ./_internal/build_darwin_*.go ./sherpa-onnx-go-macos/
76 93
77 rm -rf sherpa-onnx-go-macos/lib/x86_64-apple-darwin/lib* 94 rm -rf sherpa-onnx-go-macos/lib/x86_64-apple-darwin/lib*
78 dst=$(realpath sherpa-onnx-go-macos/lib/x86_64-apple-darwin/) 95 dst=$(realpath sherpa-onnx-go-macos/lib/x86_64-apple-darwin/)
@@ -84,6 +101,10 @@ function osx() { @@ -84,6 +101,10 @@ function osx() {
84 101
85 cp -v sherpa_onnx/lib/*.dylib $dst/ 102 cp -v sherpa_onnx/lib/*.dylib $dst/
86 103
  104 + pushd $dst
  105 + cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
  106 + popd
  107 +
87 cd .. 108 cd ..
88 rm -rf t 109 rm -rf t
89 110
@@ -98,6 +119,10 @@ function osx() { @@ -98,6 +119,10 @@ function osx() {
98 119
99 cp -v sherpa_onnx/lib/*.dylib $dst/ 120 cp -v sherpa_onnx/lib/*.dylib $dst/
100 121
  122 + pushd $dst
  123 + cp -v libonnxruntime.1.17.1.dylib libonnxruntime.dylib
  124 + popd
  125 +
101 cd .. 126 cd ..
102 rm -rf t 127 rm -rf t
103 echo "------------------------------" 128 echo "------------------------------"
@@ -115,8 +140,10 @@ function osx() { @@ -115,8 +140,10 @@ function osx() {
115 function windows() { 140 function windows() {
116 echo "Process windows" 141 echo "Process windows"
117 git clone git@github.com:k2-fsa/sherpa-onnx-go-windows.git 142 git clone git@github.com:k2-fsa/sherpa-onnx-go-windows.git
  143 + rm -v ./sherpa-onnx-go-windows/*.go
118 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-windows/ 144 cp -v ./sherpa_onnx.go ./sherpa-onnx-go-windows/
119 cp -v ./_internal/c-api.h ./sherpa-onnx-go-windows/ 145 cp -v ./_internal/c-api.h ./sherpa-onnx-go-windows/
  146 + cp -v ./_internal/build_windows_*.go ./sherpa-onnx-go-windows/
120 147
121 rm -fv sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu/* 148 rm -fv sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu/*
122 dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu) 149 dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
@@ -67,15 +67,6 @@ target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) @@ -67,15 +67,6 @@ target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
67 67
68 target_link_libraries(${PROJECT_NAME} 68 target_link_libraries(${PROJECT_NAME}
69 sherpa-onnx-c-api 69 sherpa-onnx-c-api
70 - sherpa-onnx-core  
71 - kaldi-decoder-core  
72 - sherpa-onnx-kaldifst-core  
73 - sherpa-onnx-fstfar  
74 - sherpa-onnx-fst  
75 - kaldi-native-fbank-core  
76 - piper_phonemize  
77 - espeak-ng  
78 - ucd  
79 onnxruntime 70 onnxruntime
80 -Wl,-rpath,$ENV{SHERPA_ONNX_INSTALL_DIR}/lib 71 -Wl,-rpath,$ENV{SHERPA_ONNX_INSTALL_DIR}/lib
81 ) 72 )
@@ -2,11 +2,16 @@ @@ -2,11 +2,16 @@
2 2
3 set -ex 3 set -ex
4 4
5 -if [[ ! -f ../../build/install/lib/libsherpa-onnx-core.dylib && ! -f ../../build/install/lib/libsherpa-onnx-core.so ]]; then 5 +if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-c-api.so ]]; then
6 pushd ../../ 6 pushd ../../
7 mkdir -p build 7 mkdir -p build
8 cd build 8 cd build
9 - cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON .. 9 +
  10 + cmake \
  11 + -DCMAKE_INSTALL_PREFIX=./install \
  12 + -DBUILD_SHARED_LIBS=ON \
  13 + ..
  14 +
10 make install 15 make install
11 popd 16 popd
12 fi 17 fi
@@ -155,7 +155,18 @@ endif() @@ -155,7 +155,18 @@ endif()
155 if(SHERPA_ONNX_ENABLE_CHECK) 155 if(SHERPA_ONNX_ENABLE_CHECK)
156 list(APPEND sources log.cc) 156 list(APPEND sources log.cc)
157 endif() 157 endif()
158 -add_library(sherpa-onnx-core ${sources}) 158 +
  159 +# Always static build
  160 +add_library(sherpa-onnx-core STATIC ${sources})
  161 +
  162 +set_target_properties(
  163 + sherpa-onnx-core
  164 + PROPERTIES
  165 + POSITION_INDEPENDENT_CODE ON
  166 + C_VISIBILITY_PRESET hidden
  167 + CXX_VISIBILITY_PRESET hidden
  168 +)
  169 +
159 if(APPLE) 170 if(APPLE)
160 target_compile_options(sherpa-onnx-core PRIVATE 171 target_compile_options(sherpa-onnx-core PRIVATE
161 -Wno-deprecated-declarations 172 -Wno-deprecated-declarations
@@ -213,6 +224,7 @@ if(SHERPA_ONNX_ENABLE_CHECK) @@ -213,6 +224,7 @@ if(SHERPA_ONNX_ENABLE_CHECK)
213 endif() 224 endif()
214 225
215 if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Linux) 226 if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Linux)
  227 + # This is for linux arm32 and arm64
216 target_link_libraries(sherpa-onnx-core -ldl) 228 target_link_libraries(sherpa-onnx-core -ldl)
217 endif() 229 endif()
218 230
@@ -264,16 +276,10 @@ if(SHERPA_ONNX_ENABLE_BINARY) @@ -264,16 +276,10 @@ if(SHERPA_ONNX_ENABLE_BINARY)
264 endif() 276 endif()
265 endif() 277 endif()
266 278
267 -if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32)  
268 - install(TARGETS sherpa-onnx-core DESTINATION ..)  
269 -else() 279 +if(NOT BUILD_SHARED_LIBS)
270 install(TARGETS sherpa-onnx-core DESTINATION lib) 280 install(TARGETS sherpa-onnx-core DESTINATION lib)
271 endif() 281 endif()
272 282
273 -if(WIN32 AND BUILD_SHARED_LIBS)  
274 - install(TARGETS sherpa-onnx-core DESTINATION bin)  
275 -endif()  
276 -  
277 if(SHERPA_ONNX_ENABLE_BINARY) 283 if(SHERPA_ONNX_ENABLE_BINARY)
278 install( 284 install(
279 TARGETS 285 TARGETS
@@ -311,6 +317,9 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) @@ -311,6 +317,9 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
311 ) 317 )
312 endif() 318 endif()
313 319
  320 + # # To fix the following error for Windows when building exe
  321 + # # mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_Dynamic Release'
  322 +
314 foreach(exe IN LISTS exes) 323 foreach(exe IN LISTS exes)
315 target_link_libraries(${exe} sherpa-onnx-core) 324 target_link_libraries(${exe} sherpa-onnx-core)
316 endforeach() 325 endforeach()
@@ -386,12 +395,6 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) @@ -386,12 +395,6 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
386 microphone.cc 395 microphone.cc
387 ) 396 )
388 397
389 - if(BUILD_SHARED_LIBS)  
390 - set(PA_LIB portaudio)  
391 - else()  
392 - set(PA_LIB portaudio_static)  
393 - endif()  
394 -  
395 set(exes 398 set(exes
396 sherpa-onnx-microphone 399 sherpa-onnx-microphone
397 sherpa-onnx-keyword-spotter-microphone 400 sherpa-onnx-keyword-spotter-microphone
@@ -408,7 +411,7 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) @@ -408,7 +411,7 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
408 endif() 411 endif()
409 412
410 foreach(exe IN LISTS exes) 413 foreach(exe IN LISTS exes)
411 - target_link_libraries(${exe} ${PA_LIB} sherpa-onnx-core) 414 + target_link_libraries(${exe} portaudio_static sherpa-onnx-core)
412 endforeach() 415 endforeach()
413 416
414 if(NOT WIN32) 417 if(NOT WIN32)
@@ -473,7 +476,7 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) @@ -473,7 +476,7 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
473 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib") 476 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
474 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib") 477 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")
475 478
476 - if(SHERPA_ONNX_ENABLE_PYTHON) 479 + if(SHERPA_ONNX_ENABLE_PYTHON AND NOT WIN32)
477 target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 480 target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
478 target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 481 target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
479 target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib") 482 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( @@ -550,4 +553,3 @@ add_custom_target(
550 DEPENDS ${sources}) 553 DEPENDS ${sources})
551 554
552 add_custom_target(check DEPENDS clang-tidy-check) 555 add_custom_target(check DEPENDS clang-tidy-check)
553 -  
@@ -35,5 +35,8 @@ endif() @@ -35,5 +35,8 @@ endif()
35 35
36 add_library(sherpa-onnx-jni ${sources}) 36 add_library(sherpa-onnx-jni ${sources})
37 37
  38 +target_compile_definitions(sherpa-onnx-jni PRIVATE SHERPA_ONNX_BUILD_SHARED_LIBS=1)
  39 +target_compile_definitions(sherpa-onnx-jni PRIVATE SHERPA_ONNX_BUILD_MAIN_LIB=1)
  40 +
38 target_link_libraries(sherpa-onnx-jni sherpa-onnx-core) 41 target_link_libraries(sherpa-onnx-jni sherpa-onnx-core)
39 install(TARGETS sherpa-onnx-jni DESTINATION lib) 42 install(TARGETS sherpa-onnx-jni DESTINATION lib)
@@ -12,11 +12,31 @@ @@ -12,11 +12,31 @@
12 #include "android/asset_manager_jni.h" 12 #include "android/asset_manager_jni.h"
13 #endif 13 #endif
14 14
  15 +#if defined(_WIN32)
  16 +#if defined(SHERPA_ONNX_BUILD_SHARED_LIBS)
  17 +#define SHERPA_ONNX_EXPORT __declspec(dllexport)
  18 +#define SHERPA_ONNX_IMPORT __declspec(dllimport)
  19 +#else
  20 +#define SHERPA_ONNX_EXPORT
  21 +#define SHERPA_ONNX_IMPORT
  22 +#endif
  23 +#else // WIN32
  24 +#define SHERPA_ONNX_EXPORT __attribute__((visibility("default")))
  25 +
  26 +#define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT
  27 +#endif // WIN32
  28 +
  29 +#if defined(SHERPA_ONNX_BUILD_MAIN_LIB)
  30 +#define SHERPA_ONNX_API SHERPA_ONNX_EXPORT
  31 +#else
  32 +#define SHERPA_ONNX_API SHERPA_ONNX_IMPORT
  33 +#endif
  34 +
15 // If you use ndk, you can find "jni.h" inside 35 // If you use ndk, you can find "jni.h" inside
16 // android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include 36 // android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
17 #include "jni.h" // NOLINT 37 #include "jni.h" // NOLINT
18 38
19 -#define SHERPA_ONNX_EXTERN_C extern "C" 39 +#define SHERPA_ONNX_EXTERN_C extern "C" SHERPA_ONNX_API
20 40
21 // defined in jni.cc 41 // defined in jni.cc
22 jobject NewInteger(JNIEnv *env, int32_t value); 42 jobject NewInteger(JNIEnv *env, int32_t value);