Committed by
GitHub
Support including TTS conditionally. (#699)
正在显示
14 个修改的文件
包含
401 行增加
和
65 行删除
| @@ -32,28 +32,45 @@ concurrency: | @@ -32,28 +32,45 @@ concurrency: | ||
| 32 | 32 | ||
| 33 | jobs: | 33 | jobs: |
| 34 | build_xcframework: | 34 | build_xcframework: |
| 35 | - name: Build xcframework on ${{ matrix.os }} | 35 | + name: tts-${{ matrix.with_tts }} |
| 36 | runs-on: ${{ matrix.os }} | 36 | runs-on: ${{ matrix.os }} |
| 37 | strategy: | 37 | strategy: |
| 38 | fail-fast: false | 38 | fail-fast: false |
| 39 | matrix: | 39 | matrix: |
| 40 | os: [macos-latest] | 40 | os: [macos-latest] |
| 41 | + with_tts: [ON, OFF] | ||
| 41 | 42 | ||
| 42 | steps: | 43 | steps: |
| 43 | - uses: actions/checkout@v4 | 44 | - uses: actions/checkout@v4 |
| 44 | 45 | ||
| 45 | - name: Build iOS | 46 | - name: Build iOS |
| 47 | + if: matrix.with_tts == 'ON' | ||
| 46 | shell: bash | 48 | shell: bash |
| 47 | run: | | 49 | run: | |
| 48 | ./build-ios.sh | 50 | ./build-ios.sh |
| 49 | 51 | ||
| 52 | + - name: Build iOS (No tts) | ||
| 53 | + if: matrix.with_tts == 'OFF' | ||
| 54 | + shell: bash | ||
| 55 | + run: | | ||
| 56 | + ./build-ios-no-tts.sh | ||
| 57 | + | ||
| 50 | - name: Display artifacts | 58 | - name: Display artifacts |
| 59 | + if: matrix.with_tts == 'ON' | ||
| 51 | shell: bash | 60 | shell: bash |
| 52 | run: | | 61 | run: | |
| 53 | brew install tree | 62 | brew install tree |
| 54 | tree -L 2 ./build-ios | 63 | tree -L 2 ./build-ios |
| 55 | 64 | ||
| 65 | + - name: Display artifacts | ||
| 66 | + if: matrix.with_tts == 'OFF' | ||
| 67 | + shell: bash | ||
| 68 | + run: | | ||
| 69 | + brew install tree | ||
| 70 | + tree -L 2 ./build-ios-no-tts | ||
| 71 | + | ||
| 56 | - name: Package artifacts | 72 | - name: Package artifacts |
| 73 | + if: matrix.with_tts == 'ON' | ||
| 57 | shell: bash | 74 | shell: bash |
| 58 | run: | | 75 | run: | |
| 59 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | 76 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) |
| @@ -71,11 +88,37 @@ jobs: | @@ -71,11 +88,37 @@ jobs: | ||
| 71 | 88 | ||
| 72 | ls -lh | 89 | ls -lh |
| 73 | 90 | ||
| 91 | + - name: Package artifacts | ||
| 92 | + if: matrix.with_tts == 'OFF' | ||
| 93 | + shell: bash | ||
| 94 | + run: | | ||
| 95 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 96 | + echo "SHERPA_ONNX_VERSION=$SHERPA_ONNX_VERSION" >> "$GITHUB_ENV" | ||
| 97 | + | ||
| 98 | + rm -rf build-ios-no-tts/build | ||
| 99 | + rm -rf build-ios-no-tts/install | ||
| 100 | + rm -rf build-ios-no-tts/ios-onnxruntime/.git | ||
| 101 | + | ||
| 102 | + tree build-ios-no-tts | ||
| 103 | + | ||
| 104 | + filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-ios-no-tts.tar.bz2 | ||
| 105 | + | ||
| 106 | + tar cjvf $filename ./build-ios-no-tts | ||
| 107 | + | ||
| 108 | + ls -lh | ||
| 109 | + | ||
| 74 | - uses: actions/upload-artifact@v4 | 110 | - uses: actions/upload-artifact@v4 |
| 111 | + if: matrix.with_tts == 'ON' | ||
| 75 | with: | 112 | with: |
| 76 | name: sherpa-onnx-ios-libs | 113 | name: sherpa-onnx-ios-libs |
| 77 | path: ./build-ios | 114 | path: ./build-ios |
| 78 | 115 | ||
| 116 | + - uses: actions/upload-artifact@v4 | ||
| 117 | + if: matrix.with_tts == 'OFF' | ||
| 118 | + with: | ||
| 119 | + name: sherpa-onnx-ios-libs-no-tts | ||
| 120 | + path: ./build-ios-no-tts | ||
| 121 | + | ||
| 79 | # https://huggingface.co/docs/hub/spaces-github-actions | 122 | # https://huggingface.co/docs/hub/spaces-github-actions |
| 80 | - name: Publish to huggingface | 123 | - name: Publish to huggingface |
| 81 | if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | 124 | if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') |
| @@ -96,7 +139,7 @@ jobs: | @@ -96,7 +139,7 @@ jobs: | ||
| 96 | cd huggingface | 139 | cd huggingface |
| 97 | git lfs pull | 140 | git lfs pull |
| 98 | 141 | ||
| 99 | - cp -v ../sherpa-onnx-*-ios.tar.bz2 ./ | 142 | + cp -v ../sherpa-onnx-*.tar.bz2 ./ |
| 100 | 143 | ||
| 101 | git status | 144 | git status |
| 102 | git lfs track "*.bz2" | 145 | git lfs track "*.bz2" |
| @@ -113,4 +156,4 @@ jobs: | @@ -113,4 +156,4 @@ jobs: | ||
| 113 | with: | 156 | with: |
| 114 | file_glob: true | 157 | file_glob: true |
| 115 | overwrite: true | 158 | overwrite: true |
| 116 | - file: sherpa-onnx-*-ios.tar.bz2 | 159 | + file: sherpa-onnx-*.tar.bz2 |
| @@ -45,7 +45,7 @@ concurrency: | @@ -45,7 +45,7 @@ concurrency: | ||
| 45 | 45 | ||
| 46 | jobs: | 46 | jobs: |
| 47 | linux: | 47 | linux: |
| 48 | - name: ${{ matrix.build_type }} ${{ matrix.shared_lib }} | 48 | + name: ${{ matrix.build_type }} shared-${{ matrix.shared_lib }} tts-${{ matrix.with_tts }} |
| 49 | runs-on: ${{ matrix.os }} | 49 | runs-on: ${{ matrix.os }} |
| 50 | strategy: | 50 | strategy: |
| 51 | fail-fast: false | 51 | fail-fast: false |
| @@ -53,6 +53,7 @@ jobs: | @@ -53,6 +53,7 @@ jobs: | ||
| 53 | os: [ubuntu-latest] | 53 | os: [ubuntu-latest] |
| 54 | build_type: [Release, Debug] | 54 | build_type: [Release, Debug] |
| 55 | shared_lib: [ON, OFF] | 55 | shared_lib: [ON, OFF] |
| 56 | + with_tts: [ON, OFF] | ||
| 56 | 57 | ||
| 57 | steps: | 58 | steps: |
| 58 | - uses: actions/checkout@v4 | 59 | - uses: actions/checkout@v4 |
| @@ -93,7 +94,7 @@ jobs: | @@ -93,7 +94,7 @@ jobs: | ||
| 93 | mkdir build | 94 | mkdir build |
| 94 | cd build | 95 | cd build |
| 95 | 96 | ||
| 96 | - cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install .. | 97 | + 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 .. |
| 97 | 98 | ||
| 98 | make -j2 | 99 | make -j2 |
| 99 | make install | 100 | make install |
| @@ -120,7 +121,7 @@ jobs: | @@ -120,7 +121,7 @@ jobs: | ||
| 120 | 121 | ||
| 121 | - uses: actions/upload-artifact@v4 | 122 | - uses: actions/upload-artifact@v4 |
| 122 | with: | 123 | with: |
| 123 | - name: release-${{ matrix.build_type }}-${{ matrix.shared_lib }} | 124 | + name: release-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }} |
| 124 | path: build/bin/* | 125 | path: build/bin/* |
| 125 | 126 | ||
| 126 | - name: Test spoken language identification (C API) | 127 | - name: Test spoken language identification (C API) |
| @@ -175,6 +176,7 @@ jobs: | @@ -175,6 +176,7 @@ jobs: | ||
| 175 | .github/scripts/test-offline-ctc.sh | 176 | .github/scripts/test-offline-ctc.sh |
| 176 | 177 | ||
| 177 | - name: Test offline TTS | 178 | - name: Test offline TTS |
| 179 | + if: matrix.with_tts == 'ON' | ||
| 178 | shell: bash | 180 | shell: bash |
| 179 | run: | | 181 | run: | |
| 180 | export PATH=$PWD/build/bin:$PATH | 182 | export PATH=$PWD/build/bin:$PATH |
| @@ -226,7 +228,11 @@ jobs: | @@ -226,7 +228,11 @@ jobs: | ||
| 226 | suffix=static | 228 | suffix=static |
| 227 | fi | 229 | fi |
| 228 | 230 | ||
| 231 | + if [[ ${{ matrix.with_tts }} ]]; then | ||
| 229 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-x64-$suffix | 232 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-x64-$suffix |
| 233 | + else | ||
| 234 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-x64-$suffix-no-tts | ||
| 235 | + fi | ||
| 230 | mkdir $dst | 236 | mkdir $dst |
| 231 | 237 | ||
| 232 | cp -a build/install/bin $dst/ | 238 | cp -a build/install/bin $dst/ |
| @@ -278,6 +284,6 @@ jobs: | @@ -278,6 +284,6 @@ jobs: | ||
| 278 | 284 | ||
| 279 | - uses: actions/upload-artifact@v4 | 285 | - uses: actions/upload-artifact@v4 |
| 280 | with: | 286 | with: |
| 281 | - name: tts-generated-test-files-${{ matrix.build_type }}-${{ matrix.shared_lib }} | 287 | + name: tts-generated-test-files-${{ matrix.build_type }}-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }} |
| 282 | path: tts | 288 | path: tts |
| 283 | 289 |
| @@ -45,13 +45,14 @@ concurrency: | @@ -45,13 +45,14 @@ concurrency: | ||
| 45 | jobs: | 45 | jobs: |
| 46 | macos: | 46 | macos: |
| 47 | runs-on: ${{ matrix.os }} | 47 | runs-on: ${{ matrix.os }} |
| 48 | - name: ${{ matrix.build_type }} ${{ matrix.lib_type }} | 48 | + name: ${{ matrix.build_type }} ${{ matrix.lib_type }} tts-${{ matrix.with_tts }} |
| 49 | strategy: | 49 | strategy: |
| 50 | fail-fast: false | 50 | fail-fast: false |
| 51 | matrix: | 51 | matrix: |
| 52 | os: [macos-latest] | 52 | os: [macos-latest] |
| 53 | build_type: [Release, Debug] | 53 | build_type: [Release, Debug] |
| 54 | lib_type: [static, shared] | 54 | lib_type: [static, shared] |
| 55 | + with_tts: [ON, OFF] | ||
| 55 | 56 | ||
| 56 | steps: | 57 | steps: |
| 57 | - uses: actions/checkout@v4 | 58 | - uses: actions/checkout@v4 |
| @@ -61,7 +62,7 @@ jobs: | @@ -61,7 +62,7 @@ jobs: | ||
| 61 | - name: ccache | 62 | - name: ccache |
| 62 | uses: hendrikmuhs/ccache-action@v1.2 | 63 | uses: hendrikmuhs/ccache-action@v1.2 |
| 63 | with: | 64 | with: |
| 64 | - key: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.lib_type }} | 65 | + key: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.lib_type }}-tts-${{ matrix.with_tts }} |
| 65 | 66 | ||
| 66 | - name: Configure CMake | 67 | - name: Configure CMake |
| 67 | shell: bash | 68 | shell: bash |
| @@ -79,7 +80,7 @@ jobs: | @@ -79,7 +80,7 @@ jobs: | ||
| 79 | BUILD_SHARED_LIBS=ON | 80 | BUILD_SHARED_LIBS=ON |
| 80 | fi | 81 | fi |
| 81 | 82 | ||
| 82 | - cmake -D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_INSTALL_PREFIX=./install .. | 83 | + 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 .. |
| 83 | 84 | ||
| 84 | - name: Build sherpa-onnx for macos | 85 | - name: Build sherpa-onnx for macos |
| 85 | shell: bash | 86 | shell: bash |
| @@ -135,6 +136,7 @@ jobs: | @@ -135,6 +136,7 @@ jobs: | ||
| 135 | .github/scripts/test-online-ctc.sh | 136 | .github/scripts/test-online-ctc.sh |
| 136 | 137 | ||
| 137 | - name: Test offline TTS | 138 | - name: Test offline TTS |
| 139 | + if: matrix.with_tts == 'ON' | ||
| 138 | shell: bash | 140 | shell: bash |
| 139 | run: | | 141 | run: | |
| 140 | export PATH=$PWD/build/bin:$PATH | 142 | export PATH=$PWD/build/bin:$PATH |
| @@ -196,7 +198,11 @@ jobs: | @@ -196,7 +198,11 @@ jobs: | ||
| 196 | run: | | 198 | run: | |
| 197 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | 199 | SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) |
| 198 | 200 | ||
| 201 | + if [[ ${{ matrix.with_tts }} ]]; then | ||
| 199 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-osx-universal2-${{ matrix.lib_type }} | 202 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-osx-universal2-${{ matrix.lib_type }} |
| 203 | + else | ||
| 204 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-osx-universal2-${{ matrix.lib_type }}-no-tts | ||
| 205 | + fi | ||
| 200 | mkdir $dst | 206 | mkdir $dst |
| 201 | 207 | ||
| 202 | cp -a build/install/bin $dst/ | 208 | cp -a build/install/bin $dst/ |
| @@ -40,13 +40,14 @@ concurrency: | @@ -40,13 +40,14 @@ concurrency: | ||
| 40 | 40 | ||
| 41 | jobs: | 41 | jobs: |
| 42 | windows_x64: | 42 | windows_x64: |
| 43 | - name: ${{ matrix.shared_lib }} | 43 | + name: shared-${{ matrix.shared_lib }} tts-${{ matrix.with_tts }} |
| 44 | runs-on: ${{ matrix.os }} | 44 | runs-on: ${{ matrix.os }} |
| 45 | strategy: | 45 | strategy: |
| 46 | fail-fast: false | 46 | fail-fast: false |
| 47 | matrix: | 47 | matrix: |
| 48 | os: [windows-latest] | 48 | os: [windows-latest] |
| 49 | shared_lib: [ON, OFF] | 49 | shared_lib: [ON, OFF] |
| 50 | + with_tts: [ON, OFF] | ||
| 50 | 51 | ||
| 51 | steps: | 52 | steps: |
| 52 | - uses: actions/checkout@v4 | 53 | - uses: actions/checkout@v4 |
| @@ -58,7 +59,8 @@ jobs: | @@ -58,7 +59,8 @@ jobs: | ||
| 58 | run: | | 59 | run: | |
| 59 | mkdir build | 60 | mkdir build |
| 60 | cd build | 61 | cd build |
| 61 | - cmake -A x64 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install .. | 62 | + 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 .. |
| 63 | + | ||
| 62 | - name: Build sherpa-onnx for windows | 64 | - name: Build sherpa-onnx for windows |
| 63 | shell: bash | 65 | shell: bash |
| 64 | run: | | 66 | run: | |
| @@ -93,6 +95,7 @@ jobs: | @@ -93,6 +95,7 @@ jobs: | ||
| 93 | .github/scripts/test-online-ctc.sh | 95 | .github/scripts/test-online-ctc.sh |
| 94 | 96 | ||
| 95 | - name: Test offline TTS | 97 | - name: Test offline TTS |
| 98 | + if: matrix.with_tts == 'ON' | ||
| 96 | shell: bash | 99 | shell: bash |
| 97 | run: | | 100 | run: | |
| 98 | export PATH=$PWD/build/bin/Release:$PATH | 101 | export PATH=$PWD/build/bin/Release:$PATH |
| @@ -155,9 +158,15 @@ jobs: | @@ -155,9 +158,15 @@ jobs: | ||
| 155 | 158 | ||
| 156 | shared_lib=${{ matrix.shared_lib }} | 159 | shared_lib=${{ matrix.shared_lib }} |
| 157 | if [[ $shared_lib == "ON" ]]; then | 160 | if [[ $shared_lib == "ON" ]]; then |
| 158 | - dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-shared | 161 | + suffix=shared |
| 162 | + else | ||
| 163 | + suffix=static | ||
| 164 | + fi | ||
| 165 | + | ||
| 166 | + if [[ ${{ matrix.with_tts }} ]]; then | ||
| 167 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-$suffix | ||
| 159 | else | 168 | else |
| 160 | - dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-static | 169 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-$suffix-no-tts |
| 161 | fi | 170 | fi |
| 162 | 171 | ||
| 163 | mkdir $dst | 172 | mkdir $dst |
| @@ -40,13 +40,14 @@ concurrency: | @@ -40,13 +40,14 @@ concurrency: | ||
| 40 | 40 | ||
| 41 | jobs: | 41 | jobs: |
| 42 | windows_x86: | 42 | windows_x86: |
| 43 | - name: Windows x86 | 43 | + name: shared-${{ matrix.shared_lib }} tts-${{ matrix.with_tts }} |
| 44 | runs-on: ${{ matrix.os }} | 44 | runs-on: ${{ matrix.os }} |
| 45 | strategy: | 45 | strategy: |
| 46 | fail-fast: false | 46 | fail-fast: false |
| 47 | matrix: | 47 | matrix: |
| 48 | os: [windows-latest] | 48 | os: [windows-latest] |
| 49 | shared_lib: [ON, OFF] | 49 | shared_lib: [ON, OFF] |
| 50 | + with_tts: [ON, OFF] | ||
| 50 | 51 | ||
| 51 | steps: | 52 | steps: |
| 52 | - uses: actions/checkout@v4 | 53 | - uses: actions/checkout@v4 |
| @@ -58,7 +59,7 @@ jobs: | @@ -58,7 +59,7 @@ jobs: | ||
| 58 | run: | | 59 | run: | |
| 59 | mkdir build | 60 | mkdir build |
| 60 | cd build | 61 | cd build |
| 61 | - cmake -A Win32 -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install .. | 62 | + 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 .. |
| 62 | 63 | ||
| 63 | - name: Build sherpa-onnx for windows | 64 | - name: Build sherpa-onnx for windows |
| 64 | shell: bash | 65 | shell: bash |
| @@ -94,6 +95,7 @@ jobs: | @@ -94,6 +95,7 @@ jobs: | ||
| 94 | .github/scripts/test-online-ctc.sh | 95 | .github/scripts/test-online-ctc.sh |
| 95 | 96 | ||
| 96 | - name: Test offline TTS | 97 | - name: Test offline TTS |
| 98 | + if: matrix.with_tts == 'ON' | ||
| 97 | shell: bash | 99 | shell: bash |
| 98 | run: | | 100 | run: | |
| 99 | export PATH=$PWD/build/bin/Release:$PATH | 101 | export PATH=$PWD/build/bin/Release:$PATH |
| @@ -157,10 +159,17 @@ jobs: | @@ -157,10 +159,17 @@ jobs: | ||
| 157 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86 | 159 | dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86 |
| 158 | 160 | ||
| 159 | shared_lib=${{ matrix.shared_lib }} | 161 | shared_lib=${{ matrix.shared_lib }} |
| 162 | + | ||
| 160 | if [[ $shared_lib == "ON" ]]; then | 163 | if [[ $shared_lib == "ON" ]]; then |
| 161 | - dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86-shared | 164 | + suffix=shared |
| 165 | + else | ||
| 166 | + suffix=static | ||
| 167 | + fi | ||
| 168 | + | ||
| 169 | + if [[ ${{ matrix.with_tts }} ]]; then | ||
| 170 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86-$suffix | ||
| 162 | else | 171 | else |
| 163 | - dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86-static | 172 | + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86-$suffix-no-tts |
| 164 | fi | 173 | fi |
| 165 | 174 | ||
| 166 | mkdir $dst | 175 | mkdir $dst |
| @@ -26,6 +26,7 @@ option(SHERPA_ONNX_ENABLE_WASM_ASR "Whether to enable WASM for ASR" OFF) | @@ -26,6 +26,7 @@ option(SHERPA_ONNX_ENABLE_WASM_ASR "Whether to enable WASM for ASR" OFF) | ||
| 26 | option(SHERPA_ONNX_ENABLE_WASM_KWS "Whether to enable WASM for KWS" OFF) | 26 | option(SHERPA_ONNX_ENABLE_WASM_KWS "Whether to enable WASM for KWS" OFF) |
| 27 | option(SHERPA_ONNX_ENABLE_WASM_NODEJS "Whether to enable WASM for NodeJS" OFF) | 27 | option(SHERPA_ONNX_ENABLE_WASM_NODEJS "Whether to enable WASM for NodeJS" OFF) |
| 28 | option(SHERPA_ONNX_ENABLE_BINARY "Whether to build binaries" ON) | 28 | option(SHERPA_ONNX_ENABLE_BINARY "Whether to build binaries" ON) |
| 29 | +option(SHERPA_ONNX_ENABLE_TTS "Whether to build TTS related code" ON) | ||
| 29 | option(SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY "True to link libstdc++ statically. Used only when BUILD_SHARED_LIBS is OFF on Linux" ON) | 30 | option(SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY "True to link libstdc++ statically. Used only when BUILD_SHARED_LIBS is OFF on Linux" ON) |
| 30 | option(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE "True to use pre-installed onnxruntime if available" ON) | 31 | option(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE "True to use pre-installed onnxruntime if available" ON) |
| 31 | 32 | ||
| @@ -111,10 +112,26 @@ message(STATUS "SHERPA_ONNX_ENABLE_GPU ${SHERPA_ONNX_ENABLE_GPU}") | @@ -111,10 +112,26 @@ message(STATUS "SHERPA_ONNX_ENABLE_GPU ${SHERPA_ONNX_ENABLE_GPU}") | ||
| 111 | message(STATUS "SHERPA_ONNX_ENABLE_WASM ${SHERPA_ONNX_ENABLE_WASM}") | 112 | message(STATUS "SHERPA_ONNX_ENABLE_WASM ${SHERPA_ONNX_ENABLE_WASM}") |
| 112 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_TTS ${SHERPA_ONNX_ENABLE_WASM_TTS}") | 113 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_TTS ${SHERPA_ONNX_ENABLE_WASM_TTS}") |
| 113 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_ASR ${SHERPA_ONNX_ENABLE_WASM_ASR}") | 114 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_ASR ${SHERPA_ONNX_ENABLE_WASM_ASR}") |
| 115 | +message(STATUS "SHERPA_ONNX_ENABLE_WASM_KWS ${SHERPA_ONNX_ENABLE_WASM_KWS}") | ||
| 114 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_NODEJS ${SHERPA_ONNX_ENABLE_WASM_NODEJS}") | 116 | message(STATUS "SHERPA_ONNX_ENABLE_WASM_NODEJS ${SHERPA_ONNX_ENABLE_WASM_NODEJS}") |
| 117 | +message(STATUS "SHERPA_ONNX_ENABLE_BINARY ${SHERPA_ONNX_ENABLE_BINARY}") | ||
| 118 | +message(STATUS "SHERPA_ONNX_ENABLE_TTS ${SHERPA_ONNX_ENABLE_TTS}") | ||
| 119 | +message(STATUS "SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY ${SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY}") | ||
| 115 | message(STATUS "SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE ${SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE}") | 120 | message(STATUS "SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE ${SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE}") |
| 116 | 121 | ||
| 122 | +if(SHERPA_ONNX_ENABLE_TTS) | ||
| 123 | + message(STATUS "TTS is enabled") | ||
| 124 | + add_definitions(-DSHERPA_ONNX_ENABLE_TTS=1) | ||
| 125 | +else() | ||
| 126 | + message(WARNING "TTS is disabled") | ||
| 127 | + add_definitions(-DSHERPA_ONNX_ENABLE_TTS=0) | ||
| 128 | +endif() | ||
| 129 | + | ||
| 117 | if(SHERPA_ONNX_ENABLE_WASM_TTS) | 130 | if(SHERPA_ONNX_ENABLE_WASM_TTS) |
| 131 | + if(NOT SHERPA_ONNX_ENABLE_TTS) | ||
| 132 | + message(FATAL_ERROR "Please set SHERPA_ONNX_ENABLE_TTS to ON if you want to build wasm TTS") | ||
| 133 | + endif() | ||
| 134 | + | ||
| 118 | if(NOT SHERPA_ONNX_ENABLE_WASM) | 135 | if(NOT SHERPA_ONNX_ENABLE_WASM) |
| 119 | message(FATAL_ERROR "Please set SHERPA_ONNX_ENABLE_WASM to ON if you enable WASM for TTS") | 136 | message(FATAL_ERROR "Please set SHERPA_ONNX_ENABLE_WASM to ON if you enable WASM for TTS") |
| 120 | endif() | 137 | endif() |
| @@ -238,10 +255,12 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET) | @@ -238,10 +255,12 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET) | ||
| 238 | include(asio) | 255 | include(asio) |
| 239 | endif() | 256 | endif() |
| 240 | 257 | ||
| 241 | -include(espeak-ng-for-piper) | ||
| 242 | -set(ESPEAK_NG_DIR ${espeak_ng_SOURCE_DIR}) | ||
| 243 | -message(STATUS "ESPEAK_NG_DIR: ${ESPEAK_NG_DIR}") | ||
| 244 | -include(piper-phonemize) | 258 | +if(SHERPA_ONNX_ENABLE_TTS) |
| 259 | + include(espeak-ng-for-piper) | ||
| 260 | + set(ESPEAK_NG_DIR ${espeak_ng_SOURCE_DIR}) | ||
| 261 | + message(STATUS "ESPEAK_NG_DIR: ${ESPEAK_NG_DIR}") | ||
| 262 | + include(piper-phonemize) | ||
| 263 | +endif() | ||
| 245 | 264 | ||
| 246 | add_subdirectory(sherpa-onnx) | 265 | add_subdirectory(sherpa-onnx) |
| 247 | 266 | ||
| @@ -266,7 +285,12 @@ if(NOT BUILD_SHARED_LIBS) | @@ -266,7 +285,12 @@ if(NOT BUILD_SHARED_LIBS) | ||
| 266 | endif() | 285 | endif() |
| 267 | 286 | ||
| 268 | # See https://people.freedesktop.org/~dbn/pkg-config-guide.html | 287 | # See https://people.freedesktop.org/~dbn/pkg-config-guide.html |
| 269 | -configure_file(cmake/sherpa-onnx.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY) | 288 | +if(SHERPA_ONNX_ENABLE_TTS) |
| 289 | + configure_file(cmake/sherpa-onnx.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY) | ||
| 290 | +else() | ||
| 291 | + configure_file(cmake/sherpa-onnx-no-tts.pc.in ${PROJECT_BINARY_DIR}/sherpa-onnx.pc @ONLY) | ||
| 292 | +endif() | ||
| 293 | + | ||
| 270 | install( | 294 | install( |
| 271 | FILES | 295 | FILES |
| 272 | ${PROJECT_BINARY_DIR}/sherpa-onnx.pc | 296 | ${PROJECT_BINARY_DIR}/sherpa-onnx.pc |
build-ios-no-tts.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -e | ||
| 4 | + | ||
| 5 | +dir=build-ios-no-tts | ||
| 6 | +mkdir -p $dir | ||
| 7 | +cd $dir | ||
| 8 | +onnxruntime_version=1.17.1 | ||
| 9 | +onnxruntime_dir=ios-onnxruntime/$onnxruntime_version | ||
| 10 | + | ||
| 11 | +if [ ! -f $onnxruntime_dir/onnxruntime.xcframework/ios-arm64/onnxruntime.a ]; then | ||
| 12 | + mkdir -p $onnxruntime_dir | ||
| 13 | + pushd $onnxruntime_dir | ||
| 14 | + wget https://github.com/csukuangfj/onnxruntime-libs/releases/download/v${onnxruntime_version}/onnxruntime.xcframework-${onnxruntime_version}.tar.bz2 | ||
| 15 | + tar xvf onnxruntime.xcframework-${onnxruntime_version}.tar.bz2 | ||
| 16 | + rm onnxruntime.xcframework-${onnxruntime_version}.tar.bz2 | ||
| 17 | + cd .. | ||
| 18 | + ln -sf $onnxruntime_version/onnxruntime.xcframework . | ||
| 19 | + popd | ||
| 20 | +fi | ||
| 21 | + | ||
| 22 | +# First, for simulator | ||
| 23 | +echo "Building for simulator (x86_64)" | ||
| 24 | + | ||
| 25 | +export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator | ||
| 26 | +export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/Headers | ||
| 27 | + | ||
| 28 | +echo "SHERPA_ONNXRUNTIME_LIB_DIR: $SHERPA_ONNXRUNTIME_LIB_DIR" | ||
| 29 | +echo "SHERPA_ONNXRUNTIME_INCLUDE_DIR $SHERPA_ONNXRUNTIME_INCLUDE_DIR" | ||
| 30 | + | ||
| 31 | +# Note: We use -DENABLE_ARC=1 here to fix the linking error: | ||
| 32 | +# | ||
| 33 | +# The symbol _NSLog is not defined | ||
| 34 | +# | ||
| 35 | + | ||
| 36 | +cmake \ | ||
| 37 | + -DSHERPA_ONNX_ENABLE_TTS=OFF \ | ||
| 38 | + -DBUILD_PIPER_PHONMIZE_EXE=OFF \ | ||
| 39 | + -DBUILD_PIPER_PHONMIZE_TESTS=OFF \ | ||
| 40 | + -DBUILD_ESPEAK_NG_EXE=OFF \ | ||
| 41 | + -DBUILD_ESPEAK_NG_TESTS=OFF \ | ||
| 42 | + -S .. \ | ||
| 43 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 44 | + -DPLATFORM=SIMULATOR64 \ | ||
| 45 | + -DENABLE_BITCODE=0 \ | ||
| 46 | + -DENABLE_ARC=1 \ | ||
| 47 | + -DENABLE_VISIBILITY=0 \ | ||
| 48 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 49 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 50 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 51 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 52 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 53 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 54 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 55 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 56 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 57 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 58 | + -B build/simulator_x86_64 | ||
| 59 | + | ||
| 60 | +cmake --build build/simulator_x86_64 -j 4 --verbose | ||
| 61 | + | ||
| 62 | +echo "Building for simulator (arm64)" | ||
| 63 | + | ||
| 64 | +cmake \ | ||
| 65 | + -DSHERPA_ONNX_ENABLE_TTS=OFF \ | ||
| 66 | + -DBUILD_PIPER_PHONMIZE_EXE=OFF \ | ||
| 67 | + -DBUILD_PIPER_PHONMIZE_TESTS=OFF \ | ||
| 68 | + -DBUILD_ESPEAK_NG_EXE=OFF \ | ||
| 69 | + -DBUILD_ESPEAK_NG_TESTS=OFF \ | ||
| 70 | + -S .. \ | ||
| 71 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 72 | + -DPLATFORM=SIMULATORARM64 \ | ||
| 73 | + -DENABLE_BITCODE=0 \ | ||
| 74 | + -DENABLE_ARC=1 \ | ||
| 75 | + -DENABLE_VISIBILITY=0 \ | ||
| 76 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 77 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 78 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 79 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 80 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 81 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 82 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 83 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 84 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 85 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 86 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 87 | + -B build/simulator_arm64 | ||
| 88 | + | ||
| 89 | +cmake --build build/simulator_arm64 -j 4 --verbose | ||
| 90 | + | ||
| 91 | +echo "Building for arm64" | ||
| 92 | + | ||
| 93 | +export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64 | ||
| 94 | + | ||
| 95 | + | ||
| 96 | +cmake \ | ||
| 97 | + -DSHERPA_ONNX_ENABLE_TTS=OFF \ | ||
| 98 | + -DBUILD_PIPER_PHONMIZE_EXE=OFF \ | ||
| 99 | + -DBUILD_PIPER_PHONMIZE_TESTS=OFF \ | ||
| 100 | + -DBUILD_ESPEAK_NG_EXE=OFF \ | ||
| 101 | + -DBUILD_ESPEAK_NG_TESTS=OFF \ | ||
| 102 | + -S .. \ | ||
| 103 | + -DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \ | ||
| 104 | + -DPLATFORM=OS64 \ | ||
| 105 | + -DENABLE_BITCODE=0 \ | ||
| 106 | + -DENABLE_ARC=1 \ | ||
| 107 | + -DENABLE_VISIBILITY=0 \ | ||
| 108 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 109 | + -DCMAKE_BUILD_TYPE=Release \ | ||
| 110 | + -DBUILD_SHARED_LIBS=OFF \ | ||
| 111 | + -DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
| 112 | + -DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
| 113 | + -DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
| 114 | + -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 115 | + -DSHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 116 | + -DSHERPA_ONNX_ENABLE_C_API=ON \ | ||
| 117 | + -DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \ | ||
| 118 | + -DDEPLOYMENT_TARGET=13.0 \ | ||
| 119 | + -B build/os64 | ||
| 120 | + | ||
| 121 | +cmake --build build/os64 -j 4 | ||
| 122 | +# Generate headers for sherpa-onnx.xcframework | ||
| 123 | +cmake --build build/os64 --target install | ||
| 124 | + | ||
| 125 | +echo "Generate xcframework" | ||
| 126 | + | ||
| 127 | +mkdir -p "build/simulator/lib" | ||
| 128 | +for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a \ | ||
| 129 | + libsherpa-onnx-fst.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a; do | ||
| 130 | + lipo -create build/simulator_arm64/lib/${f} \ | ||
| 131 | + build/simulator_x86_64/lib/${f} \ | ||
| 132 | + -output build/simulator/lib/${f} | ||
| 133 | +done | ||
| 134 | + | ||
| 135 | +# Merge archive first, because the following xcodebuild create xcframework | ||
| 136 | +# cannot accept multi archive with the same architecture. | ||
| 137 | +libtool -static -o build/simulator/sherpa-onnx.a \ | ||
| 138 | + build/simulator/lib/libkaldi-native-fbank-core.a \ | ||
| 139 | + build/simulator/lib/libsherpa-onnx-c-api.a \ | ||
| 140 | + build/simulator/lib/libsherpa-onnx-core.a \ | ||
| 141 | + build/simulator/lib/libsherpa-onnx-fst.a \ | ||
| 142 | + build/simulator/lib/libsherpa-onnx-kaldifst-core.a \ | ||
| 143 | + build/simulator/lib/libkaldi-decoder-core.a | ||
| 144 | + | ||
| 145 | +libtool -static -o build/os64/sherpa-onnx.a \ | ||
| 146 | + build/os64/lib/libkaldi-native-fbank-core.a \ | ||
| 147 | + build/os64/lib/libsherpa-onnx-c-api.a \ | ||
| 148 | + build/os64/lib/libsherpa-onnx-core.a \ | ||
| 149 | + build/os64/lib/libsherpa-onnx-fst.a \ | ||
| 150 | + build/os64/lib/libsherpa-onnx-kaldifst-core.a \ | ||
| 151 | + build/os64/lib/libkaldi-decoder-core.a | ||
| 152 | + | ||
| 153 | +rm -rf sherpa-onnx.xcframework | ||
| 154 | + | ||
| 155 | +xcodebuild -create-xcframework \ | ||
| 156 | + -library "build/os64/sherpa-onnx.a" \ | ||
| 157 | + -library "build/simulator/sherpa-onnx.a" \ | ||
| 158 | + -output sherpa-onnx.xcframework | ||
| 159 | + | ||
| 160 | +# Copy Headers | ||
| 161 | +mkdir -p sherpa-onnx.xcframework/Headers | ||
| 162 | +cp -av install/include/* sherpa-onnx.xcframework/Headers | ||
| 163 | + | ||
| 164 | +pushd sherpa-onnx.xcframework/ios-arm64_x86_64-simulator | ||
| 165 | +ln -s sherpa-onnx.a libsherpa-onnx.a | ||
| 166 | +popd | ||
| 167 | + | ||
| 168 | +pushd sherpa-onnx.xcframework/ios-arm64 | ||
| 169 | +ln -s sherpa-onnx.a libsherpa-onnx.a |
| @@ -4,8 +4,10 @@ include_directories(${CMAKE_SOURCE_DIR}) | @@ -4,8 +4,10 @@ include_directories(${CMAKE_SOURCE_DIR}) | ||
| 4 | add_executable(decode-file-c-api decode-file-c-api.c) | 4 | add_executable(decode-file-c-api decode-file-c-api.c) |
| 5 | target_link_libraries(decode-file-c-api sherpa-onnx-c-api cargs) | 5 | target_link_libraries(decode-file-c-api sherpa-onnx-c-api cargs) |
| 6 | 6 | ||
| 7 | -add_executable(offline-tts-c-api offline-tts-c-api.c) | ||
| 8 | -target_link_libraries(offline-tts-c-api sherpa-onnx-c-api cargs) | 7 | +if(SHERPA_ONNX_ENABLE_TTS) |
| 8 | + add_executable(offline-tts-c-api offline-tts-c-api.c) | ||
| 9 | + target_link_libraries(offline-tts-c-api sherpa-onnx-c-api cargs) | ||
| 10 | +endif() | ||
| 9 | 11 | ||
| 10 | add_executable(spoken-language-identification-c-api spoken-language-identification-c-api.c) | 12 | add_executable(spoken-language-identification-c-api spoken-language-identification-c-api.c) |
| 11 | target_link_libraries(spoken-language-identification-c-api sherpa-onnx-c-api) | 13 | target_link_libraries(spoken-language-identification-c-api sherpa-onnx-c-api) |
cmake/sherpa-onnx-no-tts.pc.in
0 → 100644
| 1 | +prefix="@CMAKE_INSTALL_PREFIX@" | ||
| 2 | +exec_prefix="${prefix}" | ||
| 3 | +includedir="${prefix}/include" | ||
| 4 | +libdir="${exec_prefix}/lib" | ||
| 5 | + | ||
| 6 | +Name: sherpa-onnx | ||
| 7 | +Description: pkg-config for sherpa-onnx with TTS support | ||
| 8 | +URL: https://github.com/k2-fsa/sherpa-onnx | ||
| 9 | + | ||
| 10 | +Version: @SHERPA_ONNX_VERSION@ | ||
| 11 | +Cflags: -I"${includedir}" | ||
| 12 | + | ||
| 13 | +# Note: -lcargs is required only for the following file | ||
| 14 | +# https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c | ||
| 15 | +# We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c | ||
| 16 | +Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fst -lkaldi-native-fbank-core -lcargs -lonnxruntime -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@ |
| @@ -15,13 +15,16 @@ | @@ -15,13 +15,16 @@ | ||
| 15 | #include "sherpa-onnx/csrc/keyword-spotter.h" | 15 | #include "sherpa-onnx/csrc/keyword-spotter.h" |
| 16 | #include "sherpa-onnx/csrc/macros.h" | 16 | #include "sherpa-onnx/csrc/macros.h" |
| 17 | #include "sherpa-onnx/csrc/offline-recognizer.h" | 17 | #include "sherpa-onnx/csrc/offline-recognizer.h" |
| 18 | -#include "sherpa-onnx/csrc/offline-tts.h" | ||
| 19 | #include "sherpa-onnx/csrc/online-recognizer.h" | 18 | #include "sherpa-onnx/csrc/online-recognizer.h" |
| 20 | #include "sherpa-onnx/csrc/spoken-language-identification.h" | 19 | #include "sherpa-onnx/csrc/spoken-language-identification.h" |
| 21 | #include "sherpa-onnx/csrc/voice-activity-detector.h" | 20 | #include "sherpa-onnx/csrc/voice-activity-detector.h" |
| 22 | #include "sherpa-onnx/csrc/wave-reader.h" | 21 | #include "sherpa-onnx/csrc/wave-reader.h" |
| 23 | #include "sherpa-onnx/csrc/wave-writer.h" | 22 | #include "sherpa-onnx/csrc/wave-writer.h" |
| 24 | 23 | ||
| 24 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 25 | +#include "sherpa-onnx/csrc/offline-tts.h" | ||
| 26 | +#endif | ||
| 27 | + | ||
| 25 | struct SherpaOnnxOnlineRecognizer { | 28 | struct SherpaOnnxOnlineRecognizer { |
| 26 | std::unique_ptr<sherpa_onnx::OnlineRecognizer> impl; | 29 | std::unique_ptr<sherpa_onnx::OnlineRecognizer> impl; |
| 27 | }; | 30 | }; |
| @@ -742,6 +745,7 @@ void SherpaOnnxVoiceActivityDetectorReset(SherpaOnnxVoiceActivityDetector *p) { | @@ -742,6 +745,7 @@ void SherpaOnnxVoiceActivityDetectorReset(SherpaOnnxVoiceActivityDetector *p) { | ||
| 742 | p->impl->Reset(); | 745 | p->impl->Reset(); |
| 743 | } | 746 | } |
| 744 | 747 | ||
| 748 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 745 | struct SherpaOnnxOfflineTts { | 749 | struct SherpaOnnxOfflineTts { |
| 746 | std::unique_ptr<sherpa_onnx::OfflineTts> impl; | 750 | std::unique_ptr<sherpa_onnx::OfflineTts> impl; |
| 747 | }; | 751 | }; |
| @@ -857,6 +861,7 @@ void SherpaOnnxDestroyOfflineTtsGeneratedAudio( | @@ -857,6 +861,7 @@ void SherpaOnnxDestroyOfflineTtsGeneratedAudio( | ||
| 857 | delete p; | 861 | delete p; |
| 858 | } | 862 | } |
| 859 | } | 863 | } |
| 864 | +#endif // SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 860 | 865 | ||
| 861 | int32_t SherpaOnnxWriteWave(const float *samples, int32_t n, | 866 | int32_t SherpaOnnxWriteWave(const float *samples, int32_t n, |
| 862 | int32_t sample_rate, const char *filename) { | 867 | int32_t sample_rate, const char *filename) { |
| @@ -43,7 +43,6 @@ set(sources | @@ -43,7 +43,6 @@ set(sources | ||
| 43 | offline-transducer-model-config.cc | 43 | offline-transducer-model-config.cc |
| 44 | offline-transducer-model.cc | 44 | offline-transducer-model.cc |
| 45 | offline-transducer-modified-beam-search-decoder.cc | 45 | offline-transducer-modified-beam-search-decoder.cc |
| 46 | - offline-tts-character-frontend.cc | ||
| 47 | offline-wenet-ctc-model-config.cc | 46 | offline-wenet-ctc-model-config.cc |
| 48 | offline-wenet-ctc-model.cc | 47 | offline-wenet-ctc-model.cc |
| 49 | offline-whisper-greedy-search-decoder.cc | 48 | offline-whisper-greedy-search-decoder.cc |
| @@ -79,7 +78,6 @@ set(sources | @@ -79,7 +78,6 @@ set(sources | ||
| 79 | packed-sequence.cc | 78 | packed-sequence.cc |
| 80 | pad-sequence.cc | 79 | pad-sequence.cc |
| 81 | parse-options.cc | 80 | parse-options.cc |
| 82 | - piper-phonemize-lexicon.cc | ||
| 83 | provider.cc | 81 | provider.cc |
| 84 | resample.cc | 82 | resample.cc |
| 85 | session.cc | 83 | session.cc |
| @@ -99,6 +97,7 @@ set(sources | @@ -99,6 +97,7 @@ set(sources | ||
| 99 | vad-model.cc | 97 | vad-model.cc |
| 100 | voice-activity-detector.cc | 98 | voice-activity-detector.cc |
| 101 | wave-reader.cc | 99 | wave-reader.cc |
| 100 | + wave-writer.cc | ||
| 102 | ) | 101 | ) |
| 103 | 102 | ||
| 104 | # speaker embedding extractor | 103 | # speaker embedding extractor |
| @@ -110,15 +109,18 @@ list(APPEND sources | @@ -110,15 +109,18 @@ list(APPEND sources | ||
| 110 | speaker-embedding-manager.cc | 109 | speaker-embedding-manager.cc |
| 111 | ) | 110 | ) |
| 112 | 111 | ||
| 113 | -list(APPEND sources | 112 | +if(SHERPA_ONNX_ENABLE_TTS) |
| 113 | + list(APPEND sources | ||
| 114 | lexicon.cc | 114 | lexicon.cc |
| 115 | + offline-tts-character-frontend.cc | ||
| 115 | offline-tts-impl.cc | 116 | offline-tts-impl.cc |
| 116 | offline-tts-model-config.cc | 117 | offline-tts-model-config.cc |
| 117 | offline-tts-vits-model-config.cc | 118 | offline-tts-vits-model-config.cc |
| 118 | offline-tts-vits-model.cc | 119 | offline-tts-vits-model.cc |
| 119 | offline-tts.cc | 120 | offline-tts.cc |
| 120 | - wave-writer.cc | ||
| 121 | -) | 121 | + piper-phonemize-lexicon.cc |
| 122 | + ) | ||
| 123 | +endif() | ||
| 122 | 124 | ||
| 123 | if(SHERPA_ONNX_ENABLE_CHECK) | 125 | if(SHERPA_ONNX_ENABLE_CHECK) |
| 124 | list(APPEND sources log.cc) | 126 | list(APPEND sources log.cc) |
| @@ -130,14 +132,21 @@ if(APPLE) | @@ -130,14 +132,21 @@ if(APPLE) | ||
| 130 | ) | 132 | ) |
| 131 | endif() | 133 | endif() |
| 132 | 134 | ||
| 133 | - | ||
| 134 | if(ANDROID_NDK) | 135 | if(ANDROID_NDK) |
| 135 | target_link_libraries(sherpa-onnx-core android log) | 136 | target_link_libraries(sherpa-onnx-core android log) |
| 136 | endif() | 137 | endif() |
| 137 | 138 | ||
| 138 | -target_link_libraries(sherpa-onnx-core kaldi-native-fbank-core) | 139 | +target_link_libraries(sherpa-onnx-core |
| 140 | + kaldi-native-fbank-core | ||
| 141 | + kaldi-decoder-core | ||
| 142 | +) | ||
| 139 | 143 | ||
| 140 | -target_link_libraries(sherpa-onnx-core kaldi-decoder-core) | 144 | +if(SHERPA_ONNX_ENABLE_GPU) |
| 145 | + target_link_libraries(sherpa-onnx-core | ||
| 146 | + onnxruntime_providers_cuda | ||
| 147 | + onnxruntime_providers_shared | ||
| 148 | + ) | ||
| 149 | +endif() | ||
| 141 | 150 | ||
| 142 | if(BUILD_SHARED_LIBS) | 151 | if(BUILD_SHARED_LIBS) |
| 143 | target_link_libraries(sherpa-onnx-core onnxruntime) | 152 | target_link_libraries(sherpa-onnx-core onnxruntime) |
| @@ -151,15 +160,10 @@ if(NOT BUILD_SHARED_LIBS AND APPLE) | @@ -151,15 +160,10 @@ if(NOT BUILD_SHARED_LIBS AND APPLE) | ||
| 151 | target_link_libraries(sherpa-onnx-core "-framework Foundation") | 160 | target_link_libraries(sherpa-onnx-core "-framework Foundation") |
| 152 | endif() | 161 | endif() |
| 153 | 162 | ||
| 154 | -if(SHERPA_ONNX_ENABLE_GPU) | ||
| 155 | - target_link_libraries(sherpa-onnx-core | ||
| 156 | - onnxruntime_providers_cuda | ||
| 157 | - onnxruntime_providers_shared | ||
| 158 | - ) | 163 | +if(SHERPA_ONNX_ENABLE_TTS) |
| 164 | + target_link_libraries(sherpa-onnx-core piper_phonemize) | ||
| 159 | endif() | 165 | endif() |
| 160 | 166 | ||
| 161 | -target_link_libraries(sherpa-onnx-core piper_phonemize) | ||
| 162 | - | ||
| 163 | if(SHERPA_ONNX_ENABLE_CHECK) | 167 | if(SHERPA_ONNX_ENABLE_CHECK) |
| 164 | target_compile_definitions(sherpa-onnx-core PUBLIC SHERPA_ONNX_ENABLE_CHECK=1) | 168 | target_compile_definitions(sherpa-onnx-core PUBLIC SHERPA_ONNX_ENABLE_CHECK=1) |
| 165 | 169 | ||
| @@ -185,17 +189,24 @@ if(SHERPA_ONNX_ENABLE_BINARY) | @@ -185,17 +189,24 @@ if(SHERPA_ONNX_ENABLE_BINARY) | ||
| 185 | add_executable(sherpa-onnx-keyword-spotter sherpa-onnx-keyword-spotter.cc) | 189 | add_executable(sherpa-onnx-keyword-spotter sherpa-onnx-keyword-spotter.cc) |
| 186 | add_executable(sherpa-onnx-offline sherpa-onnx-offline.cc) | 190 | add_executable(sherpa-onnx-offline sherpa-onnx-offline.cc) |
| 187 | add_executable(sherpa-onnx-offline-parallel sherpa-onnx-offline-parallel.cc) | 191 | add_executable(sherpa-onnx-offline-parallel sherpa-onnx-offline-parallel.cc) |
| 188 | - add_executable(sherpa-onnx-offline-tts sherpa-onnx-offline-tts.cc) | ||
| 189 | add_executable(sherpa-onnx-offline-language-identification sherpa-onnx-offline-language-identification.cc) | 192 | add_executable(sherpa-onnx-offline-language-identification sherpa-onnx-offline-language-identification.cc) |
| 190 | 193 | ||
| 194 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 195 | + add_executable(sherpa-onnx-offline-tts sherpa-onnx-offline-tts.cc) | ||
| 196 | + endif() | ||
| 197 | + | ||
| 191 | set(main_exes | 198 | set(main_exes |
| 192 | sherpa-onnx | 199 | sherpa-onnx |
| 193 | sherpa-onnx-keyword-spotter | 200 | sherpa-onnx-keyword-spotter |
| 194 | sherpa-onnx-offline | 201 | sherpa-onnx-offline |
| 195 | sherpa-onnx-offline-parallel | 202 | sherpa-onnx-offline-parallel |
| 196 | - sherpa-onnx-offline-tts | ||
| 197 | sherpa-onnx-offline-language-identification | 203 | sherpa-onnx-offline-language-identification |
| 198 | ) | 204 | ) |
| 205 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 206 | + list(APPEND main_exes | ||
| 207 | + sherpa-onnx-offline-tts | ||
| 208 | + ) | ||
| 209 | + endif() | ||
| 199 | 210 | ||
| 200 | foreach(exe IN LISTS main_exes) | 211 | foreach(exe IN LISTS main_exes) |
| 201 | target_link_libraries(${exe} sherpa-onnx-core) | 212 | target_link_libraries(${exe} sherpa-onnx-core) |
| @@ -235,17 +246,27 @@ endif() | @@ -235,17 +246,27 @@ endif() | ||
| 235 | if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) | 246 | if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) |
| 236 | add_executable(sherpa-onnx-alsa sherpa-onnx-alsa.cc alsa.cc) | 247 | add_executable(sherpa-onnx-alsa sherpa-onnx-alsa.cc alsa.cc) |
| 237 | add_executable(sherpa-onnx-keyword-spotter-alsa sherpa-onnx-keyword-spotter-alsa.cc alsa.cc) | 248 | add_executable(sherpa-onnx-keyword-spotter-alsa sherpa-onnx-keyword-spotter-alsa.cc alsa.cc) |
| 238 | - add_executable(sherpa-onnx-offline-tts-play-alsa sherpa-onnx-offline-tts-play-alsa.cc alsa-play.cc) | ||
| 239 | add_executable(sherpa-onnx-alsa-offline sherpa-onnx-alsa-offline.cc alsa.cc) | 249 | add_executable(sherpa-onnx-alsa-offline sherpa-onnx-alsa-offline.cc alsa.cc) |
| 240 | add_executable(sherpa-onnx-alsa-offline-speaker-identification sherpa-onnx-alsa-offline-speaker-identification.cc alsa.cc) | 250 | add_executable(sherpa-onnx-alsa-offline-speaker-identification sherpa-onnx-alsa-offline-speaker-identification.cc alsa.cc) |
| 241 | 251 | ||
| 252 | + | ||
| 253 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 254 | + add_executable(sherpa-onnx-offline-tts-play-alsa sherpa-onnx-offline-tts-play-alsa.cc alsa-play.cc) | ||
| 255 | + endif() | ||
| 256 | + | ||
| 242 | set(exes | 257 | set(exes |
| 243 | sherpa-onnx-alsa | 258 | sherpa-onnx-alsa |
| 244 | sherpa-onnx-keyword-spotter-alsa | 259 | sherpa-onnx-keyword-spotter-alsa |
| 245 | sherpa-onnx-alsa-offline | 260 | sherpa-onnx-alsa-offline |
| 246 | - sherpa-onnx-offline-tts-play-alsa | ||
| 247 | sherpa-onnx-alsa-offline-speaker-identification | 261 | sherpa-onnx-alsa-offline-speaker-identification |
| 248 | ) | 262 | ) |
| 263 | + | ||
| 264 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 265 | + list(APPEND exes | ||
| 266 | + sherpa-onnx-offline-tts-play-alsa | ||
| 267 | + ) | ||
| 268 | + endif() | ||
| 269 | + | ||
| 249 | foreach(exe IN LISTS exes) | 270 | foreach(exe IN LISTS exes) |
| 250 | target_link_libraries(${exe} sherpa-onnx-core) | 271 | target_link_libraries(${exe} sherpa-onnx-core) |
| 251 | endforeach() | 272 | endforeach() |
| @@ -279,10 +300,12 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) | @@ -279,10 +300,12 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY) | ||
| 279 | endif() | 300 | endif() |
| 280 | 301 | ||
| 281 | if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) | 302 | if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) |
| 303 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 282 | add_executable(sherpa-onnx-offline-tts-play | 304 | add_executable(sherpa-onnx-offline-tts-play |
| 283 | sherpa-onnx-offline-tts-play.cc | 305 | sherpa-onnx-offline-tts-play.cc |
| 284 | microphone.cc | 306 | microphone.cc |
| 285 | ) | 307 | ) |
| 308 | + endif() | ||
| 286 | 309 | ||
| 287 | add_executable(sherpa-onnx-keyword-spotter-microphone | 310 | add_executable(sherpa-onnx-keyword-spotter-microphone |
| 288 | sherpa-onnx-keyword-spotter-microphone.cc | 311 | sherpa-onnx-keyword-spotter-microphone.cc |
| @@ -325,10 +348,15 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) | @@ -325,10 +348,15 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY) | ||
| 325 | sherpa-onnx-keyword-spotter-microphone | 348 | sherpa-onnx-keyword-spotter-microphone |
| 326 | sherpa-onnx-microphone-offline | 349 | sherpa-onnx-microphone-offline |
| 327 | sherpa-onnx-microphone-offline-speaker-identification | 350 | sherpa-onnx-microphone-offline-speaker-identification |
| 328 | - sherpa-onnx-offline-tts-play | ||
| 329 | sherpa-onnx-vad-microphone | 351 | sherpa-onnx-vad-microphone |
| 330 | sherpa-onnx-vad-microphone-offline-asr | 352 | sherpa-onnx-vad-microphone-offline-asr |
| 331 | ) | 353 | ) |
| 354 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 355 | + list(APPEND exes | ||
| 356 | + sherpa-onnx-offline-tts-play | ||
| 357 | + ) | ||
| 358 | + endif() | ||
| 359 | + | ||
| 332 | foreach(exe IN LISTS exes) | 360 | foreach(exe IN LISTS exes) |
| 333 | target_link_libraries(${exe} ${PA_LIB} sherpa-onnx-core) | 361 | target_link_libraries(${exe} ${PA_LIB} sherpa-onnx-core) |
| 334 | endforeach() | 362 | endforeach() |
| @@ -369,10 +397,8 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) | @@ -369,10 +397,8 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) | ||
| 369 | target_link_libraries(sherpa-onnx-online-websocket-client sherpa-onnx-core) | 397 | target_link_libraries(sherpa-onnx-online-websocket-client sherpa-onnx-core) |
| 370 | 398 | ||
| 371 | if(NOT WIN32) | 399 | if(NOT WIN32) |
| 372 | - target_link_libraries(sherpa-onnx-online-websocket-server -pthread) | ||
| 373 | target_compile_options(sherpa-onnx-online-websocket-server PRIVATE -Wno-deprecated-declarations) | 400 | target_compile_options(sherpa-onnx-online-websocket-server PRIVATE -Wno-deprecated-declarations) |
| 374 | 401 | ||
| 375 | - target_link_libraries(sherpa-onnx-online-websocket-client -pthread) | ||
| 376 | target_compile_options(sherpa-onnx-online-websocket-client PRIVATE -Wno-deprecated-declarations) | 402 | target_compile_options(sherpa-onnx-online-websocket-client PRIVATE -Wno-deprecated-declarations) |
| 377 | endif() | 403 | endif() |
| 378 | 404 | ||
| @@ -384,7 +410,6 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) | @@ -384,7 +410,6 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY) | ||
| 384 | target_link_libraries(sherpa-onnx-offline-websocket-server sherpa-onnx-core) | 410 | target_link_libraries(sherpa-onnx-offline-websocket-server sherpa-onnx-core) |
| 385 | 411 | ||
| 386 | if(NOT WIN32) | 412 | if(NOT WIN32) |
| 387 | - target_link_libraries(sherpa-onnx-offline-websocket-server -pthread) | ||
| 388 | target_compile_options(sherpa-onnx-offline-websocket-server PRIVATE -Wno-deprecated-declarations) | 413 | target_compile_options(sherpa-onnx-offline-websocket-server PRIVATE -Wno-deprecated-declarations) |
| 389 | endif() | 414 | endif() |
| 390 | 415 | ||
| @@ -422,13 +447,17 @@ if(SHERPA_ONNX_ENABLE_TESTS) | @@ -422,13 +447,17 @@ if(SHERPA_ONNX_ENABLE_TESTS) | ||
| 422 | context-graph-test.cc | 447 | context-graph-test.cc |
| 423 | packed-sequence-test.cc | 448 | packed-sequence-test.cc |
| 424 | pad-sequence-test.cc | 449 | pad-sequence-test.cc |
| 425 | - piper-phonemize-test.cc | ||
| 426 | slice-test.cc | 450 | slice-test.cc |
| 427 | stack-test.cc | 451 | stack-test.cc |
| 428 | transpose-test.cc | 452 | transpose-test.cc |
| 429 | unbind-test.cc | 453 | unbind-test.cc |
| 430 | utfcpp-test.cc | 454 | utfcpp-test.cc |
| 431 | ) | 455 | ) |
| 456 | + if(SHERPA_ONNX_ENABLE_TTS) | ||
| 457 | + list(APPEND sherpa_onnx_test_srcs | ||
| 458 | + piper-phonemize-test.cc | ||
| 459 | + ) | ||
| 460 | + endif() | ||
| 432 | 461 | ||
| 433 | list(APPEND sherpa_onnx_test_srcs | 462 | list(APPEND sherpa_onnx_test_srcs |
| 434 | speaker-embedding-manager-test.cc | 463 | speaker-embedding-manager-test.cc |
| @@ -24,7 +24,6 @@ | @@ -24,7 +24,6 @@ | ||
| 24 | #include "sherpa-onnx/csrc/keyword-spotter.h" | 24 | #include "sherpa-onnx/csrc/keyword-spotter.h" |
| 25 | #include "sherpa-onnx/csrc/macros.h" | 25 | #include "sherpa-onnx/csrc/macros.h" |
| 26 | #include "sherpa-onnx/csrc/offline-recognizer.h" | 26 | #include "sherpa-onnx/csrc/offline-recognizer.h" |
| 27 | -#include "sherpa-onnx/csrc/offline-tts.h" | ||
| 28 | #include "sherpa-onnx/csrc/online-recognizer.h" | 27 | #include "sherpa-onnx/csrc/online-recognizer.h" |
| 29 | #include "sherpa-onnx/csrc/onnx-utils.h" | 28 | #include "sherpa-onnx/csrc/onnx-utils.h" |
| 30 | #include "sherpa-onnx/csrc/speaker-embedding-extractor.h" | 29 | #include "sherpa-onnx/csrc/speaker-embedding-extractor.h" |
| @@ -33,6 +32,10 @@ | @@ -33,6 +32,10 @@ | ||
| 33 | #include "sherpa-onnx/csrc/wave-reader.h" | 32 | #include "sherpa-onnx/csrc/wave-reader.h" |
| 34 | #include "sherpa-onnx/csrc/wave-writer.h" | 33 | #include "sherpa-onnx/csrc/wave-writer.h" |
| 35 | 34 | ||
| 35 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 36 | +#include "sherpa-onnx/csrc/offline-tts.h" | ||
| 37 | +#endif | ||
| 38 | + | ||
| 36 | #define SHERPA_ONNX_EXTERN_C extern "C" | 39 | #define SHERPA_ONNX_EXTERN_C extern "C" |
| 37 | 40 | ||
| 38 | namespace sherpa_onnx { | 41 | namespace sherpa_onnx { |
| @@ -629,8 +632,8 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) { | @@ -629,8 +632,8 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) { | ||
| 629 | env->ReleaseStringUTFChars(s, p); | 632 | env->ReleaseStringUTFChars(s, p); |
| 630 | 633 | ||
| 631 | fid = env->GetFieldID(whisper_config_cls, "tailPaddings", "I"); | 634 | fid = env->GetFieldID(whisper_config_cls, "tailPaddings", "I"); |
| 632 | - ans.model_config.whisper.tail_paddings = env->GetIntField(whisper_config, | ||
| 633 | - fid); | 635 | + ans.model_config.whisper.tail_paddings = |
| 636 | + env->GetIntField(whisper_config, fid); | ||
| 634 | 637 | ||
| 635 | return ans; | 638 | return ans; |
| 636 | } | 639 | } |
| @@ -782,6 +785,7 @@ static VadModelConfig GetVadModelConfig(JNIEnv *env, jobject config) { | @@ -782,6 +785,7 @@ static VadModelConfig GetVadModelConfig(JNIEnv *env, jobject config) { | ||
| 782 | return ans; | 785 | return ans; |
| 783 | } | 786 | } |
| 784 | 787 | ||
| 788 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 785 | class SherpaOnnxOfflineTts { | 789 | class SherpaOnnxOfflineTts { |
| 786 | public: | 790 | public: |
| 787 | #if __ANDROID_API__ >= 9 | 791 | #if __ANDROID_API__ >= 9 |
| @@ -878,6 +882,7 @@ static OfflineTtsConfig GetOfflineTtsConfig(JNIEnv *env, jobject config) { | @@ -878,6 +882,7 @@ static OfflineTtsConfig GetOfflineTtsConfig(JNIEnv *env, jobject config) { | ||
| 878 | 882 | ||
| 879 | return ans; | 883 | return ans; |
| 880 | } | 884 | } |
| 885 | +#endif | ||
| 881 | 886 | ||
| 882 | } // namespace sherpa_onnx | 887 | } // namespace sherpa_onnx |
| 883 | 888 | ||
| @@ -1209,6 +1214,15 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_allSpeakerNames( | @@ -1209,6 +1214,15 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_allSpeakerNames( | ||
| 1209 | return obj_arr; | 1214 | return obj_arr; |
| 1210 | } | 1215 | } |
| 1211 | 1216 | ||
| 1217 | +// see | ||
| 1218 | +// https://stackoverflow.com/questions/29043872/android-jni-return-multiple-variables | ||
| 1219 | +static jobject NewInteger(JNIEnv *env, int32_t value) { | ||
| 1220 | + jclass cls = env->FindClass("java/lang/Integer"); | ||
| 1221 | + jmethodID constructor = env->GetMethodID(cls, "<init>", "(I)V"); | ||
| 1222 | + return env->NewObject(cls, constructor, value); | ||
| 1223 | +} | ||
| 1224 | + | ||
| 1225 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 1212 | SHERPA_ONNX_EXTERN_C | 1226 | SHERPA_ONNX_EXTERN_C |
| 1213 | JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_new( | 1227 | JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_new( |
| 1214 | JNIEnv *env, jobject /*obj*/, jobject asset_manager, jobject _config) { | 1228 | JNIEnv *env, jobject /*obj*/, jobject asset_manager, jobject _config) { |
| @@ -1265,14 +1279,6 @@ JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getNumSpeakers( | @@ -1265,14 +1279,6 @@ JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getNumSpeakers( | ||
| 1265 | ->NumSpeakers(); | 1279 | ->NumSpeakers(); |
| 1266 | } | 1280 | } |
| 1267 | 1281 | ||
| 1268 | -// see | ||
| 1269 | -// https://stackoverflow.com/questions/29043872/android-jni-return-multiple-variables | ||
| 1270 | -static jobject NewInteger(JNIEnv *env, int32_t value) { | ||
| 1271 | - jclass cls = env->FindClass("java/lang/Integer"); | ||
| 1272 | - jmethodID constructor = env->GetMethodID(cls, "<init>", "(I)V"); | ||
| 1273 | - return env->NewObject(cls, constructor, value); | ||
| 1274 | -} | ||
| 1275 | - | ||
| 1276 | SHERPA_ONNX_EXTERN_C | 1282 | SHERPA_ONNX_EXTERN_C |
| 1277 | JNIEXPORT jobjectArray JNICALL | 1283 | JNIEXPORT jobjectArray JNICALL |
| 1278 | Java_com_k2fsa_sherpa_onnx_OfflineTts_generateImpl(JNIEnv *env, jobject /*obj*/, | 1284 | Java_com_k2fsa_sherpa_onnx_OfflineTts_generateImpl(JNIEnv *env, jobject /*obj*/, |
| @@ -1336,6 +1342,7 @@ Java_com_k2fsa_sherpa_onnx_OfflineTts_generateWithCallbackImpl( | @@ -1336,6 +1342,7 @@ Java_com_k2fsa_sherpa_onnx_OfflineTts_generateWithCallbackImpl( | ||
| 1336 | 1342 | ||
| 1337 | return obj_arr; | 1343 | return obj_arr; |
| 1338 | } | 1344 | } |
| 1345 | +#endif | ||
| 1339 | 1346 | ||
| 1340 | SHERPA_ONNX_EXTERN_C | 1347 | SHERPA_ONNX_EXTERN_C |
| 1341 | JNIEXPORT jboolean JNICALL Java_com_k2fsa_sherpa_onnx_GeneratedAudio_saveImpl( | 1348 | JNIEXPORT jboolean JNICALL Java_com_k2fsa_sherpa_onnx_GeneratedAudio_saveImpl( |
| @@ -15,9 +15,6 @@ set(srcs | @@ -15,9 +15,6 @@ set(srcs | ||
| 15 | offline-stream.cc | 15 | offline-stream.cc |
| 16 | offline-tdnn-model-config.cc | 16 | offline-tdnn-model-config.cc |
| 17 | offline-transducer-model-config.cc | 17 | offline-transducer-model-config.cc |
| 18 | - offline-tts-model-config.cc | ||
| 19 | - offline-tts-vits-model-config.cc | ||
| 20 | - offline-tts.cc | ||
| 21 | offline-wenet-ctc-model-config.cc | 18 | offline-wenet-ctc-model-config.cc |
| 22 | offline-whisper-model-config.cc | 19 | offline-whisper-model-config.cc |
| 23 | offline-zipformer-ctc-model-config.cc | 20 | offline-zipformer-ctc-model-config.cc |
| @@ -44,6 +41,14 @@ else() | @@ -44,6 +41,14 @@ else() | ||
| 44 | list(APPEND srcs faked-alsa.cc) | 41 | list(APPEND srcs faked-alsa.cc) |
| 45 | endif() | 42 | endif() |
| 46 | 43 | ||
| 44 | +if(SHERPA_ONNX_ENABLE_TTS) | ||
| 45 | + list(APPEND srcs | ||
| 46 | + offline-tts-model-config.cc | ||
| 47 | + offline-tts-vits-model-config.cc | ||
| 48 | + offline-tts.cc | ||
| 49 | + ) | ||
| 50 | +endif() | ||
| 51 | + | ||
| 47 | pybind11_add_module(_sherpa_onnx ${srcs}) | 52 | pybind11_add_module(_sherpa_onnx ${srcs}) |
| 48 | 53 | ||
| 49 | if(APPLE) | 54 | if(APPLE) |
| @@ -15,7 +15,6 @@ | @@ -15,7 +15,6 @@ | ||
| 15 | #include "sherpa-onnx/python/csrc/offline-model-config.h" | 15 | #include "sherpa-onnx/python/csrc/offline-model-config.h" |
| 16 | #include "sherpa-onnx/python/csrc/offline-recognizer.h" | 16 | #include "sherpa-onnx/python/csrc/offline-recognizer.h" |
| 17 | #include "sherpa-onnx/python/csrc/offline-stream.h" | 17 | #include "sherpa-onnx/python/csrc/offline-stream.h" |
| 18 | -#include "sherpa-onnx/python/csrc/offline-tts.h" | ||
| 19 | #include "sherpa-onnx/python/csrc/online-lm-config.h" | 18 | #include "sherpa-onnx/python/csrc/online-lm-config.h" |
| 20 | #include "sherpa-onnx/python/csrc/online-model-config.h" | 19 | #include "sherpa-onnx/python/csrc/online-model-config.h" |
| 21 | #include "sherpa-onnx/python/csrc/online-recognizer.h" | 20 | #include "sherpa-onnx/python/csrc/online-recognizer.h" |
| @@ -27,6 +26,10 @@ | @@ -27,6 +26,10 @@ | ||
| 27 | #include "sherpa-onnx/python/csrc/vad-model.h" | 26 | #include "sherpa-onnx/python/csrc/vad-model.h" |
| 28 | #include "sherpa-onnx/python/csrc/voice-activity-detector.h" | 27 | #include "sherpa-onnx/python/csrc/voice-activity-detector.h" |
| 29 | 28 | ||
| 29 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 30 | +#include "sherpa-onnx/python/csrc/offline-tts.h" | ||
| 31 | +#endif | ||
| 32 | + | ||
| 30 | namespace sherpa_onnx { | 33 | namespace sherpa_onnx { |
| 31 | 34 | ||
| 32 | PYBIND11_MODULE(_sherpa_onnx, m) { | 35 | PYBIND11_MODULE(_sherpa_onnx, m) { |
| @@ -53,7 +56,10 @@ PYBIND11_MODULE(_sherpa_onnx, m) { | @@ -53,7 +56,10 @@ PYBIND11_MODULE(_sherpa_onnx, m) { | ||
| 53 | PybindCircularBuffer(&m); | 56 | PybindCircularBuffer(&m); |
| 54 | PybindVoiceActivityDetector(&m); | 57 | PybindVoiceActivityDetector(&m); |
| 55 | 58 | ||
| 59 | +#if SHERPA_ONNX_ENABLE_TTS == 1 | ||
| 56 | PybindOfflineTts(&m); | 60 | PybindOfflineTts(&m); |
| 61 | +#endif | ||
| 62 | + | ||
| 57 | PybindSpeakerEmbeddingExtractor(&m); | 63 | PybindSpeakerEmbeddingExtractor(&m); |
| 58 | PybindSpeakerEmbeddingManager(&m); | 64 | PybindSpeakerEmbeddingManager(&m); |
| 59 | PybindSpokenLanguageIdentification(&m); | 65 | PybindSpokenLanguageIdentification(&m); |
-
请 注册 或 登录 后发表评论