Committed by
GitHub
Add address sanitizer and undefined behavior sanitizer (#951)
正在显示
56 个修改的文件
包含
354 行增加
和
132 行删除
| @@ -137,7 +137,7 @@ jobs: | @@ -137,7 +137,7 @@ jobs: | ||
| 137 | git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main | 137 | git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main |
| 138 | 138 | ||
| 139 | - name: Release android libs | 139 | - name: Release android libs |
| 140 | - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | 140 | + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 141 | uses: svenstaro/upload-release-action@v2 | 141 | uses: svenstaro/upload-release-action@v2 |
| 142 | with: | 142 | with: |
| 143 | file_glob: true | 143 | file_glob: true |
| @@ -217,3 +217,11 @@ jobs: | @@ -217,3 +217,11 @@ jobs: | ||
| 217 | with: | 217 | with: |
| 218 | name: flutter-sherpa-onnx-linux-x64 | 218 | name: flutter-sherpa-onnx-linux-x64 |
| 219 | path: ./*.tar.bz2 | 219 | path: ./*.tar.bz2 |
| 220 | + | ||
| 221 | + # - name: Release android libs | ||
| 222 | + # if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 223 | + # uses: svenstaro/upload-release-action@v2 | ||
| 224 | + # with: | ||
| 225 | + # file_glob: true | ||
| 226 | + # overwrite: true | ||
| 227 | + # file: flutter*.tar.bz2 |
| @@ -180,3 +180,11 @@ jobs: | @@ -180,3 +180,11 @@ jobs: | ||
| 180 | with: | 180 | with: |
| 181 | name: flutter-sherpa-onnx-app-macos-${{ matrix.arch }} | 181 | name: flutter-sherpa-onnx-app-macos-${{ matrix.arch }} |
| 182 | path: ./*.tar.bz2 | 182 | path: ./*.tar.bz2 |
| 183 | + | ||
| 184 | + - name: Release android libs | ||
| 185 | + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 186 | + uses: svenstaro/upload-release-action@v2 | ||
| 187 | + with: | ||
| 188 | + file_glob: true | ||
| 189 | + overwrite: true | ||
| 190 | + file: flutter*.tar.bz2 |
| @@ -157,3 +157,11 @@ jobs: | @@ -157,3 +157,11 @@ jobs: | ||
| 157 | with: | 157 | with: |
| 158 | name: flutter-sherpa-onnx-windows-x64 | 158 | name: flutter-sherpa-onnx-windows-x64 |
| 159 | path: ./*.tar.bz2 | 159 | path: ./*.tar.bz2 |
| 160 | + | ||
| 161 | + - name: Release android libs | ||
| 162 | + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 163 | + uses: svenstaro/upload-release-action@v2 | ||
| 164 | + with: | ||
| 165 | + file_glob: true | ||
| 166 | + overwrite: true | ||
| 167 | + file: flutter*.tar.bz2 |
.github/workflows/sanitizer.yaml
0 → 100644
| 1 | +name: sanitizer | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + workflow_dispatch: | ||
| 5 | + | ||
| 6 | + schedule: | ||
| 7 | + # minute (0-59) | ||
| 8 | + # hour (0-23) | ||
| 9 | + # day of the month (1-31) | ||
| 10 | + # month (1-12) | ||
| 11 | + # day of the week (0-6) | ||
| 12 | + # nightly build at 22:50 UTC time every day | ||
| 13 | + - cron: "50 22 * * *" | ||
| 14 | + | ||
| 15 | +concurrency: | ||
| 16 | + group: sanitizer-${{ github.ref }} | ||
| 17 | + cancel-in-progress: true | ||
| 18 | + | ||
| 19 | +jobs: | ||
| 20 | + sanitizer: | ||
| 21 | + runs-on: ${{ matrix.os }} | ||
| 22 | + name: sanitizer | ||
| 23 | + strategy: | ||
| 24 | + fail-fast: false | ||
| 25 | + matrix: | ||
| 26 | + os: [macos-latest] | ||
| 27 | + | ||
| 28 | + steps: | ||
| 29 | + - uses: actions/checkout@v4 | ||
| 30 | + with: | ||
| 31 | + fetch-depth: 0 | ||
| 32 | + | ||
| 33 | + - name: ccache | ||
| 34 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 35 | + with: | ||
| 36 | + key: ${{ matrix.os }}-sanitizer | ||
| 37 | + | ||
| 38 | + - name: Configure CMake | ||
| 39 | + shell: bash | ||
| 40 | + run: | | ||
| 41 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 42 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 43 | + cmake --version | ||
| 44 | + | ||
| 45 | + mkdir build | ||
| 46 | + cd build | ||
| 47 | + | ||
| 48 | + cmake \ | ||
| 49 | + -DSHERPA_ONNX_ENABLE_PYTHON=ON \ | ||
| 50 | + -DSHERPA_ONNX_ENABLE_TESTS=ON \ | ||
| 51 | + -DSHERPA_ONNX_ENABLE_JNI=ON \ | ||
| 52 | + -DSHERPA_ONNX_ENABLE_SANITIZER=ON \ | ||
| 53 | + -D BUILD_SHARED_LIBS=ON \ | ||
| 54 | + -D CMAKE_BUILD_TYPE=Release \ | ||
| 55 | + -DCMAKE_INSTALL_PREFIX=./install \ | ||
| 56 | + .. | ||
| 57 | + | ||
| 58 | + - name: Build sherpa-onnx | ||
| 59 | + shell: bash | ||
| 60 | + run: | | ||
| 61 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 62 | + | ||
| 63 | + cd build | ||
| 64 | + make -j2 | ||
| 65 | + make install | ||
| 66 | + | ||
| 67 | + ls -lh lib | ||
| 68 | + ls -lh bin | ||
| 69 | + | ||
| 70 | + file ./bin/sherpa-onnx | ||
| 71 | + | ||
| 72 | + - name: Display dependencies of sherpa-onnx for macos | ||
| 73 | + shell: bash | ||
| 74 | + run: | | ||
| 75 | + file bin/sherpa-onnx | ||
| 76 | + otool -L build/bin/sherpa-onnx | ||
| 77 | + otool -l build/bin/sherpa-onnx | ||
| 78 | + | ||
| 79 | + - name: Test offline transducer | ||
| 80 | + shell: bash | ||
| 81 | + run: | | ||
| 82 | + export PATH=$PWD/build/bin:$PATH | ||
| 83 | + export EXE=sherpa-onnx-offline | ||
| 84 | + | ||
| 85 | + .github/scripts/test-offline-transducer.sh | ||
| 86 | + | ||
| 87 | + - name: Test online CTC | ||
| 88 | + shell: bash | ||
| 89 | + run: | | ||
| 90 | + export PATH=$PWD/build/bin:$PATH | ||
| 91 | + export EXE=sherpa-onnx | ||
| 92 | + | ||
| 93 | + .github/scripts/test-online-ctc.sh | ||
| 94 | + | ||
| 95 | + - name: Test offline punctuation | ||
| 96 | + shell: bash | ||
| 97 | + run: | | ||
| 98 | + export PATH=$PWD/build/bin:$PATH | ||
| 99 | + export EXE=sherpa-onnx-offline-punctuation | ||
| 100 | + | ||
| 101 | + .github/scripts/test-offline-punctuation.sh | ||
| 102 | + | ||
| 103 | + - name: Test C API | ||
| 104 | + shell: bash | ||
| 105 | + run: | | ||
| 106 | + export PATH=$PWD/build/bin:$PATH | ||
| 107 | + export SLID_EXE=spoken-language-identification-c-api | ||
| 108 | + export SID_EXE=speaker-identification-c-api | ||
| 109 | + export AT_EXE=audio-tagging-c-api | ||
| 110 | + export PUNCT_EXE=add-punctuation-c-api | ||
| 111 | + | ||
| 112 | + .github/scripts/test-c-api.sh | ||
| 113 | + | ||
| 114 | + - name: Test Audio tagging | ||
| 115 | + shell: bash | ||
| 116 | + run: | | ||
| 117 | + export PATH=$PWD/build/bin:$PATH | ||
| 118 | + export EXE=sherpa-onnx-offline-audio-tagging | ||
| 119 | + | ||
| 120 | + .github/scripts/test-audio-tagging.sh | ||
| 121 | + | ||
| 122 | + - name: Test spoken language identification (C++ API) | ||
| 123 | + shell: bash | ||
| 124 | + run: | | ||
| 125 | + export PATH=$PWD/build/bin:$PATH | ||
| 126 | + export EXE=sherpa-onnx-offline-language-identification | ||
| 127 | + | ||
| 128 | + .github/scripts/test-spoken-language-identification.sh | ||
| 129 | + | ||
| 130 | + - name: Test transducer kws | ||
| 131 | + shell: bash | ||
| 132 | + run: | | ||
| 133 | + export PATH=$PWD/build/bin:$PATH | ||
| 134 | + export EXE=sherpa-onnx-keyword-spotter | ||
| 135 | + | ||
| 136 | + .github/scripts/test-kws.sh | ||
| 137 | + | ||
| 138 | + - name: Test offline TTS | ||
| 139 | + if: matrix.with_tts == 'ON' | ||
| 140 | + shell: bash | ||
| 141 | + run: | | ||
| 142 | + export PATH=$PWD/build/bin:$PATH | ||
| 143 | + export EXE=sherpa-onnx-offline-tts | ||
| 144 | + | ||
| 145 | + .github/scripts/test-offline-tts.sh | ||
| 146 | + | ||
| 147 | + - name: Test online paraformer | ||
| 148 | + shell: bash | ||
| 149 | + run: | | ||
| 150 | + export PATH=$PWD/build/bin:$PATH | ||
| 151 | + export EXE=sherpa-onnx | ||
| 152 | + | ||
| 153 | + .github/scripts/test-online-paraformer.sh | ||
| 154 | + | ||
| 155 | + - name: Test offline Whisper | ||
| 156 | + if: matrix.build_type != 'Debug' | ||
| 157 | + shell: bash | ||
| 158 | + run: | | ||
| 159 | + export PATH=$PWD/build/bin:$PATH | ||
| 160 | + export EXE=sherpa-onnx-offline | ||
| 161 | + | ||
| 162 | + .github/scripts/test-offline-whisper.sh | ||
| 163 | + | ||
| 164 | + - name: Test offline CTC | ||
| 165 | + shell: bash | ||
| 166 | + run: | | ||
| 167 | + export PATH=$PWD/build/bin:$PATH | ||
| 168 | + export EXE=sherpa-onnx-offline | ||
| 169 | + | ||
| 170 | + .github/scripts/test-offline-ctc.sh | ||
| 171 | + | ||
| 172 | + - name: Test online transducer | ||
| 173 | + shell: bash | ||
| 174 | + run: | | ||
| 175 | + export PATH=$PWD/build/bin:$PATH | ||
| 176 | + export EXE=sherpa-onnx | ||
| 177 | + | ||
| 178 | + .github/scripts/test-online-transducer.sh | ||
| 179 | + | ||
| 180 | + - name: Test online transducer (C API) | ||
| 181 | + shell: bash | ||
| 182 | + run: | | ||
| 183 | + export PATH=$PWD/build/bin:$PATH | ||
| 184 | + export EXE=decode-file-c-api | ||
| 185 | + | ||
| 186 | + .github/scripts/test-online-transducer.sh |
| @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | @@ -2,6 +2,8 @@ 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 | + | ||
| 6 | + | ||
| 5 | project(sherpa-onnx) | 7 | project(sherpa-onnx) |
| 6 | 8 | ||
| 7 | set(SHERPA_ONNX_VERSION "1.9.26") | 9 | set(SHERPA_ONNX_VERSION "1.9.26") |
| @@ -32,6 +34,7 @@ option(SHERPA_ONNX_ENABLE_BINARY "Whether to build binaries" ON) | @@ -32,6 +34,7 @@ option(SHERPA_ONNX_ENABLE_BINARY "Whether to build binaries" ON) | ||
| 32 | option(SHERPA_ONNX_ENABLE_TTS "Whether to build TTS related code" ON) | 34 | option(SHERPA_ONNX_ENABLE_TTS "Whether to build TTS related code" ON) |
| 33 | option(SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY "True to link libstdc++ statically. Used only when BUILD_SHARED_LIBS is OFF on Linux" ON) | 35 | option(SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY "True to link libstdc++ statically. Used only when BUILD_SHARED_LIBS is OFF on Linux" ON) |
| 34 | option(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE "True to use pre-installed onnxruntime if available" ON) | 36 | option(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE "True to use pre-installed onnxruntime if available" ON) |
| 37 | +option(SHERPA_ONNX_ENABLE_SANITIZER "Whether to enable ubsan and asan" OFF) | ||
| 35 | 38 | ||
| 36 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") | 39 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") |
| 37 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") | 40 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") |
| @@ -121,6 +124,7 @@ message(STATUS "SHERPA_ONNX_ENABLE_BINARY ${SHERPA_ONNX_ENABLE_BINARY}") | @@ -121,6 +124,7 @@ message(STATUS "SHERPA_ONNX_ENABLE_BINARY ${SHERPA_ONNX_ENABLE_BINARY}") | ||
| 121 | message(STATUS "SHERPA_ONNX_ENABLE_TTS ${SHERPA_ONNX_ENABLE_TTS}") | 124 | message(STATUS "SHERPA_ONNX_ENABLE_TTS ${SHERPA_ONNX_ENABLE_TTS}") |
| 122 | message(STATUS "SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY ${SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY}") | 125 | message(STATUS "SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY ${SHERPA_ONNX_LINK_LIBSTDCPP_STATICALLY}") |
| 123 | message(STATUS "SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE ${SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE}") | 126 | message(STATUS "SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE ${SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE}") |
| 127 | +message(STATUS "SHERPA_ONNX_ENABLE_SANITIZER: ${SHERPA_ONNX_ENABLE_SANITIZER}") | ||
| 124 | 128 | ||
| 125 | if(SHERPA_ONNX_ENABLE_TTS) | 129 | if(SHERPA_ONNX_ENABLE_TTS) |
| 126 | message(STATUS "TTS is enabled") | 130 | message(STATUS "TTS is enabled") |
| @@ -267,6 +271,33 @@ if(SHERPA_ONNX_ENABLE_TTS) | @@ -267,6 +271,33 @@ if(SHERPA_ONNX_ENABLE_TTS) | ||
| 267 | include(cppjieba) # For Chinese TTS. It is a header-only C++ library | 271 | include(cppjieba) # For Chinese TTS. It is a header-only C++ library |
| 268 | endif() | 272 | endif() |
| 269 | 273 | ||
| 274 | +# if(NOT MSVC AND CMAKE_BUILD_TYPE STREQUAL Debug AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")) | ||
| 275 | +if(SHERPA_ONNX_ENABLE_SANITIZER) | ||
| 276 | + message(WARNING "enable ubsan and asan") | ||
| 277 | + set(CMAKE_REQUIRED_LIBRARIES -lubsan -lasan) | ||
| 278 | + include(CheckCCompilerFlag) | ||
| 279 | + | ||
| 280 | + set(flags -fsanitize=undefined ) | ||
| 281 | + string(APPEND flags " -fno-sanitize-recover=undefined ") | ||
| 282 | + string(APPEND flags " -fsanitize=integer ") | ||
| 283 | + string(APPEND flags " -fsanitize=nullability ") | ||
| 284 | + string(APPEND flags " -fsanitize=implicit-conversion ") | ||
| 285 | + string(APPEND flags " -fsanitize=bounds ") | ||
| 286 | + string(APPEND flags " -fsanitize=address ") | ||
| 287 | + | ||
| 288 | + if(OFF) | ||
| 289 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags} -Wall -Wextra") | ||
| 290 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags} -Wall -Wextra") | ||
| 291 | + else() | ||
| 292 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags}") | ||
| 293 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags}") | ||
| 294 | + endif() | ||
| 295 | + | ||
| 296 | + set(CMAKE_EXECUTBLE_LINKER_FLAGS "${CMAKE_EXECUTBLE_LINKER_FLAGS} ${flags}") | ||
| 297 | + | ||
| 298 | + add_compile_options(-fno-omit-frame-pointer) | ||
| 299 | +endif() | ||
| 300 | + | ||
| 270 | add_subdirectory(sherpa-onnx) | 301 | add_subdirectory(sherpa-onnx) |
| 271 | 302 | ||
| 272 | if(SHERPA_ONNX_ENABLE_C_API AND SHERPA_ONNX_ENABLE_BINARY) | 303 | if(SHERPA_ONNX_ENABLE_C_API AND SHERPA_ONNX_ENABLE_BINARY) |
| @@ -43,8 +43,8 @@ int32_t main() { | @@ -43,8 +43,8 @@ int32_t main() { | ||
| 43 | const char *texts[] = { | 43 | const char *texts[] = { |
| 44 | "这是一个测试你好吗How are you我很好thank you are you ok谢谢你", | 44 | "这是一个测试你好吗How are you我很好thank you are you ok谢谢你", |
| 45 | "我们都是木头人不会说话不会动", | 45 | "我们都是木头人不会说话不会动", |
| 46 | - "The African blogosphere is rapidly expanding bringing more voices " | ||
| 47 | - "online in the form of commentaries opinions analyses rants and poetry", | 46 | + ("The African blogosphere is rapidly expanding bringing more voices " |
| 47 | + "online in the form of commentaries opinions analyses rants and poetry"), | ||
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | int32_t n = sizeof(texts) / sizeof(const char *); | 50 | int32_t n = sizeof(texts) / sizeof(const char *); |
| @@ -179,8 +179,6 @@ int32_t main(int32_t argc, char *argv[]) { | @@ -179,8 +179,6 @@ int32_t main(int32_t argc, char *argv[]) { | ||
| 179 | 179 | ||
| 180 | #define N 3200 // 0.2 s. Sample rate is fixed to 16 kHz | 180 | #define N 3200 // 0.2 s. Sample rate is fixed to 16 kHz |
| 181 | 181 | ||
| 182 | - int16_t buffer[N]; | ||
| 183 | - float samples[N]; | ||
| 184 | fprintf(stderr, "sample rate: %d, num samples: %d, duration: %.2f s\n", | 182 | fprintf(stderr, "sample rate: %d, num samples: %d, duration: %.2f s\n", |
| 185 | wave->sample_rate, wave->num_samples, | 183 | wave->sample_rate, wave->num_samples, |
| 186 | (float)wave->num_samples / wave->sample_rate); | 184 | (float)wave->num_samples / wave->sample_rate); |
| @@ -65,8 +65,6 @@ int32_t main() { | @@ -65,8 +65,6 @@ int32_t main() { | ||
| 65 | // simulate streaming. You can choose an arbitrary N | 65 | // simulate streaming. You can choose an arbitrary N |
| 66 | #define N 3200 | 66 | #define N 3200 |
| 67 | 67 | ||
| 68 | - int16_t buffer[N]; | ||
| 69 | - float samples[N]; | ||
| 70 | fprintf(stderr, "sample rate: %d, num samples: %d, duration: %.2f s\n", | 68 | fprintf(stderr, "sample rate: %d, num samples: %d, duration: %.2f s\n", |
| 71 | wave->sample_rate, wave->num_samples, | 69 | wave->sample_rate, wave->num_samples, |
| 72 | (float)wave->num_samples / wave->sample_rate); | 70 | (float)wave->num_samples / wave->sample_rate); |
| @@ -14,10 +14,7 @@ function(download_espeak_ng_for_piper) | @@ -14,10 +14,7 @@ function(download_espeak_ng_for_piper) | ||
| 14 | set(USE_SPEECHPLAYER OFF CACHE BOOL "" FORCE) | 14 | set(USE_SPEECHPLAYER OFF CACHE BOOL "" FORCE) |
| 15 | set(EXTRA_cmn ON CACHE BOOL "" FORCE) | 15 | set(EXTRA_cmn ON CACHE BOOL "" FORCE) |
| 16 | set(EXTRA_ru ON CACHE BOOL "" FORCE) | 16 | set(EXTRA_ru ON CACHE BOOL "" FORCE) |
| 17 | - | ||
| 18 | - if(SHERPA_ONNX_ENABLE_WASM) | ||
| 19 | - set(BUILD_ESPEAK_NG_EXE OFF CACHE BOOL "" FORCE) | ||
| 20 | - endif() | 17 | + set(BUILD_ESPEAK_NG_EXE OFF CACHE BOOL "" FORCE) |
| 21 | 18 | ||
| 22 | # If you don't have access to the Internet, | 19 | # If you don't have access to the Internet, |
| 23 | # please pre-download kaldi-decoder | 20 | # please pre-download kaldi-decoder |
| @@ -187,7 +187,7 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( | @@ -187,7 +187,7 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( | ||
| 187 | r->text = pText; | 187 | r->text = pText; |
| 188 | 188 | ||
| 189 | // copy json | 189 | // copy json |
| 190 | - const auto &json = result.AsJsonString(); | 190 | + std::string json = result.AsJsonString(); |
| 191 | char *pJson = new char[json.size() + 1]; | 191 | char *pJson = new char[json.size() + 1]; |
| 192 | std::copy(json.begin(), json.end(), pJson); | 192 | std::copy(json.begin(), json.end(), pJson); |
| 193 | pJson[json.size()] = 0; | 193 | pJson[json.size()] = 0; |
| @@ -445,7 +445,7 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult( | @@ -445,7 +445,7 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult( | ||
| 445 | r->text = pText; | 445 | r->text = pText; |
| 446 | 446 | ||
| 447 | // copy json | 447 | // copy json |
| 448 | - const auto &json = result.AsJsonString(); | 448 | + std::string json = result.AsJsonString(); |
| 449 | char *pJson = new char[json.size() + 1]; | 449 | char *pJson = new char[json.size() + 1]; |
| 450 | std::copy(json.begin(), json.end(), pJson); | 450 | std::copy(json.begin(), json.end(), pJson); |
| 451 | pJson[json.size()] = 0; | 451 | pJson[json.size()] = 0; |
| @@ -643,7 +643,7 @@ const SherpaOnnxKeywordResult *GetKeywordResult( | @@ -643,7 +643,7 @@ const SherpaOnnxKeywordResult *GetKeywordResult( | ||
| 643 | r->keyword = pKeyword; | 643 | r->keyword = pKeyword; |
| 644 | 644 | ||
| 645 | // copy json | 645 | // copy json |
| 646 | - const auto &json = result.AsJsonString(); | 646 | + std::string json = result.AsJsonString(); |
| 647 | char *pJson = new char[json.size() + 1]; | 647 | char *pJson = new char[json.size() + 1]; |
| 648 | std::copy(json.begin(), json.end(), pJson); | 648 | std::copy(json.begin(), json.end(), pJson); |
| 649 | pJson[json.size()] = 0; | 649 | pJson[json.size()] = 0; |
| @@ -73,7 +73,7 @@ class AudioTaggingCEDImpl : public AudioTaggingImpl { | @@ -73,7 +73,7 @@ class AudioTaggingCEDImpl : public AudioTaggingImpl { | ||
| 73 | std::vector<float> f = s->GetFrames(); | 73 | std::vector<float> f = s->GetFrames(); |
| 74 | 74 | ||
| 75 | int32_t num_frames = f.size() / feat_dim; | 75 | int32_t num_frames = f.size() / feat_dim; |
| 76 | - assert(feat_dim * num_frames == f.size()); | 76 | + assert(feat_dim * num_frames == static_cast<int32_t>(f.size())); |
| 77 | 77 | ||
| 78 | std::array<int64_t, 3> shape = {1, num_frames, feat_dim}; | 78 | std::array<int64_t, 3> shape = {1, num_frames, feat_dim}; |
| 79 | 79 |
| @@ -65,7 +65,7 @@ void AudioTaggingLabels::Init(std::istream &is) { | @@ -65,7 +65,7 @@ void AudioTaggingLabels::Init(std::istream &is) { | ||
| 65 | exit(-1); | 65 | exit(-1); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | - if (i != names_.size()) { | 68 | + if (i != static_cast<int32_t>(names_.size())) { |
| 69 | SHERPA_ONNX_LOGE( | 69 | SHERPA_ONNX_LOGE( |
| 70 | "Index should be sorted and contiguous. Expected index: %d, given: " | 70 | "Index should be sorted and contiguous. Expected index: %d, given: " |
| 71 | "%d.", | 71 | "%d.", |
| @@ -74,7 +74,7 @@ class AudioTaggingZipformerImpl : public AudioTaggingImpl { | @@ -74,7 +74,7 @@ class AudioTaggingZipformerImpl : public AudioTaggingImpl { | ||
| 74 | 74 | ||
| 75 | int32_t num_frames = f.size() / feat_dim; | 75 | int32_t num_frames = f.size() / feat_dim; |
| 76 | 76 | ||
| 77 | - assert(feat_dim * num_frames == f.size()); | 77 | + assert(feat_dim * num_frames == static_cast<int32_t>(f.size())); |
| 78 | 78 | ||
| 79 | std::array<int64_t, 3> shape = {1, num_frames, feat_dim}; | 79 | std::array<int64_t, 3> shape = {1, num_frames, feat_dim}; |
| 80 | 80 |
| @@ -92,7 +92,7 @@ Ort::Value Cat(OrtAllocator *allocator, | @@ -92,7 +92,7 @@ Ort::Value Cat(OrtAllocator *allocator, | ||
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | - return std::move(ans); | 95 | + return ans; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | template Ort::Value Cat<float>(OrtAllocator *allocator, | 98 | template Ort::Value Cat<float>(OrtAllocator *allocator, |
| @@ -62,7 +62,6 @@ void CircularBuffer::Resize(int32_t new_capacity) { | @@ -62,7 +62,6 @@ void CircularBuffer::Resize(int32_t new_capacity) { | ||
| 62 | new_buffer.begin() + dest); | 62 | new_buffer.begin() + dest); |
| 63 | } else { | 63 | } else { |
| 64 | int32_t first_part = new_capacity - dest; | 64 | int32_t first_part = new_capacity - dest; |
| 65 | - int32_t second_part = part1_size - first_part; | ||
| 66 | std::copy(buffer_.begin() + start, buffer_.begin() + start + first_part, | 65 | std::copy(buffer_.begin() + start, buffer_.begin() + start + first_part, |
| 67 | new_buffer.begin() + dest); | 66 | new_buffer.begin() + dest); |
| 68 | 67 |
| @@ -27,7 +27,7 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | @@ -27,7 +27,7 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | ||
| 27 | if (!ac_thresholds.empty()) { | 27 | if (!ac_thresholds.empty()) { |
| 28 | SHERPA_ONNX_CHECK_EQ(token_ids.size(), ac_thresholds.size()); | 28 | SHERPA_ONNX_CHECK_EQ(token_ids.size(), ac_thresholds.size()); |
| 29 | } | 29 | } |
| 30 | - for (int32_t i = 0; i < token_ids.size(); ++i) { | 30 | + for (int32_t i = 0; i < static_cast<int32_t>(token_ids.size()); ++i) { |
| 31 | auto node = root_.get(); | 31 | auto node = root_.get(); |
| 32 | float score = scores.empty() ? 0.0f : scores[i]; | 32 | float score = scores.empty() ? 0.0f : scores[i]; |
| 33 | score = score == 0.0f ? context_score_ : score; | 33 | score = score == 0.0f ? context_score_ : score; |
| @@ -35,10 +35,10 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | @@ -35,10 +35,10 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | ||
| 35 | ac_threshold = ac_threshold == 0.0f ? ac_threshold_ : ac_threshold; | 35 | ac_threshold = ac_threshold == 0.0f ? ac_threshold_ : ac_threshold; |
| 36 | std::string phrase = phrases.empty() ? std::string() : phrases[i]; | 36 | std::string phrase = phrases.empty() ? std::string() : phrases[i]; |
| 37 | 37 | ||
| 38 | - for (int32_t j = 0; j < token_ids[i].size(); ++j) { | 38 | + for (int32_t j = 0; j < static_cast<int32_t>(token_ids[i].size()); ++j) { |
| 39 | int32_t token = token_ids[i][j]; | 39 | int32_t token = token_ids[i][j]; |
| 40 | if (0 == node->next.count(token)) { | 40 | if (0 == node->next.count(token)) { |
| 41 | - bool is_end = j == token_ids[i].size() - 1; | 41 | + bool is_end = j == (static_cast<int32_t>(token_ids[i].size()) - 1); |
| 42 | node->next[token] = std::make_unique<ContextState>( | 42 | node->next[token] = std::make_unique<ContextState>( |
| 43 | token, score, node->node_score + score, | 43 | token, score, node->node_score + score, |
| 44 | is_end ? node->node_score + score : 0, j + 1, | 44 | is_end ? node->node_score + score : 0, j + 1, |
| @@ -49,11 +49,11 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | @@ -49,11 +49,11 @@ void ContextGraph::Build(const std::vector<std::vector<int32_t>> &token_ids, | ||
| 49 | node->next[token]->token_score = token_score; | 49 | node->next[token]->token_score = token_score; |
| 50 | float node_score = node->node_score + token_score; | 50 | float node_score = node->node_score + token_score; |
| 51 | node->next[token]->node_score = node_score; | 51 | node->next[token]->node_score = node_score; |
| 52 | - bool is_end = | ||
| 53 | - (j == token_ids[i].size() - 1) || node->next[token]->is_end; | 52 | + bool is_end = (j == static_cast<int32_t>(token_ids[i].size()) - 1) || |
| 53 | + node->next[token]->is_end; | ||
| 54 | node->next[token]->output_score = is_end ? node_score : 0.0f; | 54 | node->next[token]->output_score = is_end ? node_score : 0.0f; |
| 55 | node->next[token]->is_end = is_end; | 55 | node->next[token]->is_end = is_end; |
| 56 | - if (j == token_ids[i].size() - 1) { | 56 | + if (j == static_cast<int32_t>(token_ids[i].size()) - 1) { |
| 57 | node->next[token]->phrase = phrase; | 57 | node->next[token]->phrase = phrase; |
| 58 | node->next[token]->ac_threshold = ac_threshold; | 58 | node->next[token]->ac_threshold = ac_threshold; |
| 59 | } | 59 | } |
| @@ -129,8 +129,8 @@ class Hypotheses { | @@ -129,8 +129,8 @@ class Hypotheses { | ||
| 129 | return os.str(); | 129 | return os.str(); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | - const auto begin() const { return hyps_dict_.begin(); } | ||
| 133 | - const auto end() const { return hyps_dict_.end(); } | 132 | + auto begin() const { return hyps_dict_.begin(); } |
| 133 | + auto end() const { return hyps_dict_.end(); } | ||
| 134 | 134 | ||
| 135 | auto begin() { return hyps_dict_.begin(); } | 135 | auto begin() { return hyps_dict_.begin(); } |
| 136 | auto end() { return hyps_dict_.end(); } | 136 | auto end() { return hyps_dict_.end(); } |
| @@ -217,7 +217,7 @@ JiebaLexicon::JiebaLexicon(const std::string &lexicon, | @@ -217,7 +217,7 @@ JiebaLexicon::JiebaLexicon(const std::string &lexicon, | ||
| 217 | debug)) {} | 217 | debug)) {} |
| 218 | 218 | ||
| 219 | std::vector<std::vector<int64_t>> JiebaLexicon::ConvertTextToTokenIds( | 219 | std::vector<std::vector<int64_t>> JiebaLexicon::ConvertTextToTokenIds( |
| 220 | - const std::string &text, const std::string &unused_voice /*= ""*/) const { | 220 | + const std::string &text, const std::string & /*unused_voice = ""*/) const { |
| 221 | return impl_->ConvertTextToTokenIds(text); | 221 | return impl_->ConvertTextToTokenIds(text); |
| 222 | } | 222 | } |
| 223 | 223 |
| @@ -69,7 +69,7 @@ class OfflineCtTransformerModel::Impl { | @@ -69,7 +69,7 @@ class OfflineCtTransformerModel::Impl { | ||
| 69 | 69 | ||
| 70 | int32_t vocab_size; | 70 | int32_t vocab_size; |
| 71 | SHERPA_ONNX_READ_META_DATA(vocab_size, "vocab_size"); | 71 | SHERPA_ONNX_READ_META_DATA(vocab_size, "vocab_size"); |
| 72 | - if (tokens.size() != vocab_size) { | 72 | + if (static_cast<int32_t>(tokens.size()) != vocab_size) { |
| 73 | SHERPA_ONNX_LOGE("tokens.size() %d != vocab_size %d", | 73 | SHERPA_ONNX_LOGE("tokens.size() %d != vocab_size %d", |
| 74 | static_cast<int32_t>(tokens.size()), vocab_size); | 74 | static_cast<int32_t>(tokens.size()), vocab_size); |
| 75 | exit(-1); | 75 | exit(-1); |
| @@ -71,7 +71,7 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl { | @@ -71,7 +71,7 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl { | ||
| 71 | for (int32_t i = 0; i != num_segments; ++i) { | 71 | for (int32_t i = 0; i != num_segments; ++i) { |
| 72 | int32_t this_start = i * segment_size; // inclusive | 72 | int32_t this_start = i * segment_size; // inclusive |
| 73 | int32_t this_end = this_start + segment_size; // exclusive | 73 | int32_t this_end = this_start + segment_size; // exclusive |
| 74 | - if (this_end > token_ids.size()) { | 74 | + if (this_end > static_cast<int32_t>(token_ids.size())) { |
| 75 | this_end = token_ids.size(); | 75 | this_end = token_ids.size(); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -155,7 +155,7 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl { | @@ -155,7 +155,7 @@ class OfflinePunctuationCtTransformerImpl : public OfflinePunctuationImpl { | ||
| 155 | std::vector<std::string> words_punct; | 155 | std::vector<std::string> words_punct; |
| 156 | 156 | ||
| 157 | for (int32_t i = 0; i != static_cast<int32_t>(punctuations.size()); ++i) { | 157 | for (int32_t i = 0; i != static_cast<int32_t>(punctuations.size()); ++i) { |
| 158 | - if (i >= tokens.size()) { | 158 | + if (i >= static_cast<int32_t>(tokens.size())) { |
| 159 | break; | 159 | break; |
| 160 | } | 160 | } |
| 161 | std::string &w = tokens[i]; | 161 | std::string &w = tokens[i]; |
| @@ -96,7 +96,7 @@ OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( | @@ -96,7 +96,7 @@ OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( | ||
| 96 | 96 | ||
| 97 | std::vector<std::vector<int64_t>> | 97 | std::vector<std::vector<int64_t>> |
| 98 | OfflineTtsCharacterFrontend::ConvertTextToTokenIds( | 98 | OfflineTtsCharacterFrontend::ConvertTextToTokenIds( |
| 99 | - const std::string &_text, const std::string &voice /*= ""*/) const { | 99 | + const std::string &_text, const std::string & /*voice = ""*/) const { |
| 100 | // see | 100 | // see |
| 101 | // https://github.com/coqui-ai/TTS/blob/dev/TTS/tts/utils/text/tokenizer.py#L87 | 101 | // https://github.com/coqui-ai/TTS/blob/dev/TTS/tts/utils/text/tokenizer.py#L87 |
| 102 | int32_t use_eos_bos = meta_data_.use_eos_bos; | 102 | int32_t use_eos_bos = meta_data_.use_eos_bos; |
| @@ -151,7 +151,7 @@ OfflineTtsCharacterFrontend::ConvertTextToTokenIds( | @@ -151,7 +151,7 @@ OfflineTtsCharacterFrontend::ConvertTextToTokenIds( | ||
| 151 | this_sentence.push_back(eos_id); | 151 | this_sentence.push_back(eos_id); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | - if (this_sentence.size() > 1 + use_eos_bos) { | 154 | + if (static_cast<int32_t>(this_sentence.size()) > 1 + use_eos_bos) { |
| 155 | ans.push_back(std::move(this_sentence)); | 155 | ans.push_back(std::move(this_sentence)); |
| 156 | } | 156 | } |
| 157 | } else { | 157 | } else { |
| @@ -238,7 +238,7 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { | @@ -238,7 +238,7 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { | ||
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | batch.clear(); | 240 | batch.clear(); |
| 241 | - while (k < x.size()) { | 241 | + while (k < static_cast<int32_t>(x.size())) { |
| 242 | batch.push_back(std::move(x[k])); | 242 | batch.push_back(std::move(x[k])); |
| 243 | ++k; | 243 | ++k; |
| 244 | } | 244 | } |
| @@ -91,8 +91,8 @@ struct OnlineRecognizerConfig { | @@ -91,8 +91,8 @@ struct OnlineRecognizerConfig { | ||
| 91 | int32_t max_active_paths = 4; | 91 | int32_t max_active_paths = 4; |
| 92 | 92 | ||
| 93 | /// used only for modified_beam_search | 93 | /// used only for modified_beam_search |
| 94 | - float hotwords_score = 1.5; | ||
| 95 | std::string hotwords_file; | 94 | std::string hotwords_file; |
| 95 | + float hotwords_score = 1.5; | ||
| 96 | 96 | ||
| 97 | float blank_penalty = 0.0; | 97 | float blank_penalty = 0.0; |
| 98 | 98 | ||
| @@ -102,17 +102,12 @@ struct OnlineRecognizerConfig { | @@ -102,17 +102,12 @@ struct OnlineRecognizerConfig { | ||
| 102 | 102 | ||
| 103 | OnlineRecognizerConfig( | 103 | OnlineRecognizerConfig( |
| 104 | const FeatureExtractorConfig &feat_config, | 104 | const FeatureExtractorConfig &feat_config, |
| 105 | - const OnlineModelConfig &model_config, | ||
| 106 | - const OnlineLMConfig &lm_config, | 105 | + const OnlineModelConfig &model_config, const OnlineLMConfig &lm_config, |
| 107 | const EndpointConfig &endpoint_config, | 106 | const EndpointConfig &endpoint_config, |
| 108 | const OnlineCtcFstDecoderConfig &ctc_fst_decoder_config, | 107 | const OnlineCtcFstDecoderConfig &ctc_fst_decoder_config, |
| 109 | - bool enable_endpoint, | ||
| 110 | - const std::string &decoding_method, | ||
| 111 | - int32_t max_active_paths, | ||
| 112 | - const std::string &hotwords_file, | ||
| 113 | - float hotwords_score, | ||
| 114 | - float blank_penalty, | ||
| 115 | - float temperature_scale) | 108 | + bool enable_endpoint, const std::string &decoding_method, |
| 109 | + int32_t max_active_paths, const std::string &hotwords_file, | ||
| 110 | + float hotwords_score, float blank_penalty, float temperature_scale) | ||
| 116 | : feat_config(feat_config), | 111 | : feat_config(feat_config), |
| 117 | model_config(model_config), | 112 | model_config(model_config), |
| 118 | lm_config(lm_config), | 113 | lm_config(lm_config), |
| @@ -95,15 +95,15 @@ class OnlineTransducerDecoder { | @@ -95,15 +95,15 @@ class OnlineTransducerDecoder { | ||
| 95 | * online decoding case, each utterance has the same number of frames | 95 | * online decoding case, each utterance has the same number of frames |
| 96 | * and there are no paddings. | 96 | * and there are no paddings. |
| 97 | */ | 97 | */ |
| 98 | - virtual void Decode(Ort::Value encoder_out, OnlineStream **ss, | ||
| 99 | - std::vector<OnlineTransducerDecoderResult> *result) { | 98 | + virtual void Decode(Ort::Value /*encoder_out*/, OnlineStream ** /*ss*/, |
| 99 | + std::vector<OnlineTransducerDecoderResult> * /*result*/) { | ||
| 100 | SHERPA_ONNX_LOGE( | 100 | SHERPA_ONNX_LOGE( |
| 101 | "This interface is for OnlineTransducerModifiedBeamSearchDecoder."); | 101 | "This interface is for OnlineTransducerModifiedBeamSearchDecoder."); |
| 102 | exit(-1); | 102 | exit(-1); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | // used for endpointing. We need to keep decoder_out after reset | 105 | // used for endpointing. We need to keep decoder_out after reset |
| 106 | - virtual void UpdateDecoderOut(OnlineTransducerDecoderResult *result) {} | 106 | + virtual void UpdateDecoderOut(OnlineTransducerDecoderResult * /*result*/) {} |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | } // namespace sherpa_onnx | 109 | } // namespace sherpa_onnx |
| @@ -77,7 +77,7 @@ void OnlineTransducerGreedySearchDecoder::Decode( | @@ -77,7 +77,7 @@ void OnlineTransducerGreedySearchDecoder::Decode( | ||
| 77 | std::vector<int64_t> encoder_out_shape = | 77 | std::vector<int64_t> encoder_out_shape = |
| 78 | encoder_out.GetTensorTypeAndShapeInfo().GetShape(); | 78 | encoder_out.GetTensorTypeAndShapeInfo().GetShape(); |
| 79 | 79 | ||
| 80 | - if (encoder_out_shape[0] != result->size()) { | 80 | + if (encoder_out_shape[0] != static_cast<int32_t>(result->size())) { |
| 81 | SHERPA_ONNX_LOGE( | 81 | SHERPA_ONNX_LOGE( |
| 82 | "Size mismatch! encoder_out.size(0) %d, result.size(0): %d", | 82 | "Size mismatch! encoder_out.size(0) %d, result.size(0): %d", |
| 83 | static_cast<int32_t>(encoder_out_shape[0]), | 83 | static_cast<int32_t>(encoder_out_shape[0]), |
| @@ -69,7 +69,7 @@ class OnlineTransducerModel { | @@ -69,7 +69,7 @@ class OnlineTransducerModel { | ||
| 69 | * This has to be called before GetEncoderInitStates(), so the `encoder_embed` | 69 | * This has to be called before GetEncoderInitStates(), so the `encoder_embed` |
| 70 | * init state has the correct `embed_dim` of its output. | 70 | * init state has the correct `embed_dim` of its output. |
| 71 | */ | 71 | */ |
| 72 | - virtual void SetFeatureDim(int32_t feature_dim) {} | 72 | + virtual void SetFeatureDim(int32_t /*feature_dim*/) {} |
| 73 | 73 | ||
| 74 | /** Run the encoder. | 74 | /** Run the encoder. |
| 75 | * | 75 | * |
| @@ -17,7 +17,7 @@ namespace sherpa_onnx { | @@ -17,7 +17,7 @@ namespace sherpa_onnx { | ||
| 17 | static void UseCachedDecoderOut( | 17 | static void UseCachedDecoderOut( |
| 18 | const std::vector<int32_t> &hyps_row_splits, | 18 | const std::vector<int32_t> &hyps_row_splits, |
| 19 | const std::vector<OnlineTransducerDecoderResult> &results, | 19 | const std::vector<OnlineTransducerDecoderResult> &results, |
| 20 | - int32_t context_size, Ort::Value *decoder_out) { | 20 | + Ort::Value *decoder_out) { |
| 21 | std::vector<int64_t> shape = | 21 | std::vector<int64_t> shape = |
| 22 | decoder_out->GetTensorTypeAndShapeInfo().GetShape(); | 22 | decoder_out->GetTensorTypeAndShapeInfo().GetShape(); |
| 23 | 23 | ||
| @@ -80,7 +80,8 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | @@ -80,7 +80,8 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | ||
| 80 | std::vector<int64_t> encoder_out_shape = | 80 | std::vector<int64_t> encoder_out_shape = |
| 81 | encoder_out.GetTensorTypeAndShapeInfo().GetShape(); | 81 | encoder_out.GetTensorTypeAndShapeInfo().GetShape(); |
| 82 | 82 | ||
| 83 | - if (encoder_out_shape[0] != result->size()) { | 83 | + if (static_cast<int32_t>(encoder_out_shape[0]) != |
| 84 | + static_cast<int32_t>(result->size())) { | ||
| 84 | SHERPA_ONNX_LOGE( | 85 | SHERPA_ONNX_LOGE( |
| 85 | "Size mismatch! encoder_out.size(0) %d, result.size(0): %d\n", | 86 | "Size mismatch! encoder_out.size(0) %d, result.size(0): %d\n", |
| 86 | static_cast<int32_t>(encoder_out_shape[0]), | 87 | static_cast<int32_t>(encoder_out_shape[0]), |
| @@ -117,8 +118,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | @@ -117,8 +118,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | ||
| 117 | Ort::Value decoder_input = model_->BuildDecoderInput(prev); | 118 | Ort::Value decoder_input = model_->BuildDecoderInput(prev); |
| 118 | Ort::Value decoder_out = model_->RunDecoder(std::move(decoder_input)); | 119 | Ort::Value decoder_out = model_->RunDecoder(std::move(decoder_input)); |
| 119 | if (t == 0) { | 120 | if (t == 0) { |
| 120 | - UseCachedDecoderOut(hyps_row_splits, *result, model_->ContextSize(), | ||
| 121 | - &decoder_out); | 121 | + UseCachedDecoderOut(hyps_row_splits, *result, &decoder_out); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | Ort::Value cur_encoder_out = | 124 | Ort::Value cur_encoder_out = |
| @@ -136,10 +136,9 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | @@ -136,10 +136,9 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | ||
| 136 | int32_t p_logit_items = vocab_size * num_hyps; | 136 | int32_t p_logit_items = vocab_size * num_hyps; |
| 137 | std::vector<float> logit_with_temperature(p_logit_items); | 137 | std::vector<float> logit_with_temperature(p_logit_items); |
| 138 | { | 138 | { |
| 139 | - std::copy(p_logit, | ||
| 140 | - p_logit + p_logit_items, | 139 | + std::copy(p_logit, p_logit + p_logit_items, |
| 141 | logit_with_temperature.begin()); | 140 | logit_with_temperature.begin()); |
| 142 | - for (float& elem : logit_with_temperature) { | 141 | + for (float &elem : logit_with_temperature) { |
| 143 | elem /= temperature_scale_; | 142 | elem /= temperature_scale_; |
| 144 | } | 143 | } |
| 145 | LogSoftmax(logit_with_temperature.data(), vocab_size, num_hyps); | 144 | LogSoftmax(logit_with_temperature.data(), vocab_size, num_hyps); |
| @@ -226,7 +225,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | @@ -226,7 +225,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | ||
| 226 | cur.push_back(std::move(hyps)); | 225 | cur.push_back(std::move(hyps)); |
| 227 | p_logprob += (end - start) * vocab_size; | 226 | p_logprob += (end - start) * vocab_size; |
| 228 | } // for (int32_t b = 0; b != batch_size; ++b) | 227 | } // for (int32_t b = 0; b != batch_size; ++b) |
| 229 | - } // for (int32_t t = 0; t != num_frames; ++t) | 228 | + } // for (int32_t t = 0; t != num_frames; ++t) |
| 230 | 229 | ||
| 231 | for (int32_t b = 0; b != batch_size; ++b) { | 230 | for (int32_t b = 0; b != batch_size; ++b) { |
| 232 | auto &hyps = cur[b]; | 231 | auto &hyps = cur[b]; |
| @@ -242,7 +241,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | @@ -242,7 +241,7 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( | ||
| 242 | 241 | ||
| 243 | void OnlineTransducerModifiedBeamSearchDecoder::UpdateDecoderOut( | 242 | void OnlineTransducerModifiedBeamSearchDecoder::UpdateDecoderOut( |
| 244 | OnlineTransducerDecoderResult *result) { | 243 | OnlineTransducerDecoderResult *result) { |
| 245 | - if (result->tokens.size() == model_->ContextSize()) { | 244 | + if (static_cast<int32_t>(result->tokens.size()) == model_->ContextSize()) { |
| 246 | result->decoder_out = Ort::Value{nullptr}; | 245 | result->decoder_out = Ort::Value{nullptr}; |
| 247 | return; | 246 | return; |
| 248 | } | 247 | } |
| @@ -51,7 +51,7 @@ class Client { | @@ -51,7 +51,7 @@ class Client { | ||
| 51 | c_.init_asio(&io_); | 51 | c_.init_asio(&io_); |
| 52 | c_.set_open_handler([this](connection_hdl hdl) { OnOpen(hdl); }); | 52 | c_.set_open_handler([this](connection_hdl hdl) { OnOpen(hdl); }); |
| 53 | c_.set_close_handler( | 53 | c_.set_close_handler( |
| 54 | - [this](connection_hdl /*hdl*/) { SHERPA_ONNX_LOGE("Disconnected"); }); | 54 | + [](connection_hdl /*hdl*/) { SHERPA_ONNX_LOGE("Disconnected"); }); |
| 55 | c_.set_message_handler( | 55 | c_.set_message_handler( |
| 56 | [this](connection_hdl hdl, message_ptr msg) { OnMessage(hdl, msg); }); | 56 | [this](connection_hdl hdl, message_ptr msg) { OnMessage(hdl, msg); }); |
| 57 | 57 |
| @@ -34,8 +34,8 @@ namespace sherpa_onnx { | @@ -34,8 +34,8 @@ namespace sherpa_onnx { | ||
| 34 | OnlineZipformer2TransducerModel::OnlineZipformer2TransducerModel( | 34 | OnlineZipformer2TransducerModel::OnlineZipformer2TransducerModel( |
| 35 | const OnlineModelConfig &config) | 35 | const OnlineModelConfig &config) |
| 36 | : env_(ORT_LOGGING_LEVEL_WARNING), | 36 | : env_(ORT_LOGGING_LEVEL_WARNING), |
| 37 | - config_(config), | ||
| 38 | sess_opts_(GetSessionOptions(config)), | 37 | sess_opts_(GetSessionOptions(config)), |
| 38 | + config_(config), | ||
| 39 | allocator_{} { | 39 | allocator_{} { |
| 40 | { | 40 | { |
| 41 | auto buf = ReadFile(config.transducer.encoder); | 41 | auto buf = ReadFile(config.transducer.encoder); |
| @@ -179,7 +179,6 @@ void OnlineZipformer2TransducerModel::InitJoiner(void *model_data, | @@ -179,7 +179,6 @@ void OnlineZipformer2TransducerModel::InitJoiner(void *model_data, | ||
| 179 | std::vector<Ort::Value> OnlineZipformer2TransducerModel::StackStates( | 179 | std::vector<Ort::Value> OnlineZipformer2TransducerModel::StackStates( |
| 180 | const std::vector<std::vector<Ort::Value>> &states) const { | 180 | const std::vector<std::vector<Ort::Value>> &states) const { |
| 181 | int32_t batch_size = static_cast<int32_t>(states.size()); | 181 | int32_t batch_size = static_cast<int32_t>(states.size()); |
| 182 | - int32_t num_encoders = static_cast<int32_t>(num_encoder_layers_.size()); | ||
| 183 | 182 | ||
| 184 | std::vector<const Ort::Value *> buf(batch_size); | 183 | std::vector<const Ort::Value *> buf(batch_size); |
| 185 | 184 | ||
| @@ -255,10 +254,9 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -255,10 +254,9 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 255 | const std::vector<Ort::Value> &states) const { | 254 | const std::vector<Ort::Value> &states) const { |
| 256 | int32_t m = std::accumulate(num_encoder_layers_.begin(), | 255 | int32_t m = std::accumulate(num_encoder_layers_.begin(), |
| 257 | num_encoder_layers_.end(), 0); | 256 | num_encoder_layers_.end(), 0); |
| 258 | - assert(states.size() == m * 6 + 2); | 257 | + assert(static_cast<int32_t>(states.size()) == m * 6 + 2); |
| 259 | 258 | ||
| 260 | int32_t batch_size = states[0].GetTensorTypeAndShapeInfo().GetShape()[1]; | 259 | int32_t batch_size = states[0].GetTensorTypeAndShapeInfo().GetShape()[1]; |
| 261 | - int32_t num_encoders = num_encoder_layers_.size(); | ||
| 262 | 260 | ||
| 263 | std::vector<std::vector<Ort::Value>> ans; | 261 | std::vector<std::vector<Ort::Value>> ans; |
| 264 | ans.resize(batch_size); | 262 | ans.resize(batch_size); |
| @@ -266,7 +264,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -266,7 +264,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 266 | for (int32_t i = 0; i != m; ++i) { | 264 | for (int32_t i = 0; i != m; ++i) { |
| 267 | { | 265 | { |
| 268 | auto v = Unbind(allocator_, &states[i * 6], 1); | 266 | auto v = Unbind(allocator_, &states[i * 6], 1); |
| 269 | - assert(v.size() == batch_size); | 267 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 270 | 268 | ||
| 271 | for (int32_t n = 0; n != batch_size; ++n) { | 269 | for (int32_t n = 0; n != batch_size; ++n) { |
| 272 | ans[n].push_back(std::move(v[n])); | 270 | ans[n].push_back(std::move(v[n])); |
| @@ -274,7 +272,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -274,7 +272,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 274 | } | 272 | } |
| 275 | { | 273 | { |
| 276 | auto v = Unbind(allocator_, &states[i * 6 + 1], 1); | 274 | auto v = Unbind(allocator_, &states[i * 6 + 1], 1); |
| 277 | - assert(v.size() == batch_size); | 275 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 278 | 276 | ||
| 279 | for (int32_t n = 0; n != batch_size; ++n) { | 277 | for (int32_t n = 0; n != batch_size; ++n) { |
| 280 | ans[n].push_back(std::move(v[n])); | 278 | ans[n].push_back(std::move(v[n])); |
| @@ -282,7 +280,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -282,7 +280,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 282 | } | 280 | } |
| 283 | { | 281 | { |
| 284 | auto v = Unbind(allocator_, &states[i * 6 + 2], 1); | 282 | auto v = Unbind(allocator_, &states[i * 6 + 2], 1); |
| 285 | - assert(v.size() == batch_size); | 283 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 286 | 284 | ||
| 287 | for (int32_t n = 0; n != batch_size; ++n) { | 285 | for (int32_t n = 0; n != batch_size; ++n) { |
| 288 | ans[n].push_back(std::move(v[n])); | 286 | ans[n].push_back(std::move(v[n])); |
| @@ -290,7 +288,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -290,7 +288,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 290 | } | 288 | } |
| 291 | { | 289 | { |
| 292 | auto v = Unbind(allocator_, &states[i * 6 + 3], 1); | 290 | auto v = Unbind(allocator_, &states[i * 6 + 3], 1); |
| 293 | - assert(v.size() == batch_size); | 291 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 294 | 292 | ||
| 295 | for (int32_t n = 0; n != batch_size; ++n) { | 293 | for (int32_t n = 0; n != batch_size; ++n) { |
| 296 | ans[n].push_back(std::move(v[n])); | 294 | ans[n].push_back(std::move(v[n])); |
| @@ -298,7 +296,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -298,7 +296,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 298 | } | 296 | } |
| 299 | { | 297 | { |
| 300 | auto v = Unbind(allocator_, &states[i * 6 + 4], 0); | 298 | auto v = Unbind(allocator_, &states[i * 6 + 4], 0); |
| 301 | - assert(v.size() == batch_size); | 299 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 302 | 300 | ||
| 303 | for (int32_t n = 0; n != batch_size; ++n) { | 301 | for (int32_t n = 0; n != batch_size; ++n) { |
| 304 | ans[n].push_back(std::move(v[n])); | 302 | ans[n].push_back(std::move(v[n])); |
| @@ -306,7 +304,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -306,7 +304,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 306 | } | 304 | } |
| 307 | { | 305 | { |
| 308 | auto v = Unbind(allocator_, &states[i * 6 + 5], 0); | 306 | auto v = Unbind(allocator_, &states[i * 6 + 5], 0); |
| 309 | - assert(v.size() == batch_size); | 307 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 310 | 308 | ||
| 311 | for (int32_t n = 0; n != batch_size; ++n) { | 309 | for (int32_t n = 0; n != batch_size; ++n) { |
| 312 | ans[n].push_back(std::move(v[n])); | 310 | ans[n].push_back(std::move(v[n])); |
| @@ -316,7 +314,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -316,7 +314,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 316 | 314 | ||
| 317 | { | 315 | { |
| 318 | auto v = Unbind(allocator_, &states[m * 6], 0); | 316 | auto v = Unbind(allocator_, &states[m * 6], 0); |
| 319 | - assert(v.size() == batch_size); | 317 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 320 | 318 | ||
| 321 | for (int32_t n = 0; n != batch_size; ++n) { | 319 | for (int32_t n = 0; n != batch_size; ++n) { |
| 322 | ans[n].push_back(std::move(v[n])); | 320 | ans[n].push_back(std::move(v[n])); |
| @@ -324,7 +322,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | @@ -324,7 +322,7 @@ OnlineZipformer2TransducerModel::UnStackStates( | ||
| 324 | } | 322 | } |
| 325 | { | 323 | { |
| 326 | auto v = Unbind<int64_t>(allocator_, &states[m * 6 + 1], 0); | 324 | auto v = Unbind<int64_t>(allocator_, &states[m * 6 + 1], 0); |
| 327 | - assert(v.size() == batch_size); | 325 | + assert(static_cast<int32_t>(v.size()) == batch_size); |
| 328 | 326 | ||
| 329 | for (int32_t n = 0; n != batch_size; ++n) { | 327 | for (int32_t n = 0; n != batch_size; ++n) { |
| 330 | ans[n].push_back(std::move(v[n])); | 328 | ans[n].push_back(std::move(v[n])); |
| @@ -246,7 +246,7 @@ static bool MustBeQuoted(const std::string &str, ShellType st) { | @@ -246,7 +246,7 @@ static bool MustBeQuoted(const std::string &str, ShellType st) { | ||
| 246 | // Our aim is to print out the command line in such a way that if it's | 246 | // Our aim is to print out the command line in such a way that if it's |
| 247 | // pasted into a shell of ShellType "st" (only bash for now), it | 247 | // pasted into a shell of ShellType "st" (only bash for now), it |
| 248 | // will get passed to the program in the same way. | 248 | // will get passed to the program in the same way. |
| 249 | -static std::string QuoteAndEscape(const std::string &str, ShellType st) { | 249 | +static std::string QuoteAndEscape(const std::string &str, ShellType /*st*/) { |
| 250 | // Only Bash is supported (for the moment). | 250 | // Only Bash is supported (for the moment). |
| 251 | SHERPA_ONNX_CHECK_EQ(st, kBash) << "Invalid shell type."; | 251 | SHERPA_ONNX_CHECK_EQ(st, kBash) << "Invalid shell type."; |
| 252 | 252 |
| @@ -31,7 +31,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -31,7 +31,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 31 | return stop ? paComplete : paContinue; | 31 | return stop ? paComplete : paContinue; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | -static void Handler(int32_t sig) { | 34 | +static void Handler(int32_t /*sig*/) { |
| 35 | stop = true; | 35 | stop = true; |
| 36 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); | 36 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); |
| 37 | } | 37 | } |
| @@ -124,8 +124,6 @@ for a list of pre-trained models to download. | @@ -124,8 +124,6 @@ for a list of pre-trained models to download. | ||
| 124 | mic_sample_rate = atof(pSampleRateStr); | 124 | mic_sample_rate = atof(pSampleRateStr); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | - float sample_rate = 16000; | ||
| 128 | - | ||
| 129 | PaStream *stream; | 127 | PaStream *stream; |
| 130 | PaError err = | 128 | PaError err = |
| 131 | Pa_OpenStream(&stream, ¶m, nullptr, /* &outputParameters, */ | 129 | Pa_OpenStream(&stream, ¶m, nullptr, /* &outputParameters, */ |
| @@ -62,7 +62,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -62,7 +62,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 62 | unsigned long frames_per_buffer, // NOLINT | 62 | unsigned long frames_per_buffer, // NOLINT |
| 63 | const PaStreamCallbackTimeInfo * /*time_info*/, | 63 | const PaStreamCallbackTimeInfo * /*time_info*/, |
| 64 | PaStreamCallbackFlags /*status_flags*/, | 64 | PaStreamCallbackFlags /*status_flags*/, |
| 65 | - void *user_data) { | 65 | + void * /*user_data*/) { |
| 66 | std::lock_guard<std::mutex> lock(samples_mutex); | 66 | std::lock_guard<std::mutex> lock(samples_mutex); |
| 67 | 67 | ||
| 68 | auto p = reinterpret_cast<const float *>(input_buffer); | 68 | auto p = reinterpret_cast<const float *>(input_buffer); |
| @@ -71,7 +71,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -71,7 +71,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 71 | return stop ? paComplete : paContinue; | 71 | return stop ? paComplete : paContinue; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | -static void Handler(int32_t sig) { | 74 | +static void Handler(int32_t /*sig*/) { |
| 75 | stop = true; | 75 | stop = true; |
| 76 | fprintf(stderr, "\nCaught Ctrl + C. Press Enter to exit\n"); | 76 | fprintf(stderr, "\nCaught Ctrl + C. Press Enter to exit\n"); |
| 77 | } | 77 | } |
| @@ -165,8 +165,6 @@ for more models. | @@ -165,8 +165,6 @@ for more models. | ||
| 165 | mic_sample_rate = atof(pSampleRateStr); | 165 | mic_sample_rate = atof(pSampleRateStr); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | - float sample_rate = 16000; | ||
| 169 | - | ||
| 170 | PaStream *stream; | 168 | PaStream *stream; |
| 171 | PaError err = | 169 | PaError err = |
| 172 | Pa_OpenStream(&stream, ¶m, nullptr, /* &outputParameters, */ | 170 | Pa_OpenStream(&stream, ¶m, nullptr, /* &outputParameters, */ |
| @@ -62,7 +62,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -62,7 +62,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 62 | unsigned long frames_per_buffer, // NOLINT | 62 | unsigned long frames_per_buffer, // NOLINT |
| 63 | const PaStreamCallbackTimeInfo * /*time_info*/, | 63 | const PaStreamCallbackTimeInfo * /*time_info*/, |
| 64 | PaStreamCallbackFlags /*status_flags*/, | 64 | PaStreamCallbackFlags /*status_flags*/, |
| 65 | - void *user_data) { | 65 | + void * /*user_data*/) { |
| 66 | std::lock_guard<std::mutex> lock(samples_mutex); | 66 | std::lock_guard<std::mutex> lock(samples_mutex); |
| 67 | 67 | ||
| 68 | auto p = reinterpret_cast<const float *>(input_buffer); | 68 | auto p = reinterpret_cast<const float *>(input_buffer); |
| @@ -71,7 +71,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -71,7 +71,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 71 | return stop ? paComplete : paContinue; | 71 | return stop ? paComplete : paContinue; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | -static void Handler(int32_t sig) { | 74 | +static void Handler(int32_t /*sig*/) { |
| 75 | stop = true; | 75 | stop = true; |
| 76 | fprintf(stderr, "\nCaught Ctrl + C. Press Enter to exit\n"); | 76 | fprintf(stderr, "\nCaught Ctrl + C. Press Enter to exit\n"); |
| 77 | } | 77 | } |
| @@ -180,7 +180,6 @@ for a list of pre-trained models to download. | @@ -180,7 +180,6 @@ for a list of pre-trained models to download. | ||
| 180 | fprintf(stderr, "Use sample rate %f for mic\n", mic_sample_rate); | 180 | fprintf(stderr, "Use sample rate %f for mic\n", mic_sample_rate); |
| 181 | mic_sample_rate = atof(pSampleRateStr); | 181 | mic_sample_rate = atof(pSampleRateStr); |
| 182 | } | 182 | } |
| 183 | - float sample_rate = 16000; | ||
| 184 | 183 | ||
| 185 | PaStream *stream; | 184 | PaStream *stream; |
| 186 | PaError err = | 185 | PaError err = |
| @@ -33,7 +33,7 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -33,7 +33,7 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 33 | return stop ? paComplete : paContinue; | 33 | return stop ? paComplete : paContinue; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | -static void Handler(int32_t sig) { | 36 | +static void Handler(int32_t /*sig*/) { |
| 37 | stop = true; | 37 | stop = true; |
| 38 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); | 38 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); |
| 39 | } | 39 | } |
| @@ -85,7 +85,7 @@ void AsrInference(const std::vector<std::vector<std::string>> &chunk_wav_paths, | @@ -85,7 +85,7 @@ void AsrInference(const std::vector<std::vector<std::string>> &chunk_wav_paths, | ||
| 85 | 85 | ||
| 86 | while (true) { | 86 | while (true) { |
| 87 | int chunk = wav_index.fetch_add(1); | 87 | int chunk = wav_index.fetch_add(1); |
| 88 | - if (chunk >= chunk_wav_paths.size()) { | 88 | + if (chunk >= static_cast<int32_t>(chunk_wav_paths.size())) { |
| 89 | break; | 89 | break; |
| 90 | } | 90 | } |
| 91 | const auto &wav_paths = chunk_wav_paths[chunk]; | 91 | const auto &wav_paths = chunk_wav_paths[chunk]; |
| @@ -85,7 +85,7 @@ static int PlayCallback(const void * /*in*/, void *out, | @@ -85,7 +85,7 @@ static int PlayCallback(const void * /*in*/, void *out, | ||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | int32_t k = 0; | 87 | int32_t k = 0; |
| 88 | - for (; k < n && !g_buffer.samples.empty();) { | 88 | + for (; k < static_cast<int32_t>(n) && !g_buffer.samples.empty();) { |
| 89 | int32_t this_block = n - k; | 89 | int32_t this_block = n - k; |
| 90 | 90 | ||
| 91 | auto &p = g_buffer.samples.front(); | 91 | auto &p = g_buffer.samples.front(); |
| @@ -99,7 +99,7 @@ static int PlayCallback(const void * /*in*/, void *out, | @@ -99,7 +99,7 @@ static int PlayCallback(const void * /*in*/, void *out, | ||
| 99 | 99 | ||
| 100 | k = n; | 100 | k = n; |
| 101 | 101 | ||
| 102 | - if (p.consumed == p.data.size()) { | 102 | + if (p.consumed == static_cast<int32_t>(p.data.size())) { |
| 103 | g_buffer.samples.pop(); | 103 | g_buffer.samples.pop(); |
| 104 | } | 104 | } |
| 105 | break; | 105 | break; |
| @@ -110,7 +110,7 @@ static int PlayCallback(const void * /*in*/, void *out, | @@ -110,7 +110,7 @@ static int PlayCallback(const void * /*in*/, void *out, | ||
| 110 | g_buffer.samples.pop(); | 110 | g_buffer.samples.pop(); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | - if (k < n) { | 113 | + if (k < static_cast<int32_t>(n)) { |
| 114 | std::fill_n(pout + k, n - k, 0); | 114 | std::fill_n(pout + k, n - k, 0); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| @@ -121,7 +121,7 @@ static int PlayCallback(const void * /*in*/, void *out, | @@ -121,7 +121,7 @@ static int PlayCallback(const void * /*in*/, void *out, | ||
| 121 | return paContinue; | 121 | return paContinue; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | -static void PlayCallbackFinished(void *userData) { g_cv.notify_all(); } | 124 | +static void PlayCallbackFinished(void * /*userData*/) { g_cv.notify_all(); } |
| 125 | 125 | ||
| 126 | static void StartPlayback(int32_t sample_rate) { | 126 | static void StartPlayback(int32_t sample_rate) { |
| 127 | int32_t frames_per_buffer = 1024; | 127 | int32_t frames_per_buffer = 1024; |
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | #include "sherpa-onnx/csrc/parse-options.h" | 9 | #include "sherpa-onnx/csrc/parse-options.h" |
| 10 | #include "sherpa-onnx/csrc/wave-writer.h" | 10 | #include "sherpa-onnx/csrc/wave-writer.h" |
| 11 | 11 | ||
| 12 | -void audioCallback(const float *samples, int32_t n, float progress) { | 12 | +void audioCallback(const float * /*samples*/, int32_t n, float progress) { |
| 13 | printf("sample=%d, progress=%f\n", n, progress); | 13 | printf("sample=%d, progress=%f\n", n, progress); |
| 14 | } | 14 | } |
| 15 | 15 |
| @@ -25,14 +25,14 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -25,14 +25,14 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 25 | unsigned long frames_per_buffer, // NOLINT | 25 | unsigned long frames_per_buffer, // NOLINT |
| 26 | const PaStreamCallbackTimeInfo * /*time_info*/, | 26 | const PaStreamCallbackTimeInfo * /*time_info*/, |
| 27 | PaStreamCallbackFlags /*status_flags*/, | 27 | PaStreamCallbackFlags /*status_flags*/, |
| 28 | - void *user_data) { | 28 | + void * /*user_data*/) { |
| 29 | std::lock_guard<std::mutex> lock(mutex); | 29 | std::lock_guard<std::mutex> lock(mutex); |
| 30 | buffer.Push(reinterpret_cast<const float *>(input_buffer), frames_per_buffer); | 30 | buffer.Push(reinterpret_cast<const float *>(input_buffer), frames_per_buffer); |
| 31 | 31 | ||
| 32 | return stop ? paComplete : paContinue; | 32 | return stop ? paComplete : paContinue; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | -static void Handler(int32_t sig) { | 35 | +static void Handler(int32_t /*sig*/) { |
| 36 | stop = true; | 36 | stop = true; |
| 37 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); | 37 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); |
| 38 | } | 38 | } |
| @@ -25,14 +25,14 @@ static int32_t RecordCallback(const void *input_buffer, | @@ -25,14 +25,14 @@ static int32_t RecordCallback(const void *input_buffer, | ||
| 25 | unsigned long frames_per_buffer, // NOLINT | 25 | unsigned long frames_per_buffer, // NOLINT |
| 26 | const PaStreamCallbackTimeInfo * /*time_info*/, | 26 | const PaStreamCallbackTimeInfo * /*time_info*/, |
| 27 | PaStreamCallbackFlags /*status_flags*/, | 27 | PaStreamCallbackFlags /*status_flags*/, |
| 28 | - void *user_data) { | 28 | + void * /*user_data*/) { |
| 29 | std::lock_guard<std::mutex> lock(mutex); | 29 | std::lock_guard<std::mutex> lock(mutex); |
| 30 | buffer.Push(reinterpret_cast<const float *>(input_buffer), frames_per_buffer); | 30 | buffer.Push(reinterpret_cast<const float *>(input_buffer), frames_per_buffer); |
| 31 | 31 | ||
| 32 | return stop ? paComplete : paContinue; | 32 | return stop ? paComplete : paContinue; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | -static void Handler(int32_t sig) { | 35 | +static void Handler(int32_t /*sig*/) { |
| 36 | stop = true; | 36 | stop = true; |
| 37 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); | 37 | fprintf(stderr, "\nCaught Ctrl + C. Exiting...\n"); |
| 38 | } | 38 | } |
| @@ -26,8 +26,6 @@ Ort::Value Slice(OrtAllocator *allocator, const Ort::Value *v, | @@ -26,8 +26,6 @@ Ort::Value Slice(OrtAllocator *allocator, const Ort::Value *v, | ||
| 26 | assert(dim1_start < dim1_end); | 26 | assert(dim1_start < dim1_end); |
| 27 | assert(dim1_end <= shape[1]); | 27 | assert(dim1_end <= shape[1]); |
| 28 | 28 | ||
| 29 | - const T *src = v->GetTensorData<T>(); | ||
| 30 | - | ||
| 31 | std::array<int64_t, 3> ans_shape{dim0_end - dim0_start, dim1_end - dim1_start, | 29 | std::array<int64_t, 3> ans_shape{dim0_end - dim0_start, dim1_end - dim1_start, |
| 32 | shape[2]}; | 30 | shape[2]}; |
| 33 | 31 |
| @@ -50,7 +50,7 @@ class SpeakerEmbeddingManager::Impl { | @@ -50,7 +50,7 @@ class SpeakerEmbeddingManager::Impl { | ||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | for (const auto &x : embedding_list) { | 52 | for (const auto &x : embedding_list) { |
| 53 | - if (x.size() != dim_) { | 53 | + if (static_cast<int32_t>(x.size()) != dim_) { |
| 54 | SHERPA_ONNX_LOGE("Given dim: %d, expected dim: %d", | 54 | SHERPA_ONNX_LOGE("Given dim: %d, expected dim: %d", |
| 55 | static_cast<int32_t>(x.size()), dim_); | 55 | static_cast<int32_t>(x.size()), dim_); |
| 56 | return false; | 56 | return false; |
| @@ -224,7 +224,7 @@ bool SpeakerEmbeddingManager::Verify(const std::string &name, const float *p, | @@ -224,7 +224,7 @@ bool SpeakerEmbeddingManager::Verify(const std::string &name, const float *p, | ||
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | float SpeakerEmbeddingManager::Score(const std::string &name, | 226 | float SpeakerEmbeddingManager::Score(const std::string &name, |
| 227 | - const float *p) const { | 227 | + const float *p) const { |
| 228 | return impl_->Score(name, p); | 228 | return impl_->Score(name, p); |
| 229 | } | 229 | } |
| 230 | 230 |
| @@ -58,7 +58,7 @@ std::vector<Ort::Value> Unbind(OrtAllocator *allocator, const Ort::Value *value, | @@ -58,7 +58,7 @@ std::vector<Ort::Value> Unbind(OrtAllocator *allocator, const Ort::Value *value, | ||
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | - return std::move(ans); | 61 | + return ans; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | template std::vector<Ort::Value> Unbind<float>(OrtAllocator *allocator, | 64 | template std::vector<Ort::Value> Unbind<float>(OrtAllocator *allocator, |
| @@ -161,7 +161,7 @@ std::vector<float> ReadWaveImpl(std::istream &is, int32_t *sampling_rate, | @@ -161,7 +161,7 @@ std::vector<float> ReadWaveImpl(std::istream &is, int32_t *sampling_rate, | ||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | std::vector<float> ans(samples.size()); | 163 | std::vector<float> ans(samples.size()); |
| 164 | - for (int32_t i = 0; i != ans.size(); ++i) { | 164 | + for (int32_t i = 0; i != static_cast<int32_t>(ans.size()); ++i) { |
| 165 | ans[i] = samples[i] / 32768.; | 165 | ans[i] = samples[i] / 32768.; |
| 166 | } | 166 | } |
| 167 | 167 |
| @@ -146,13 +146,13 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_newFromFile( | @@ -146,13 +146,13 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_newFromFile( | ||
| 146 | 146 | ||
| 147 | SHERPA_ONNX_EXTERN_C | 147 | SHERPA_ONNX_EXTERN_C |
| 148 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_delete( | 148 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_delete( |
| 149 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 149 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 150 | delete reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); | 150 | delete reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | SHERPA_ONNX_EXTERN_C | 153 | SHERPA_ONNX_EXTERN_C |
| 154 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_decode( | 154 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_decode( |
| 155 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 155 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 156 | auto kws = reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); | 156 | auto kws = reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); |
| 157 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 157 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 158 | 158 | ||
| @@ -185,7 +185,7 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_createStream( | @@ -185,7 +185,7 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_createStream( | ||
| 185 | 185 | ||
| 186 | SHERPA_ONNX_EXTERN_C | 186 | SHERPA_ONNX_EXTERN_C |
| 187 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_isReady( | 187 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_KeywordSpotter_isReady( |
| 188 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 188 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 189 | auto kws = reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); | 189 | auto kws = reinterpret_cast<sherpa_onnx::KeywordSpotter *>(ptr); |
| 190 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 190 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 191 | 191 |
| @@ -86,7 +86,7 @@ Java_com_k2fsa_sherpa_onnx_OfflinePunctuation_newFromFile(JNIEnv *env, | @@ -86,7 +86,7 @@ Java_com_k2fsa_sherpa_onnx_OfflinePunctuation_newFromFile(JNIEnv *env, | ||
| 86 | 86 | ||
| 87 | SHERPA_ONNX_EXTERN_C | 87 | SHERPA_ONNX_EXTERN_C |
| 88 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflinePunctuation_delete( | 88 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflinePunctuation_delete( |
| 89 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 89 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 90 | delete reinterpret_cast<sherpa_onnx::OfflinePunctuation *>(ptr); | 90 | delete reinterpret_cast<sherpa_onnx::OfflinePunctuation *>(ptr); |
| 91 | } | 91 | } |
| 92 | 92 |
| @@ -220,13 +220,13 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_newFromFile(JNIEnv *env, | @@ -220,13 +220,13 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_newFromFile(JNIEnv *env, | ||
| 220 | 220 | ||
| 221 | SHERPA_ONNX_EXTERN_C | 221 | SHERPA_ONNX_EXTERN_C |
| 222 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_delete( | 222 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_delete( |
| 223 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 223 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 224 | delete reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); | 224 | delete reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | SHERPA_ONNX_EXTERN_C | 227 | SHERPA_ONNX_EXTERN_C |
| 228 | JNIEXPORT jlong JNICALL | 228 | JNIEXPORT jlong JNICALL |
| 229 | -Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_createStream(JNIEnv *env, | 229 | +Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_createStream(JNIEnv * /*env*/, |
| 230 | jobject /*obj*/, | 230 | jobject /*obj*/, |
| 231 | jlong ptr) { | 231 | jlong ptr) { |
| 232 | auto recognizer = reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); | 232 | auto recognizer = reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); |
| @@ -242,7 +242,7 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_createStream(JNIEnv *env, | @@ -242,7 +242,7 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_createStream(JNIEnv *env, | ||
| 242 | 242 | ||
| 243 | SHERPA_ONNX_EXTERN_C | 243 | SHERPA_ONNX_EXTERN_C |
| 244 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_decode( | 244 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_decode( |
| 245 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong streamPtr) { | 245 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong streamPtr) { |
| 246 | auto recognizer = reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); | 246 | auto recognizer = reinterpret_cast<sherpa_onnx::OfflineRecognizer *>(ptr); |
| 247 | auto stream = reinterpret_cast<sherpa_onnx::OfflineStream *>(streamPtr); | 247 | auto stream = reinterpret_cast<sherpa_onnx::OfflineStream *>(streamPtr); |
| 248 | 248 |
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | SHERPA_ONNX_EXTERN_C | 9 | SHERPA_ONNX_EXTERN_C |
| 10 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineStream_delete( | 10 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineStream_delete( |
| 11 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 11 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 12 | delete reinterpret_cast<sherpa_onnx::OfflineStream *>(ptr); | 12 | delete reinterpret_cast<sherpa_onnx::OfflineStream *>(ptr); |
| 13 | } | 13 | } |
| 14 | 14 |
| @@ -136,19 +136,19 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_newFromFile( | @@ -136,19 +136,19 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_newFromFile( | ||
| 136 | 136 | ||
| 137 | SHERPA_ONNX_EXTERN_C | 137 | SHERPA_ONNX_EXTERN_C |
| 138 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_delete( | 138 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_delete( |
| 139 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 139 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 140 | delete reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr); | 140 | delete reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | SHERPA_ONNX_EXTERN_C | 143 | SHERPA_ONNX_EXTERN_C |
| 144 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getSampleRate( | 144 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getSampleRate( |
| 145 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 145 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 146 | return reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr)->SampleRate(); | 146 | return reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr)->SampleRate(); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | SHERPA_ONNX_EXTERN_C | 149 | SHERPA_ONNX_EXTERN_C |
| 150 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getNumSpeakers( | 150 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_OfflineTts_getNumSpeakers( |
| 151 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 151 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 152 | return reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr)->NumSpeakers(); | 152 | return reinterpret_cast<sherpa_onnx::OfflineTts *>(ptr)->NumSpeakers(); |
| 153 | } | 153 | } |
| 154 | 154 |
| @@ -284,13 +284,13 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_newFromFile( | @@ -284,13 +284,13 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_newFromFile( | ||
| 284 | 284 | ||
| 285 | SHERPA_ONNX_EXTERN_C | 285 | SHERPA_ONNX_EXTERN_C |
| 286 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_delete( | 286 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_delete( |
| 287 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 287 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 288 | delete reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); | 288 | delete reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | SHERPA_ONNX_EXTERN_C | 291 | SHERPA_ONNX_EXTERN_C |
| 292 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_reset( | 292 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_reset( |
| 293 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 293 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 294 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); | 294 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); |
| 295 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 295 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 296 | recognizer->Reset(stream); | 296 | recognizer->Reset(stream); |
| @@ -298,7 +298,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_reset( | @@ -298,7 +298,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_reset( | ||
| 298 | 298 | ||
| 299 | SHERPA_ONNX_EXTERN_C | 299 | SHERPA_ONNX_EXTERN_C |
| 300 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isReady( | 300 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isReady( |
| 301 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 301 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 302 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); | 302 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); |
| 303 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 303 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 304 | 304 | ||
| @@ -307,7 +307,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isReady( | @@ -307,7 +307,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isReady( | ||
| 307 | 307 | ||
| 308 | SHERPA_ONNX_EXTERN_C | 308 | SHERPA_ONNX_EXTERN_C |
| 309 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isEndpoint( | 309 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isEndpoint( |
| 310 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 310 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 311 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); | 311 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); |
| 312 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 312 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 313 | 313 | ||
| @@ -316,7 +316,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isEndpoint( | @@ -316,7 +316,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_isEndpoint( | ||
| 316 | 316 | ||
| 317 | SHERPA_ONNX_EXTERN_C | 317 | SHERPA_ONNX_EXTERN_C |
| 318 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_decode( | 318 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_decode( |
| 319 | - JNIEnv *env, jobject /*obj*/, jlong ptr, jlong stream_ptr) { | 319 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr, jlong stream_ptr) { |
| 320 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); | 320 | auto recognizer = reinterpret_cast<sherpa_onnx::OnlineRecognizer *>(ptr); |
| 321 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); | 321 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(stream_ptr); |
| 322 | 322 |
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | SHERPA_ONNX_EXTERN_C | 9 | SHERPA_ONNX_EXTERN_C |
| 10 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_delete( | 10 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_delete( |
| 11 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 11 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 12 | delete reinterpret_cast<sherpa_onnx::OnlineStream *>(ptr); | 12 | delete reinterpret_cast<sherpa_onnx::OnlineStream *>(ptr); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| @@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_acceptWaveform( | @@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_acceptWaveform( | ||
| 26 | 26 | ||
| 27 | SHERPA_ONNX_EXTERN_C | 27 | SHERPA_ONNX_EXTERN_C |
| 28 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_inputFinished( | 28 | JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_OnlineStream_inputFinished( |
| 29 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 29 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 30 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(ptr); | 30 | auto stream = reinterpret_cast<sherpa_onnx::OnlineStream *>(ptr); |
| 31 | stream->InputFinished(); | 31 | stream->InputFinished(); |
| 32 | } | 32 | } |
| @@ -77,7 +77,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_newFromFile( | @@ -77,7 +77,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_newFromFile( | ||
| 77 | 77 | ||
| 78 | SHERPA_ONNX_EXTERN_C | 78 | SHERPA_ONNX_EXTERN_C |
| 79 | JNIEXPORT void JNICALL | 79 | JNIEXPORT void JNICALL |
| 80 | -Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_delete(JNIEnv *env, | 80 | +Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_delete(JNIEnv * /*env*/, |
| 81 | jobject /*obj*/, | 81 | jobject /*obj*/, |
| 82 | jlong ptr) { | 82 | jlong ptr) { |
| 83 | delete reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr); | 83 | delete reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr); |
| @@ -86,7 +86,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_delete(JNIEnv *env, | @@ -86,7 +86,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_delete(JNIEnv *env, | ||
| 86 | SHERPA_ONNX_EXTERN_C | 86 | SHERPA_ONNX_EXTERN_C |
| 87 | JNIEXPORT jlong JNICALL | 87 | JNIEXPORT jlong JNICALL |
| 88 | Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_createStream( | 88 | Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_createStream( |
| 89 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 89 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 90 | std::unique_ptr<sherpa_onnx::OnlineStream> s = | 90 | std::unique_ptr<sherpa_onnx::OnlineStream> s = |
| 91 | reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr) | 91 | reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr) |
| 92 | ->CreateStream(); | 92 | ->CreateStream(); |
| @@ -101,7 +101,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_createStream( | @@ -101,7 +101,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_createStream( | ||
| 101 | 101 | ||
| 102 | SHERPA_ONNX_EXTERN_C | 102 | SHERPA_ONNX_EXTERN_C |
| 103 | JNIEXPORT jboolean JNICALL | 103 | JNIEXPORT jboolean JNICALL |
| 104 | -Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_isReady(JNIEnv *env, | 104 | +Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_isReady(JNIEnv * /*env*/, |
| 105 | jobject /*obj*/, | 105 | jobject /*obj*/, |
| 106 | jlong ptr, | 106 | jlong ptr, |
| 107 | jlong stream_ptr) { | 107 | jlong stream_ptr) { |
| @@ -130,7 +130,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_compute(JNIEnv *env, | @@ -130,7 +130,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_compute(JNIEnv *env, | ||
| 130 | 130 | ||
| 131 | SHERPA_ONNX_EXTERN_C | 131 | SHERPA_ONNX_EXTERN_C |
| 132 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_dim( | 132 | JNIEXPORT jint JNICALL Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingExtractor_dim( |
| 133 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 133 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 134 | auto extractor = | 134 | auto extractor = |
| 135 | reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr); | 135 | reinterpret_cast<sherpa_onnx::SpeakerEmbeddingExtractor *>(ptr); |
| 136 | return extractor->Dim(); | 136 | return extractor->Dim(); |
| @@ -17,7 +17,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_create(JNIEnv *env, | @@ -17,7 +17,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_create(JNIEnv *env, | ||
| 17 | 17 | ||
| 18 | SHERPA_ONNX_EXTERN_C | 18 | SHERPA_ONNX_EXTERN_C |
| 19 | JNIEXPORT void JNICALL | 19 | JNIEXPORT void JNICALL |
| 20 | -Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_delete(JNIEnv *env, | 20 | +Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_delete(JNIEnv * /*env*/, |
| 21 | jobject /*obj*/, | 21 | jobject /*obj*/, |
| 22 | jlong ptr) { | 22 | jlong ptr) { |
| 23 | auto manager = reinterpret_cast<sherpa_onnx::SpeakerEmbeddingManager *>(ptr); | 23 | auto manager = reinterpret_cast<sherpa_onnx::SpeakerEmbeddingManager *>(ptr); |
| @@ -178,7 +178,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_contains(JNIEnv *env, | @@ -178,7 +178,7 @@ Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_contains(JNIEnv *env, | ||
| 178 | 178 | ||
| 179 | SHERPA_ONNX_EXTERN_C | 179 | SHERPA_ONNX_EXTERN_C |
| 180 | JNIEXPORT jint JNICALL | 180 | JNIEXPORT jint JNICALL |
| 181 | -Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_numSpeakers(JNIEnv *env, | 181 | +Java_com_k2fsa_sherpa_onnx_SpeakerEmbeddingManager_numSpeakers(JNIEnv * /*env*/, |
| 182 | jobject /*obj*/, | 182 | jobject /*obj*/, |
| 183 | jlong ptr) { | 183 | jlong ptr) { |
| 184 | auto manager = reinterpret_cast<sherpa_onnx::SpeakerEmbeddingManager *>(ptr); | 184 | auto manager = reinterpret_cast<sherpa_onnx::SpeakerEmbeddingManager *>(ptr); |
| @@ -101,7 +101,7 @@ Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_newFromFile( | @@ -101,7 +101,7 @@ Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_newFromFile( | ||
| 101 | 101 | ||
| 102 | SHERPA_ONNX_EXTERN_C | 102 | SHERPA_ONNX_EXTERN_C |
| 103 | JNIEXPORT void JNICALL | 103 | JNIEXPORT void JNICALL |
| 104 | -Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_delete(JNIEnv *env, | 104 | +Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_delete(JNIEnv * /*env*/, |
| 105 | jobject /*obj*/, | 105 | jobject /*obj*/, |
| 106 | jlong ptr) { | 106 | jlong ptr) { |
| 107 | delete reinterpret_cast<sherpa_onnx::SpokenLanguageIdentification *>(ptr); | 107 | delete reinterpret_cast<sherpa_onnx::SpokenLanguageIdentification *>(ptr); |
| @@ -110,7 +110,7 @@ Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_delete(JNIEnv *env, | @@ -110,7 +110,7 @@ Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_delete(JNIEnv *env, | ||
| 110 | SHERPA_ONNX_EXTERN_C | 110 | SHERPA_ONNX_EXTERN_C |
| 111 | JNIEXPORT jlong JNICALL | 111 | JNIEXPORT jlong JNICALL |
| 112 | Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_createStream( | 112 | Java_com_k2fsa_sherpa_onnx_SpokenLanguageIdentification_createStream( |
| 113 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 113 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 114 | auto slid = | 114 | auto slid = |
| 115 | reinterpret_cast<sherpa_onnx::SpokenLanguageIdentification *>(ptr); | 115 | reinterpret_cast<sherpa_onnx::SpokenLanguageIdentification *>(ptr); |
| 116 | std::unique_ptr<sherpa_onnx::OfflineStream> s = slid->CreateStream(); | 116 | std::unique_ptr<sherpa_onnx::OfflineStream> s = slid->CreateStream(); |
| @@ -97,7 +97,7 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_Vad_newFromFile( | @@ -97,7 +97,7 @@ JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_Vad_newFromFile( | ||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | SHERPA_ONNX_EXTERN_C | 99 | SHERPA_ONNX_EXTERN_C |
| 100 | -JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_delete(JNIEnv *env, | 100 | +JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_delete(JNIEnv * /*env*/, |
| 101 | jobject /*obj*/, | 101 | jobject /*obj*/, |
| 102 | jlong ptr) { | 102 | jlong ptr) { |
| 103 | delete reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 103 | delete reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| @@ -117,7 +117,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_acceptWaveform( | @@ -117,7 +117,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_acceptWaveform( | ||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | SHERPA_ONNX_EXTERN_C | 119 | SHERPA_ONNX_EXTERN_C |
| 120 | -JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_empty(JNIEnv *env, | 120 | +JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_empty(JNIEnv * /*env*/, |
| 121 | jobject /*obj*/, | 121 | jobject /*obj*/, |
| 122 | jlong ptr) { | 122 | jlong ptr) { |
| 123 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 123 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| @@ -125,7 +125,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_empty(JNIEnv *env, | @@ -125,7 +125,7 @@ JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_empty(JNIEnv *env, | ||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | SHERPA_ONNX_EXTERN_C | 127 | SHERPA_ONNX_EXTERN_C |
| 128 | -JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_pop(JNIEnv *env, | 128 | +JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_pop(JNIEnv * /*env*/, |
| 129 | jobject /*obj*/, | 129 | jobject /*obj*/, |
| 130 | jlong ptr) { | 130 | jlong ptr) { |
| 131 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 131 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| @@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_pop(JNIEnv *env, | @@ -133,7 +133,7 @@ JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_pop(JNIEnv *env, | ||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | SHERPA_ONNX_EXTERN_C | 135 | SHERPA_ONNX_EXTERN_C |
| 136 | -JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_clear(JNIEnv *env, | 136 | +JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_clear(JNIEnv * /*env*/, |
| 137 | jobject /*obj*/, | 137 | jobject /*obj*/, |
| 138 | jlong ptr) { | 138 | jlong ptr) { |
| 139 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 139 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| @@ -161,13 +161,13 @@ Java_com_k2fsa_sherpa_onnx_Vad_front(JNIEnv *env, jobject /*obj*/, jlong ptr) { | @@ -161,13 +161,13 @@ Java_com_k2fsa_sherpa_onnx_Vad_front(JNIEnv *env, jobject /*obj*/, jlong ptr) { | ||
| 161 | 161 | ||
| 162 | SHERPA_ONNX_EXTERN_C | 162 | SHERPA_ONNX_EXTERN_C |
| 163 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_isSpeechDetected( | 163 | JNIEXPORT bool JNICALL Java_com_k2fsa_sherpa_onnx_Vad_isSpeechDetected( |
| 164 | - JNIEnv *env, jobject /*obj*/, jlong ptr) { | 164 | + JNIEnv * /*env*/, jobject /*obj*/, jlong ptr) { |
| 165 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 165 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| 166 | return model->IsSpeechDetected(); | 166 | return model->IsSpeechDetected(); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | SHERPA_ONNX_EXTERN_C | 169 | SHERPA_ONNX_EXTERN_C |
| 170 | -JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_reset(JNIEnv *env, | 170 | +JNIEXPORT void JNICALL Java_com_k2fsa_sherpa_onnx_Vad_reset(JNIEnv * /*env*/, |
| 171 | jobject /*obj*/, | 171 | jobject /*obj*/, |
| 172 | jlong ptr) { | 172 | jlong ptr) { |
| 173 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); | 173 | auto model = reinterpret_cast<sherpa_onnx::VoiceActivityDetector *>(ptr); |
| @@ -63,7 +63,11 @@ if(APPLE) | @@ -63,7 +63,11 @@ if(APPLE) | ||
| 63 | OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_DIR | 63 | OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_DIR |
| 64 | ) | 64 | ) |
| 65 | message(STATUS "PYTHON_SITE_PACKAGE_DIR: ${PYTHON_SITE_PACKAGE_DIR}") | 65 | message(STATUS "PYTHON_SITE_PACKAGE_DIR: ${PYTHON_SITE_PACKAGE_DIR}") |
| 66 | - target_link_libraries(_sherpa_onnx PRIVATE "-Wl,-rpath,${PYTHON_SITE_PACKAGE_DIR}") | 66 | + if(PYTHON_SITE_PACKAGE_DIR STREQUAL "") |
| 67 | + message(WARNING "PYTHON_SITE_PACKAGE_DIR is empty!") | ||
| 68 | + else() | ||
| 69 | + target_link_libraries(_sherpa_onnx PRIVATE "-Wl,-rpath,${PYTHON_SITE_PACKAGE_DIR}") | ||
| 70 | + endif() | ||
| 67 | endif() | 71 | endif() |
| 68 | 72 | ||
| 69 | if(NOT WIN32) | 73 | if(NOT WIN32) |
-
请 注册 或 登录 后发表评论