Committed by
GitHub
Publish flutter packages for Android (#1074)
正在显示
117 个修改的文件
包含
628 行增加
和
7559 行删除
| @@ -14,10 +14,11 @@ concurrency: | @@ -14,10 +14,11 @@ concurrency: | ||
| 14 | cancel-in-progress: true | 14 | cancel-in-progress: true |
| 15 | 15 | ||
| 16 | jobs: | 16 | jobs: |
| 17 | - release_dart: | 17 | + sherpa_onnx_linux: |
| 18 | + # if: false | ||
| 18 | permissions: | 19 | permissions: |
| 19 | id-token: write # Required for authentication using OIDC | 20 | id-token: write # Required for authentication using OIDC |
| 20 | - name: Release dart | 21 | + name: sherpa_onnx_linux |
| 21 | runs-on: ubuntu-latest | 22 | runs-on: ubuntu-latest |
| 22 | 23 | ||
| 23 | steps: | 24 | steps: |
| @@ -31,21 +32,470 @@ jobs: | @@ -31,21 +32,470 @@ jobs: | ||
| 31 | 32 | ||
| 32 | - uses: dart-lang/setup-dart@v1 | 33 | - uses: dart-lang/setup-dart@v1 |
| 33 | 34 | ||
| 34 | - - name: Copy pre-build libs | 35 | + - name: Fix version |
| 35 | shell: bash | 36 | shell: bash |
| 36 | run: | | 37 | run: | |
| 37 | - cd scripts/dart | ||
| 38 | - ./release.sh | ||
| 39 | - cd ../.. | 38 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) |
| 40 | 39 | ||
| 41 | - mv -v sherpa-onnx/flutter /tmp/to-be-published | 40 | + src_dir=$PWD/flutter/sherpa_onnx_linux |
| 41 | + pushd $src_dir | ||
| 42 | + v="version: $SHERPA_ONNX_VERSION" | ||
| 43 | + echo "v: $v" | ||
| 44 | + sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml | ||
| 45 | + rm *.bak | ||
| 46 | + git status | ||
| 47 | + git diff | ||
| 42 | 48 | ||
| 43 | - cp -v README.md /tmp/to-be-published | 49 | + - name: Copy extra files |
| 50 | + shell: bash | ||
| 51 | + run: | | ||
| 52 | + dst=flutter/sherpa_onnx_linux | ||
| 53 | + | ||
| 54 | + mkdir $dst/example | ||
| 55 | + | ||
| 56 | + cp -v flutter/sherpa_onnx/example/* $dst/example | ||
| 57 | + cp -v LICENSE $dst/ | ||
| 58 | + cp -v CHANGELOG.md $dst/ | ||
| 59 | + | ||
| 60 | + git status | ||
| 61 | + | ||
| 62 | + - name: Build sherpa-onnx | ||
| 63 | + uses: addnab/docker-run-action@v3 | ||
| 64 | + with: | ||
| 65 | + image: quay.io/pypa/manylinux2014_x86_64 | ||
| 66 | + options: | | ||
| 67 | + --volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx | ||
| 68 | + shell: bash | ||
| 69 | + run: | | ||
| 70 | + uname -a | ||
| 71 | + gcc --version | ||
| 72 | + cmake --version | ||
| 73 | + cat /etc/*release | ||
| 74 | + id | ||
| 75 | + pwd | ||
| 76 | + | ||
| 77 | + cd /home/runner/work/sherpa-onnx/sherpa-onnx | ||
| 78 | + | ||
| 79 | + mkdir build | ||
| 80 | + cd build | ||
| 81 | + | ||
| 82 | + cmake \ | ||
| 83 | + -D SHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 84 | + -D SHERPA_ONNX_ENABLE_TTS=ON \ | ||
| 85 | + -D CMAKE_BUILD_TYPE=Release \ | ||
| 86 | + -D BUILD_SHARED_LIBS=ON \ | ||
| 87 | + -D CMAKE_INSTALL_PREFIX=./install \ | ||
| 88 | + -D SHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 89 | + -D SHERPA_ONNX_ENABLE_BINARY=OFF \ | ||
| 90 | + .. | ||
| 91 | + | ||
| 92 | + make -j2 | ||
| 93 | + make install | ||
| 94 | + | ||
| 95 | + ls -lh ./install/lib | ||
| 96 | + | ||
| 97 | + - name: Copy pre-built libs | ||
| 98 | + shell: bash | ||
| 99 | + run: | | ||
| 100 | + cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/ | ||
| 101 | + pushd flutter/sherpa_onnx_linux/linux/ | ||
| 102 | + | ||
| 103 | + rm libonnxruntime.so | ||
| 104 | + ln -s libonnxruntime.so.* ./libonnxruntime.so | ||
| 105 | + | ||
| 106 | + popd | ||
| 107 | + | ||
| 108 | + mv -v flutter/sherpa_onnx_linux /tmp/to_be_published | ||
| 109 | + | ||
| 110 | + ls -lh /tmp/to_be_published/linux | ||
| 111 | + | ||
| 112 | + - name: Release | ||
| 113 | + shell: bash | ||
| 114 | + run: | | ||
| 115 | + cd /tmp/to_be_published | ||
| 116 | + flutter pub get | ||
| 117 | + flutter pub publish --dry-run | ||
| 118 | + flutter pub publish --force | ||
| 119 | + | ||
| 120 | + sherpa_onnx_macos: | ||
| 121 | + # if: false | ||
| 122 | + permissions: | ||
| 123 | + id-token: write # Required for authentication using OIDC | ||
| 124 | + name: sherpa_onnx_macos | ||
| 125 | + runs-on: macos-latest | ||
| 126 | + | ||
| 127 | + steps: | ||
| 128 | + - uses: actions/checkout@v4 | ||
| 129 | + | ||
| 130 | + - name: ccache | ||
| 131 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 132 | + with: | ||
| 133 | + key: ${{ matrix.os }}-flutter-release-package | ||
| 134 | + | ||
| 135 | + - name: Setup Flutter SDK | ||
| 136 | + uses: flutter-actions/setup-flutter@v3 | ||
| 137 | + with: | ||
| 138 | + channel: stable | ||
| 139 | + version: latest | ||
| 140 | + | ||
| 141 | + - uses: dart-lang/setup-dart@v1 | ||
| 142 | + | ||
| 143 | + - name: Fix version | ||
| 144 | + shell: bash | ||
| 145 | + run: | | ||
| 146 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 147 | + | ||
| 148 | + src_dir=$PWD/flutter/sherpa_onnx_macos | ||
| 149 | + pushd $src_dir | ||
| 150 | + v="version: $SHERPA_ONNX_VERSION" | ||
| 151 | + echo "v: $v" | ||
| 152 | + sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml | ||
| 153 | + rm *.bak | ||
| 154 | + git status | ||
| 155 | + git diff | ||
| 156 | + | ||
| 157 | + - name: Copy extra files | ||
| 158 | + shell: bash | ||
| 159 | + run: | | ||
| 160 | + dst=flutter/sherpa_onnx_macos | ||
| 161 | + | ||
| 162 | + mkdir $dst/example | ||
| 163 | + | ||
| 164 | + cp -v flutter/sherpa_onnx/example/* $dst/example | ||
| 165 | + cp -v LICENSE $dst/ | ||
| 166 | + cp -v CHANGELOG.md $dst/ | ||
| 167 | + | ||
| 168 | + git status | ||
| 169 | + | ||
| 170 | + - name: Configure CMake | ||
| 171 | + shell: bash | ||
| 172 | + run: | | ||
| 173 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 174 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 175 | + cmake --version | ||
| 176 | + | ||
| 177 | + mkdir build | ||
| 178 | + cd build | ||
| 179 | + cmake \ | ||
| 180 | + -D SHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 181 | + -D SHERPA_ONNX_ENABLE_TTS=ON \ | ||
| 182 | + -D CMAKE_BUILD_TYPE=Release \ | ||
| 183 | + -D BUILD_SHARED_LIBS=ON \ | ||
| 184 | + -D CMAKE_INSTALL_PREFIX=./install \ | ||
| 185 | + -D SHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 186 | + -D SHERPA_ONNX_ENABLE_BINARY=OFF \ | ||
| 187 | + -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ | ||
| 188 | + .. | ||
| 189 | + | ||
| 190 | + - name: Build sherpa-onnx | ||
| 191 | + shell: bash | ||
| 192 | + run: | | ||
| 193 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 194 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 195 | + cmake --version | ||
| 196 | + | ||
| 197 | + cd build | ||
| 198 | + make -j2 install | ||
| 199 | + | ||
| 200 | + ls -lh install/lib/libsherpa-onnx-core.dylib | ||
| 201 | + file install/lib/libsherpa-onnx-core.dylib | ||
| 202 | + | ||
| 203 | + - name: Copy pre-built libs | ||
| 204 | + shell: bash | ||
| 205 | + run: | | ||
| 206 | + cp -v build/install/lib/lib*.dylib* flutter/sherpa_onnx_macos/macos/ | ||
| 207 | + | ||
| 208 | + | ||
| 209 | + mv -v flutter/sherpa_onnx_macos /tmp/to_be_published | ||
| 210 | + | ||
| 211 | + ls -lh /tmp/to_be_published/macos | ||
| 212 | + | ||
| 213 | + pushd /tmp/to_be_published/macos | ||
| 214 | + | ||
| 215 | + rm libonnxruntime.dylib | ||
| 216 | + | ||
| 217 | + ls -lh | ||
| 218 | + | ||
| 219 | + popd | ||
| 220 | + | ||
| 221 | + - name: Release | ||
| 222 | + shell: bash | ||
| 223 | + run: | | ||
| 224 | + cd /tmp/to_be_published | ||
| 225 | + du -h -d1 . | ||
| 226 | + flutter pub get | ||
| 227 | + flutter pub publish --dry-run | ||
| 228 | + flutter pub publish --force | ||
| 229 | + | ||
| 230 | + sherpa_onnx_windows: | ||
| 231 | + # if: false | ||
| 232 | + permissions: | ||
| 233 | + id-token: write # Required for authentication using OIDC | ||
| 234 | + name: sherpa_onnx_windows | ||
| 235 | + runs-on: windows-2019 | ||
| 236 | + | ||
| 237 | + steps: | ||
| 238 | + - uses: actions/checkout@v4 | ||
| 239 | + | ||
| 240 | + - name: Fix version | ||
| 241 | + shell: bash | ||
| 242 | + run: | | ||
| 243 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 244 | + | ||
| 245 | + src_dir=$PWD/flutter/sherpa_onnx_windows | ||
| 246 | + pushd $src_dir | ||
| 247 | + v="version: $SHERPA_ONNX_VERSION" | ||
| 248 | + echo "v: $v" | ||
| 249 | + sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml | ||
| 250 | + rm *.bak | ||
| 251 | + git status | ||
| 252 | + git diff | ||
| 253 | + | ||
| 254 | + - name: Copy extra files | ||
| 255 | + shell: bash | ||
| 256 | + run: | | ||
| 257 | + dst=flutter/sherpa_onnx_windows | ||
| 258 | + | ||
| 259 | + mkdir $dst/example | ||
| 260 | + | ||
| 261 | + cp -v flutter/sherpa_onnx/example/* $dst/example | ||
| 262 | + cp -v LICENSE $dst/ | ||
| 263 | + cp -v CHANGELOG.md $dst/ | ||
| 264 | + | ||
| 265 | + git status | ||
| 266 | + | ||
| 267 | + - name: Configure CMake | ||
| 268 | + shell: bash | ||
| 269 | + run: | | ||
| 270 | + mkdir build | ||
| 271 | + cd build | ||
| 272 | + cmake \ | ||
| 273 | + -D SHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
| 274 | + -D SHERPA_ONNX_ENABLE_TTS=ON \ | ||
| 275 | + -D CMAKE_BUILD_TYPE=Release \ | ||
| 276 | + -D BUILD_SHARED_LIBS=ON \ | ||
| 277 | + -D CMAKE_INSTALL_PREFIX=./install \ | ||
| 278 | + -D SHERPA_ONNX_ENABLE_JNI=OFF \ | ||
| 279 | + -D SHERPA_ONNX_ENABLE_BINARY=OFF \ | ||
| 280 | + .. | ||
| 281 | + | ||
| 282 | + - name: Build sherpa-onnx | ||
| 283 | + shell: bash | ||
| 284 | + run: | | ||
| 285 | + cd build | ||
| 286 | + cmake --build . --target install --config Release | ||
| 287 | + | ||
| 288 | + ls -lh install/lib/*.dll | ||
| 289 | + | ||
| 290 | + - name: Copy pre-built libs | ||
| 291 | + shell: bash | ||
| 292 | + run: | | ||
| 293 | + cp -v build/install/lib/*.dll flutter/sherpa_onnx_windows/windows/ | ||
| 294 | + mv -v flutter/sherpa_onnx_windows /tmp/to_be_published | ||
| 295 | + | ||
| 296 | + ls -lh /tmp/to_be_published/windows | ||
| 297 | + | ||
| 298 | + - name: Setup Flutter SDK | ||
| 299 | + uses: flutter-actions/setup-flutter@v3 | ||
| 300 | + with: | ||
| 301 | + channel: stable | ||
| 302 | + version: latest | ||
| 303 | + | ||
| 304 | + - uses: dart-lang/setup-dart@v1 | ||
| 44 | 305 | ||
| 45 | - name: Release | 306 | - name: Release |
| 46 | shell: bash | 307 | shell: bash |
| 47 | run: | | 308 | run: | |
| 48 | - cd /tmp/to-be-published | 309 | + cd /tmp/to_be_published |
| 310 | + flutter pub get | ||
| 311 | + flutter pub publish --dry-run | ||
| 312 | + flutter pub publish --force | ||
| 313 | + | ||
| 314 | + sherpa_onnx_android: | ||
| 315 | + # if: false | ||
| 316 | + permissions: | ||
| 317 | + id-token: write # Required for authentication using OIDC | ||
| 318 | + name: sherpa_onnx_android | ||
| 319 | + runs-on: ubuntu-latest | ||
| 320 | + | ||
| 321 | + steps: | ||
| 322 | + - uses: actions/checkout@v4 | ||
| 323 | + | ||
| 324 | + - name: ccache | ||
| 325 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 326 | + with: | ||
| 327 | + key: ${{ matrix.os }}-flutter-release-package-android | ||
| 328 | + | ||
| 329 | + - name: Fix version | ||
| 330 | + shell: bash | ||
| 331 | + run: | | ||
| 332 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 333 | + | ||
| 334 | + src_dir=$PWD/flutter/sherpa_onnx_android | ||
| 335 | + pushd $src_dir | ||
| 336 | + v="version: $SHERPA_ONNX_VERSION" | ||
| 337 | + echo "v: $v" | ||
| 338 | + sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml | ||
| 339 | + rm *.bak | ||
| 340 | + git status | ||
| 341 | + git diff | ||
| 342 | + | ||
| 343 | + - name: Copy extra files | ||
| 344 | + shell: bash | ||
| 345 | + run: | | ||
| 346 | + dst=flutter/sherpa_onnx_android | ||
| 347 | + | ||
| 348 | + mkdir $dst/example | ||
| 349 | + | ||
| 350 | + cp -v flutter/sherpa_onnx/example/* $dst/example | ||
| 351 | + cp -v LICENSE $dst/ | ||
| 352 | + cp -v CHANGELOG.md $dst/ | ||
| 353 | + | ||
| 354 | + git status | ||
| 355 | + | ||
| 356 | + - name: Build android-arm64-v8a | ||
| 357 | + shell: bash | ||
| 358 | + run: | | ||
| 359 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 360 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 361 | + cmake --version | ||
| 362 | + | ||
| 363 | + export SHERPA_ONNX_ENABLE_C_API=ON | ||
| 364 | + export SHERPA_ONNX_ENABLE_JNI=OFF | ||
| 365 | + export SHERPA_ONNX_ENABLE_BINARY=OFF | ||
| 366 | + | ||
| 367 | + ./build-android-arm64-v8a.sh | ||
| 368 | + | ||
| 369 | + - name: Build android-armv7-eabi | ||
| 370 | + shell: bash | ||
| 371 | + run: | | ||
| 372 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 373 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 374 | + cmake --version | ||
| 375 | + | ||
| 376 | + export SHERPA_ONNX_ENABLE_C_API=ON | ||
| 377 | + export SHERPA_ONNX_ENABLE_JNI=OFF | ||
| 378 | + export SHERPA_ONNX_ENABLE_BINARY=OFF | ||
| 379 | + | ||
| 380 | + ./build-android-armv7-eabi.sh | ||
| 381 | + | ||
| 382 | + - name: Build android-x86 | ||
| 383 | + shell: bash | ||
| 384 | + run: | | ||
| 385 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 386 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 387 | + cmake --version | ||
| 388 | + | ||
| 389 | + export SHERPA_ONNX_ENABLE_C_API=ON | ||
| 390 | + export SHERPA_ONNX_ENABLE_JNI=OFF | ||
| 391 | + export SHERPA_ONNX_ENABLE_BINARY=OFF | ||
| 392 | + | ||
| 393 | + ./build-android-x86.sh | ||
| 394 | + | ||
| 395 | + - name: Build android-x86-64 | ||
| 396 | + shell: bash | ||
| 397 | + run: | | ||
| 398 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 399 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 400 | + cmake --version | ||
| 401 | + | ||
| 402 | + export SHERPA_ONNX_ENABLE_C_API=ON | ||
| 403 | + export SHERPA_ONNX_ENABLE_JNI=OFF | ||
| 404 | + export SHERPA_ONNX_ENABLE_BINARY=OFF | ||
| 405 | + | ||
| 406 | + ./build-android-x86-64.sh | ||
| 407 | + | ||
| 408 | + - name: Copy pre-built libs | ||
| 409 | + shell: bash | ||
| 410 | + run: | | ||
| 411 | + echo "----arm64-v8a----" | ||
| 412 | + cp -v build-android-arm64-v8a/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/arm64-v8a/ | ||
| 413 | + | ||
| 414 | + echo "----armv7-eabi----" | ||
| 415 | + cp -v build-android-armv7-eabi/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/armeabi-v7a | ||
| 416 | + | ||
| 417 | + echo "----x86----" | ||
| 418 | + cp -v build-android-x86/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/x86 | ||
| 419 | + | ||
| 420 | + echo "----x86_64----" | ||
| 421 | + cp -v build-android-x86-64/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/x86_64 | ||
| 422 | + | ||
| 423 | + mv -v flutter/sherpa_onnx_android /tmp/to_be_published | ||
| 424 | + | ||
| 425 | + ls -lh /tmp/to_be_published | ||
| 426 | + | ||
| 427 | + - name: Setup Flutter SDK | ||
| 428 | + uses: flutter-actions/setup-flutter@v3 | ||
| 429 | + with: | ||
| 430 | + channel: stable | ||
| 431 | + version: latest | ||
| 432 | + | ||
| 433 | + - uses: dart-lang/setup-dart@v1 | ||
| 434 | + | ||
| 435 | + - name: Release | ||
| 436 | + shell: bash | ||
| 437 | + run: | | ||
| 438 | + cd /tmp/to_be_published | ||
| 439 | + du -h -d1 . | ||
| 440 | + | ||
| 441 | + flutter pub get | ||
| 442 | + flutter pub publish --dry-run | ||
| 443 | + flutter pub publish --force | ||
| 444 | + | ||
| 445 | + sherpa_onnx: | ||
| 446 | + # needs: [sherpa_onnx_linux, sherpa_onnx_macos, sherpa_onnx_windows, sherpa_onnx_android] | ||
| 447 | + # if: false | ||
| 448 | + permissions: | ||
| 449 | + id-token: write # Required for authentication using OIDC | ||
| 450 | + name: sherpa_onnx | ||
| 451 | + runs-on: ubuntu-latest | ||
| 452 | + | ||
| 453 | + steps: | ||
| 454 | + - uses: actions/checkout@v4 | ||
| 455 | + | ||
| 456 | + - name: Setup Flutter SDK | ||
| 457 | + uses: flutter-actions/setup-flutter@v3 | ||
| 458 | + with: | ||
| 459 | + channel: stable | ||
| 460 | + version: latest | ||
| 461 | + | ||
| 462 | + - uses: dart-lang/setup-dart@v1 | ||
| 463 | + | ||
| 464 | + - name: Fix version | ||
| 465 | + shell: bash | ||
| 466 | + run: | | ||
| 467 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 468 | + | ||
| 469 | + src_dir=$PWD/flutter/sherpa_onnx | ||
| 470 | + pushd $src_dir | ||
| 471 | + v="version: $SHERPA_ONNX_VERSION" | ||
| 472 | + echo "v: $v" | ||
| 473 | + sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml | ||
| 474 | + rm *.bak | ||
| 475 | + git status | ||
| 476 | + git diff | ||
| 477 | + | ||
| 478 | + - name: Copy extra files | ||
| 479 | + shell: bash | ||
| 480 | + run: | | ||
| 481 | + dst=flutter/sherpa_onnx | ||
| 482 | + | ||
| 483 | + cp -v LICENSE $dst/ | ||
| 484 | + cp -v CHANGELOG.md $dst/ | ||
| 485 | + cp -v README.md $dst/ | ||
| 486 | + | ||
| 487 | + git status | ||
| 488 | + | ||
| 489 | + mv -v flutter/sherpa_onnx /tmp/to_be_published | ||
| 490 | + | ||
| 491 | + ls -lh /tmp/to_be_published | ||
| 492 | + | ||
| 493 | + - name: Release | ||
| 494 | + shell: bash | ||
| 495 | + run: | | ||
| 496 | + cd /tmp/to_be_published | ||
| 497 | + du -h -d1 . | ||
| 498 | + | ||
| 49 | flutter pub get | 499 | flutter pub get |
| 50 | flutter pub publish --dry-run | 500 | flutter pub publish --dry-run |
| 51 | flutter pub publish --force | 501 | flutter pub publish --force |
| @@ -46,6 +46,51 @@ jobs: | @@ -46,6 +46,51 @@ jobs: | ||
| 46 | dart --version | 46 | dart --version |
| 47 | flutter doctor | 47 | flutter doctor |
| 48 | 48 | ||
| 49 | + - name: Display sherpa-onnx package info | ||
| 50 | + shell: bash | ||
| 51 | + run: | | ||
| 52 | + cd dart-api-examples/vad | ||
| 53 | + flutter pub get | ||
| 54 | + | ||
| 55 | + if [[ ${{ matrix.os }} == ubuntu-latest ]]; then | ||
| 56 | + echo "-----" | ||
| 57 | + ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev | ||
| 58 | + | ||
| 59 | + echo "-----" | ||
| 60 | + ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx* | ||
| 61 | + | ||
| 62 | + echo "-----" | ||
| 63 | + ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx*/* | ||
| 64 | + | ||
| 65 | + echo "-----" | ||
| 66 | + ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-* | ||
| 67 | + | ||
| 68 | + # sudo mkdir /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-1.10.7/lib | ||
| 69 | + # sudo touch /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-1.10.7/lib/.gitkeep | ||
| 70 | + | ||
| 71 | + echo "-----" | ||
| 72 | + ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-*/linux | ||
| 73 | + elif [[ ${{ matrix.os }} == macos-latest ]]; then | ||
| 74 | + echo "-----" | ||
| 75 | + ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev | ||
| 76 | + | ||
| 77 | + echo "-----" | ||
| 78 | + ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx* | ||
| 79 | + | ||
| 80 | + echo "-----" | ||
| 81 | + ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx*/* | ||
| 82 | + | ||
| 83 | + echo "-----" | ||
| 84 | + ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_macos-*/ | ||
| 85 | + | ||
| 86 | + echo "-----" | ||
| 87 | + ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_macos-*/macos | ||
| 88 | + | ||
| 89 | + # sudo mkdir /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_macos-1.10.7/lib | ||
| 90 | + # sudo touch /Users/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_macos-1.10.7/lib/.gitkeep | ||
| 91 | + fi | ||
| 92 | + | ||
| 93 | + | ||
| 49 | - name: Run tests | 94 | - name: Run tests |
| 50 | shell: bash | 95 | shell: bash |
| 51 | run: | | 96 | run: | |
| @@ -8,7 +8,7 @@ project(sherpa-onnx) | @@ -8,7 +8,7 @@ project(sherpa-onnx) | ||
| 8 | # ./nodejs-addon-examples | 8 | # ./nodejs-addon-examples |
| 9 | # ./dart-api-examples/ | 9 | # ./dart-api-examples/ |
| 10 | # ./sherpa-onnx/flutter/CHANGELOG.md | 10 | # ./sherpa-onnx/flutter/CHANGELOG.md |
| 11 | -set(SHERPA_ONNX_VERSION "1.10.6") | 11 | +set(SHERPA_ONNX_VERSION "1.10.9") |
| 12 | 12 | ||
| 13 | # Disable warning about | 13 | # Disable warning about |
| 14 | # | 14 | # |
| @@ -61,7 +61,7 @@ if(NOT CMAKE_BUILD_TYPE) | @@ -61,7 +61,7 @@ if(NOT CMAKE_BUILD_TYPE) | ||
| 61 | set(CMAKE_BUILD_TYPE Release) | 61 | set(CMAKE_BUILD_TYPE Release) |
| 62 | endif() | 62 | endif() |
| 63 | 63 | ||
| 64 | -if(DEFINED ANDROID_ABI AND NOT SHERPA_ONNX_ENABLE_JNI) | 64 | +if(DEFINED ANDROID_ABI AND NOT SHERPA_ONNX_ENABLE_JNI AND NOT SHERPA_ONNX_ENABLE_C_API) |
| 65 | message(STATUS "Set SHERPA_ONNX_ENABLE_JNI to ON for Android") | 65 | message(STATUS "Set SHERPA_ONNX_ENABLE_JNI to ON for Android") |
| 66 | set(SHERPA_ONNX_ENABLE_JNI ON CACHE BOOL "" FORCE) | 66 | set(SHERPA_ONNX_ENABLE_JNI ON CACHE BOOL "" FORCE) |
| 67 | endif() | 67 | endif() |
| @@ -30,7 +30,7 @@ dependencies: | @@ -30,7 +30,7 @@ dependencies: | ||
| 30 | record: ^5.1.0 | 30 | record: ^5.1.0 |
| 31 | url_launcher: ^6.2.6 | 31 | url_launcher: ^6.2.6 |
| 32 | 32 | ||
| 33 | - sherpa_onnx: ^1.10.0 | 33 | + sherpa_onnx: ^1.10.9 |
| 34 | # sherpa_onnx: | 34 | # sherpa_onnx: |
| 35 | # path: ../../flutter/sherpa_onnx | 35 | # path: ../../flutter/sherpa_onnx |
| 36 | 36 |
flutter/sherpa_onnx/README.md
已删除
100644 → 0
| 1 | # sherpa-onnx app example | 1 | # sherpa-onnx app example |
| 2 | 2 | ||
| 3 | -See also <https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter-examples> | 3 | +## Flutter examples |
| 4 | 4 | ||
| 5 | -## Streaming speech recognition | 5 | +| Functions | URL | Supported Platforms| |
| 6 | +|---|---|---| | ||
| 7 | +|Streaming speech recognition| [Address](https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter-examples/streaming_asr)| Android, macOS, Windows| | ||
| 6 | 8 | ||
| 7 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 8 | - | ||
| 9 | -## Non-streaming speech recognition | ||
| 10 | - | ||
| 11 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 12 | - | ||
| 13 | -## Text to speech (TTS) | ||
| 14 | - | ||
| 15 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 16 | - | ||
| 17 | -## Voice activity detection (VAD) | ||
| 18 | - | ||
| 19 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | 9 | +## Pure dart-examples |
| 20 | 10 | ||
| 11 | +| Functions | URL | Supported Platforms| | ||
| 12 | +|---|---|---| | ||
| 13 | +|Streaming speech recognition| [Address](https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr)| macOS, Windows, Linux| | ||
| 14 | +|Non-Streaming speech recognition| [Address](https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr)| macOS, Windows, Linux| | ||
| 15 | +|Text to speech| [Address](https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts)| macOS, Windows, Linux| | ||
| 16 | +|Voice activity detection (VAD)| [Address](https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad)| macOS, Windows, Linux| |
| @@ -4,7 +4,7 @@ description: > | @@ -4,7 +4,7 @@ description: > | ||
| 4 | Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | 4 | Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi |
| 5 | with onnxruntime without Internet connection. | 5 | with onnxruntime without Internet connection. |
| 6 | 6 | ||
| 7 | -repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/sherpa-onnx/flutter | 7 | +repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter |
| 8 | 8 | ||
| 9 | issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | 9 | issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues |
| 10 | documentation: https://k2-fsa.github.io/sherpa/onnx/ | 10 | documentation: https://k2-fsa.github.io/sherpa/onnx/ |
| @@ -16,8 +16,8 @@ topics: | @@ -16,8 +16,8 @@ topics: | ||
| 16 | - audio-tagging | 16 | - audio-tagging |
| 17 | - voice-activity-detection | 17 | - voice-activity-detection |
| 18 | 18 | ||
| 19 | -# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec | ||
| 20 | -version: 1.10.7 | 19 | +# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec |
| 20 | +version: 1.10.9 | ||
| 21 | 21 | ||
| 22 | homepage: https://github.com/k2-fsa/sherpa-onnx | 22 | homepage: https://github.com/k2-fsa/sherpa-onnx |
| 23 | 23 | ||
| @@ -30,16 +30,16 @@ dependencies: | @@ -30,16 +30,16 @@ dependencies: | ||
| 30 | flutter: | 30 | flutter: |
| 31 | sdk: flutter | 31 | sdk: flutter |
| 32 | 32 | ||
| 33 | - sherpa_onnx_android: | 33 | + sherpa_onnx_android: ^1.10.9 |
| 34 | # path: ../sherpa_onnx_android | 34 | # path: ../sherpa_onnx_android |
| 35 | 35 | ||
| 36 | - sherpa_onnx_macos: | 36 | + sherpa_onnx_macos: ^1.10.9 |
| 37 | # path: ../sherpa_onnx_macos | 37 | # path: ../sherpa_onnx_macos |
| 38 | 38 | ||
| 39 | - sherpa_onnx_linux: | 39 | + sherpa_onnx_linux: ^1.10.9 |
| 40 | # path: ../sherpa_onnx_linux | 40 | # path: ../sherpa_onnx_linux |
| 41 | # | 41 | # |
| 42 | - sherpa_onnx_windows: | 42 | + sherpa_onnx_windows: ^1.10.9 |
| 43 | # path: ../sherpa_onnx_windows | 43 | # path: ../sherpa_onnx_windows |
| 44 | 44 | ||
| 45 | flutter: | 45 | flutter: |
| 1 | -# Miscellaneous | ||
| 2 | -*.class | ||
| 3 | -*.log | ||
| 4 | -*.pyc | ||
| 5 | -*.swp | ||
| 6 | -.DS_Store | ||
| 7 | -.atom/ | ||
| 8 | -.buildlog/ | ||
| 9 | -.history | ||
| 10 | -.svn/ | ||
| 11 | -migrate_working_dir/ | ||
| 12 | - | ||
| 13 | -# IntelliJ related | ||
| 14 | -*.iml | ||
| 15 | -*.ipr | ||
| 16 | -*.iws | ||
| 17 | -.idea/ | ||
| 18 | - | ||
| 19 | -# The .vscode folder contains launch configuration and tasks you configure in | ||
| 20 | -# VS Code which you may wish to be included in version control, so this line | ||
| 21 | -# is commented out by default. | ||
| 22 | -#.vscode/ | ||
| 23 | - | ||
| 24 | -# Flutter/Dart/Pub related | ||
| 25 | -**/doc/api/ | ||
| 26 | -**/ios/Flutter/.last_build_id | ||
| 27 | -.dart_tool/ | ||
| 28 | -.flutter-plugins | ||
| 29 | -.flutter-plugins-dependencies | ||
| 30 | -.pub-cache/ | ||
| 31 | -.pub/ | ||
| 32 | -/build/ | ||
| 33 | - | ||
| 34 | -# Symbolication related | ||
| 35 | -app.*.symbols | ||
| 36 | - | ||
| 37 | -# Obfuscation related | ||
| 38 | -app.*.map.json | ||
| 39 | - | ||
| 40 | -# Android Studio will place build artifacts here | ||
| 41 | -/android/app/debug | ||
| 42 | -/android/app/profile | ||
| 43 | -/android/app/release |
| 1 | -# sherpa-onnx app example | ||
| 2 | - | ||
| 3 | -## Streaming speech recognition | ||
| 4 | - | ||
| 5 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 6 | - | ||
| 7 | -## Non-streaming speech recognition | ||
| 8 | - | ||
| 9 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 10 | - | ||
| 11 | -## Text to speech (TTS) | ||
| 12 | - | ||
| 13 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 14 | - | ||
| 15 | -## Voice activity detection (VAD) | ||
| 16 | - | ||
| 17 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | ||
| 18 | - |
flutter/sherpa_onnx_android/lib/README.md
0 → 100644
| 1 | name: sherpa_onnx_android | 1 | name: sherpa_onnx_android |
| 2 | -description: "A new Flutter FFI plugin project." | 2 | + |
| 3 | +description: > | ||
| 4 | + Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | ||
| 5 | + with onnxruntime without Internet connection. | ||
| 6 | + | ||
| 3 | version: 0.0.1 | 7 | version: 0.0.1 |
| 4 | -homepage: | 8 | + |
| 9 | +repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter | ||
| 10 | + | ||
| 11 | +issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | ||
| 12 | +documentation: https://k2-fsa.github.io/sherpa/onnx/ | ||
| 13 | + | ||
| 14 | +homepage: https://github.com/k2-fsa/sherpa-onnx | ||
| 15 | + | ||
| 16 | +topics: | ||
| 17 | + - speech-recognition | ||
| 18 | + - speech-synthesis | ||
| 19 | + - speaker-identification | ||
| 20 | + - audio-tagging | ||
| 21 | + - voice-activity-detection | ||
| 5 | 22 | ||
| 6 | environment: | 23 | environment: |
| 7 | sdk: '>=3.4.0 <4.0.0' | 24 | sdk: '>=3.4.0 <4.0.0' |
| 1 | -# Miscellaneous | ||
| 2 | -*.class | ||
| 3 | -*.log | ||
| 4 | -*.pyc | ||
| 5 | -*.swp | ||
| 6 | -.DS_Store | ||
| 7 | -.atom/ | ||
| 8 | -.buildlog/ | ||
| 9 | -.history | ||
| 10 | -.svn/ | ||
| 11 | -migrate_working_dir/ | ||
| 12 | - | ||
| 13 | -# IntelliJ related | ||
| 14 | -*.iml | ||
| 15 | -*.ipr | ||
| 16 | -*.iws | ||
| 17 | -.idea/ | ||
| 18 | - | ||
| 19 | -# The .vscode folder contains launch configuration and tasks you configure in | ||
| 20 | -# VS Code which you may wish to be included in version control, so this line | ||
| 21 | -# is commented out by default. | ||
| 22 | -#.vscode/ | ||
| 23 | - | ||
| 24 | -# Flutter/Dart/Pub related | ||
| 25 | -**/doc/api/ | ||
| 26 | -**/ios/Flutter/.last_build_id | ||
| 27 | -.dart_tool/ | ||
| 28 | -.flutter-plugins | ||
| 29 | -.flutter-plugins-dependencies | ||
| 30 | -.pub-cache/ | ||
| 31 | -.pub/ | ||
| 32 | -/build/ | ||
| 33 | - | ||
| 34 | -# Symbolication related | ||
| 35 | -app.*.symbols | ||
| 36 | - | ||
| 37 | -# Obfuscation related | ||
| 38 | -app.*.map.json | ||
| 39 | - | ||
| 40 | -# Android Studio will place build artifacts here | ||
| 41 | -/android/app/debug | ||
| 42 | -/android/app/profile | ||
| 43 | -/android/app/release |
| 1 | -# sherpa-onnx app example | ||
| 2 | - | ||
| 3 | -## Streaming speech recognition | ||
| 4 | - | ||
| 5 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 6 | - | ||
| 7 | -## Non-streaming speech recognition | ||
| 8 | - | ||
| 9 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 10 | - | ||
| 11 | -## Text to speech (TTS) | ||
| 12 | - | ||
| 13 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 14 | - | ||
| 15 | -## Voice activity detection (VAD) | ||
| 16 | - | ||
| 17 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | ||
| 18 | - |
flutter/sherpa_onnx_linux/lib/README.md
0 → 100644
| 1 | name: sherpa_onnx_linux | 1 | name: sherpa_onnx_linux |
| 2 | -description: "A new Flutter FFI plugin project." | 2 | +description: > |
| 3 | + Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | ||
| 4 | + with onnxruntime without Internet connection. | ||
| 5 | + | ||
| 3 | version: 0.0.1 | 6 | version: 0.0.1 |
| 4 | -homepage: | 7 | + |
| 8 | +repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter | ||
| 9 | + | ||
| 10 | +issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | ||
| 11 | +documentation: https://k2-fsa.github.io/sherpa/onnx/ | ||
| 12 | + | ||
| 13 | +homepage: https://github.com/k2-fsa/sherpa-onnx | ||
| 14 | + | ||
| 15 | +topics: | ||
| 16 | + - speech-recognition | ||
| 17 | + - speech-synthesis | ||
| 18 | + - speaker-identification | ||
| 19 | + - audio-tagging | ||
| 20 | + - voice-activity-detection | ||
| 5 | 21 | ||
| 6 | environment: | 22 | environment: |
| 7 | sdk: '>=3.4.0 <4.0.0' | 23 | sdk: '>=3.4.0 <4.0.0' |
| 1 | -# sherpa-onnx app example | ||
| 2 | - | ||
| 3 | -## Streaming speech recognition | ||
| 4 | - | ||
| 5 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 6 | - | ||
| 7 | -## Non-streaming speech recognition | ||
| 8 | - | ||
| 9 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 10 | - | ||
| 11 | -## Text to speech (TTS) | ||
| 12 | - | ||
| 13 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 14 | - | ||
| 15 | -## Voice activity detection (VAD) | ||
| 16 | - | ||
| 17 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | ||
| 18 | - |
flutter/sherpa_onnx_macos/lib/README.md
0 → 100644
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | # | 4 | # |
| 5 | Pod::Spec.new do |s| | 5 | Pod::Spec.new do |s| |
| 6 | s.name = 'sherpa_onnx_macos' | 6 | s.name = 'sherpa_onnx_macos' |
| 7 | - s.version = '1.10.6' | 7 | + s.version = '1.10.7' |
| 8 | s.summary = 'sherpa-onnx Flutter FFI plugin project.' | 8 | s.summary = 'sherpa-onnx Flutter FFI plugin project.' |
| 9 | s.description = <<-DESC | 9 | s.description = <<-DESC |
| 10 | sherpa-onnx Flutter FFI plugin project. | 10 | sherpa-onnx Flutter FFI plugin project. |
| 1 | name: sherpa_onnx_macos | 1 | name: sherpa_onnx_macos |
| 2 | -description: "A new Flutter FFI plugin project." | 2 | + |
| 3 | +description: > | ||
| 4 | + Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | ||
| 5 | + with onnxruntime without Internet connection. | ||
| 6 | + | ||
| 3 | version: 0.0.1 | 7 | version: 0.0.1 |
| 4 | -homepage: | 8 | + |
| 9 | +repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter | ||
| 10 | + | ||
| 11 | +issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | ||
| 12 | +documentation: https://k2-fsa.github.io/sherpa/onnx/ | ||
| 13 | + | ||
| 14 | +homepage: https://github.com/k2-fsa/sherpa-onnx | ||
| 15 | + | ||
| 16 | +topics: | ||
| 17 | + - speech-recognition | ||
| 18 | + - speech-synthesis | ||
| 19 | + - speaker-identification | ||
| 20 | + - audio-tagging | ||
| 21 | + - voice-activity-detection | ||
| 5 | 22 | ||
| 6 | environment: | 23 | environment: |
| 7 | sdk: '>=3.4.0 <4.0.0' | 24 | sdk: '>=3.4.0 <4.0.0' |
| 1 | -# Miscellaneous | ||
| 2 | -*.class | ||
| 3 | -*.log | ||
| 4 | -*.pyc | ||
| 5 | -*.swp | ||
| 6 | -.DS_Store | ||
| 7 | -.atom/ | ||
| 8 | -.buildlog/ | ||
| 9 | -.history | ||
| 10 | -.svn/ | ||
| 11 | -migrate_working_dir/ | ||
| 12 | - | ||
| 13 | -# IntelliJ related | ||
| 14 | -*.iml | ||
| 15 | -*.ipr | ||
| 16 | -*.iws | ||
| 17 | -.idea/ | ||
| 18 | - | ||
| 19 | -# The .vscode folder contains launch configuration and tasks you configure in | ||
| 20 | -# VS Code which you may wish to be included in version control, so this line | ||
| 21 | -# is commented out by default. | ||
| 22 | -#.vscode/ | ||
| 23 | - | ||
| 24 | -# Flutter/Dart/Pub related | ||
| 25 | -**/doc/api/ | ||
| 26 | -**/ios/Flutter/.last_build_id | ||
| 27 | -.dart_tool/ | ||
| 28 | -.flutter-plugins | ||
| 29 | -.flutter-plugins-dependencies | ||
| 30 | -.pub-cache/ | ||
| 31 | -.pub/ | ||
| 32 | -/build/ | ||
| 33 | - | ||
| 34 | -# Symbolication related | ||
| 35 | -app.*.symbols | ||
| 36 | - | ||
| 37 | -# Obfuscation related | ||
| 38 | -app.*.map.json | ||
| 39 | - | ||
| 40 | -# Android Studio will place build artifacts here | ||
| 41 | -/android/app/debug | ||
| 42 | -/android/app/profile | ||
| 43 | -/android/app/release |
| 1 | -# sherpa-onnx app example | ||
| 2 | - | ||
| 3 | -## Streaming speech recognition | ||
| 4 | - | ||
| 5 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 6 | - | ||
| 7 | -## Non-streaming speech recognition | ||
| 8 | - | ||
| 9 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 10 | - | ||
| 11 | -## Text to speech (TTS) | ||
| 12 | - | ||
| 13 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 14 | - | ||
| 15 | -## Voice activity detection (VAD) | ||
| 16 | - | ||
| 17 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | ||
| 18 | - |
flutter/sherpa_onnx_windows/lib/README.md
0 → 100644
| 1 | name: sherpa_onnx_windows | 1 | name: sherpa_onnx_windows |
| 2 | -description: "A new Flutter FFI plugin project." | 2 | + |
| 3 | +description: > | ||
| 4 | + Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | ||
| 5 | + with onnxruntime without Internet connection. | ||
| 6 | + | ||
| 3 | version: 0.0.1 | 7 | version: 0.0.1 |
| 4 | -homepage: | 8 | + |
| 9 | +repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/flutter | ||
| 10 | + | ||
| 11 | +issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | ||
| 12 | +documentation: https://k2-fsa.github.io/sherpa/onnx/ | ||
| 13 | + | ||
| 14 | +homepage: https://github.com/k2-fsa/sherpa-onnx | ||
| 15 | + | ||
| 16 | +topics: | ||
| 17 | + - speech-recognition | ||
| 18 | + - speech-synthesis | ||
| 19 | + - speaker-identification | ||
| 20 | + - audio-tagging | ||
| 21 | + - voice-activity-detection | ||
| 5 | 22 | ||
| 6 | environment: | 23 | environment: |
| 7 | sdk: '>=3.4.0 <4.0.0' | 24 | sdk: '>=3.4.0 <4.0.0' |
sherpa-onnx/flutter/.gitignore
已删除
100644 → 0
| 1 | -# Do not remove or rename entries in this file, only add new ones | ||
| 2 | -# See https://github.com/flutter/flutter/issues/128635 for more context. | ||
| 3 | - | ||
| 4 | -# Miscellaneous | ||
| 5 | -*.class | ||
| 6 | -*.lock | ||
| 7 | -*.log | ||
| 8 | -*.pyc | ||
| 9 | -*.swp | ||
| 10 | -.DS_Store | ||
| 11 | -.atom/ | ||
| 12 | -.buildlog/ | ||
| 13 | -.history | ||
| 14 | -.svn/ | ||
| 15 | - | ||
| 16 | -# IntelliJ related | ||
| 17 | -*.iml | ||
| 18 | -*.ipr | ||
| 19 | -*.iws | ||
| 20 | -.idea/ | ||
| 21 | - | ||
| 22 | -# Visual Studio Code related | ||
| 23 | -.classpath | ||
| 24 | -.project | ||
| 25 | -.settings/ | ||
| 26 | -.vscode/* | ||
| 27 | - | ||
| 28 | -# Flutter repo-specific | ||
| 29 | -/bin/cache/ | ||
| 30 | -/bin/internal/bootstrap.bat | ||
| 31 | -/bin/internal/bootstrap.sh | ||
| 32 | -/bin/mingit/ | ||
| 33 | -/dev/benchmarks/mega_gallery/ | ||
| 34 | -/dev/bots/.recipe_deps | ||
| 35 | -/dev/bots/android_tools/ | ||
| 36 | -/dev/devicelab/ABresults*.json | ||
| 37 | -/dev/docs/doc/ | ||
| 38 | -/dev/docs/api_docs.zip | ||
| 39 | -/dev/docs/flutter.docs.zip | ||
| 40 | -/dev/docs/lib/ | ||
| 41 | -/dev/docs/pubspec.yaml | ||
| 42 | -/dev/integration_tests/**/xcuserdata | ||
| 43 | -/dev/integration_tests/**/Pods | ||
| 44 | -/packages/flutter/coverage/ | ||
| 45 | -version | ||
| 46 | -analysis_benchmark.json | ||
| 47 | - | ||
| 48 | -# packages file containing multi-root paths | ||
| 49 | -.packages.generated | ||
| 50 | - | ||
| 51 | -# Flutter/Dart/Pub related | ||
| 52 | -**/doc/api/ | ||
| 53 | -.dart_tool/ | ||
| 54 | -.flutter-plugins | ||
| 55 | -.flutter-plugins-dependencies | ||
| 56 | -**/generated_plugin_registrant.dart | ||
| 57 | -.packages | ||
| 58 | -.pub-preload-cache/ | ||
| 59 | -.pub-cache/ | ||
| 60 | -.pub/ | ||
| 61 | -build/ | ||
| 62 | -flutter_*.png | ||
| 63 | -linked_*.ds | ||
| 64 | -unlinked.ds | ||
| 65 | -unlinked_spec.ds | ||
| 66 | - | ||
| 67 | -# Android related | ||
| 68 | -**/android/**/gradle-wrapper.jar | ||
| 69 | -.gradle/ | ||
| 70 | -**/android/captures/ | ||
| 71 | -**/android/gradlew | ||
| 72 | -**/android/gradlew.bat | ||
| 73 | -**/android/local.properties | ||
| 74 | -**/android/**/GeneratedPluginRegistrant.java | ||
| 75 | -**/android/key.properties | ||
| 76 | -*.jks | ||
| 77 | - | ||
| 78 | -# iOS/XCode related | ||
| 79 | -**/ios/**/*.mode1v3 | ||
| 80 | -**/ios/**/*.mode2v3 | ||
| 81 | -**/ios/**/*.moved-aside | ||
| 82 | -**/ios/**/*.pbxuser | ||
| 83 | -**/ios/**/*.perspectivev3 | ||
| 84 | -**/ios/**/*sync/ | ||
| 85 | -**/ios/**/.sconsign.dblite | ||
| 86 | -**/ios/**/.tags* | ||
| 87 | -**/ios/**/.vagrant/ | ||
| 88 | -**/ios/**/DerivedData/ | ||
| 89 | -**/ios/**/Icon? | ||
| 90 | -**/ios/**/Pods/ | ||
| 91 | -**/ios/**/.symlinks/ | ||
| 92 | -**/ios/**/profile | ||
| 93 | -**/ios/**/xcuserdata | ||
| 94 | -**/ios/.generated/ | ||
| 95 | -**/ios/Flutter/.last_build_id | ||
| 96 | -**/ios/Flutter/App.framework | ||
| 97 | -**/ios/Flutter/Flutter.framework | ||
| 98 | -**/ios/Flutter/Flutter.podspec | ||
| 99 | -**/ios/Flutter/Generated.xcconfig | ||
| 100 | -**/ios/Flutter/ephemeral | ||
| 101 | -**/ios/Flutter/app.flx | ||
| 102 | -**/ios/Flutter/app.zip | ||
| 103 | -**/ios/Flutter/flutter_assets/ | ||
| 104 | -**/ios/Flutter/flutter_export_environment.sh | ||
| 105 | -**/ios/ServiceDefinitions.json | ||
| 106 | -**/ios/Runner/GeneratedPluginRegistrant.* | ||
| 107 | - | ||
| 108 | -# macOS | ||
| 109 | -**/Flutter/ephemeral/ | ||
| 110 | -**/Pods/ | ||
| 111 | -**/macos/Flutter/GeneratedPluginRegistrant.swift | ||
| 112 | -**/macos/Flutter/ephemeral | ||
| 113 | -**/xcuserdata/ | ||
| 114 | - | ||
| 115 | -# Windows | ||
| 116 | -**/windows/flutter/generated_plugin_registrant.cc | ||
| 117 | -**/windows/flutter/generated_plugin_registrant.h | ||
| 118 | -**/windows/flutter/generated_plugins.cmake | ||
| 119 | - | ||
| 120 | -# Linux | ||
| 121 | -**/linux/flutter/generated_plugin_registrant.cc | ||
| 122 | -**/linux/flutter/generated_plugin_registrant.h | ||
| 123 | -**/linux/flutter/generated_plugins.cmake | ||
| 124 | - | ||
| 125 | -# Coverage | ||
| 126 | -coverage/ | ||
| 127 | - | ||
| 128 | -# Symbols | ||
| 129 | -app.*.symbols | ||
| 130 | - | ||
| 131 | -# Exceptions to above rules. | ||
| 132 | -!**/ios/**/default.mode1v3 | ||
| 133 | -!**/ios/**/default.mode2v3 | ||
| 134 | -!**/ios/**/default.pbxuser | ||
| 135 | -!**/ios/**/default.perspectivev3 | ||
| 136 | -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages | ||
| 137 | -!/dev/ci/**/Gemfile.lock | ||
| 138 | -!.vscode/settings.json | ||
| 139 | - | ||
| 140 | -## User settings | ||
| 141 | -xcuserdata/ | ||
| 142 | - | ||
| 143 | -## Xcode 8 and earlier | ||
| 144 | -*.xcscmblueprint | ||
| 145 | -*.xccheckout | ||
| 146 | - | ||
| 147 | -flutter_jank_metrics*.json |
sherpa-onnx/flutter/CHANGELOG.md
已删除
100644 → 0
| 1 | -## 1.10.2 | ||
| 2 | - | ||
| 3 | -* Fix passing C# string to C++ | ||
| 4 | - | ||
| 5 | -## 1.10.1 | ||
| 6 | - | ||
| 7 | -* Enable to stop TTS generation | ||
| 8 | - | ||
| 9 | -## 1.10.0 | ||
| 10 | - | ||
| 11 | -* Add inverse text normalization | ||
| 12 | - | ||
| 13 | -## 1.9.30 | ||
| 14 | - | ||
| 15 | -* Add TTS | ||
| 16 | - | ||
| 17 | -## 1.9.29 | ||
| 18 | - | ||
| 19 | -* Publish with CI | ||
| 20 | - | ||
| 21 | -## 0.0.3 | ||
| 22 | - | ||
| 23 | -* Fix path separator on Windows. | ||
| 24 | - | ||
| 25 | -## 0.0.2 | ||
| 26 | - | ||
| 27 | -* Support specifying lib path. | ||
| 28 | - | ||
| 29 | -## 0.0.1 | ||
| 30 | - | ||
| 31 | -* Initial release. |
sherpa-onnx/flutter/LICENSE
已删除
100644 → 0
| 1 | - | ||
| 2 | - Apache License | ||
| 3 | - Version 2.0, January 2004 | ||
| 4 | - http://www.apache.org/licenses/ | ||
| 5 | - | ||
| 6 | - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||
| 7 | - | ||
| 8 | - 1. Definitions. | ||
| 9 | - | ||
| 10 | - "License" shall mean the terms and conditions for use, reproduction, | ||
| 11 | - and distribution as defined by Sections 1 through 9 of this document. | ||
| 12 | - | ||
| 13 | - "Licensor" shall mean the copyright owner or entity authorized by | ||
| 14 | - the copyright owner that is granting the License. | ||
| 15 | - | ||
| 16 | - "Legal Entity" shall mean the union of the acting entity and all | ||
| 17 | - other entities that control, are controlled by, or are under common | ||
| 18 | - control with that entity. For the purposes of this definition, | ||
| 19 | - "control" means (i) the power, direct or indirect, to cause the | ||
| 20 | - direction or management of such entity, whether by contract or | ||
| 21 | - otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||
| 22 | - outstanding shares, or (iii) beneficial ownership of such entity. | ||
| 23 | - | ||
| 24 | - "You" (or "Your") shall mean an individual or Legal Entity | ||
| 25 | - exercising permissions granted by this License. | ||
| 26 | - | ||
| 27 | - "Source" form shall mean the preferred form for making modifications, | ||
| 28 | - including but not limited to software source code, documentation | ||
| 29 | - source, and configuration files. | ||
| 30 | - | ||
| 31 | - "Object" form shall mean any form resulting from mechanical | ||
| 32 | - transformation or translation of a Source form, including but | ||
| 33 | - not limited to compiled object code, generated documentation, | ||
| 34 | - and conversions to other media types. | ||
| 35 | - | ||
| 36 | - "Work" shall mean the work of authorship, whether in Source or | ||
| 37 | - Object form, made available under the License, as indicated by a | ||
| 38 | - copyright notice that is included in or attached to the work | ||
| 39 | - (an example is provided in the Appendix below). | ||
| 40 | - | ||
| 41 | - "Derivative Works" shall mean any work, whether in Source or Object | ||
| 42 | - form, that is based on (or derived from) the Work and for which the | ||
| 43 | - editorial revisions, annotations, elaborations, or other modifications | ||
| 44 | - represent, as a whole, an original work of authorship. For the purposes | ||
| 45 | - of this License, Derivative Works shall not include works that remain | ||
| 46 | - separable from, or merely link (or bind by name) to the interfaces of, | ||
| 47 | - the Work and Derivative Works thereof. | ||
| 48 | - | ||
| 49 | - "Contribution" shall mean any work of authorship, including | ||
| 50 | - the original version of the Work and any modifications or additions | ||
| 51 | - to that Work or Derivative Works thereof, that is intentionally | ||
| 52 | - submitted to Licensor for inclusion in the Work by the copyright owner | ||
| 53 | - or by an individual or Legal Entity authorized to submit on behalf of | ||
| 54 | - the copyright owner. For the purposes of this definition, "submitted" | ||
| 55 | - means any form of electronic, verbal, or written communication sent | ||
| 56 | - to the Licensor or its representatives, including but not limited to | ||
| 57 | - communication on electronic mailing lists, source code control systems, | ||
| 58 | - and issue tracking systems that are managed by, or on behalf of, the | ||
| 59 | - Licensor for the purpose of discussing and improving the Work, but | ||
| 60 | - excluding communication that is conspicuously marked or otherwise | ||
| 61 | - designated in writing by the copyright owner as "Not a Contribution." | ||
| 62 | - | ||
| 63 | - "Contributor" shall mean Licensor and any individual or Legal Entity | ||
| 64 | - on behalf of whom a Contribution has been received by Licensor and | ||
| 65 | - subsequently incorporated within the Work. | ||
| 66 | - | ||
| 67 | - 2. Grant of Copyright License. Subject to the terms and conditions of | ||
| 68 | - this License, each Contributor hereby grants to You a perpetual, | ||
| 69 | - worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
| 70 | - copyright license to reproduce, prepare Derivative Works of, | ||
| 71 | - publicly display, publicly perform, sublicense, and distribute the | ||
| 72 | - Work and such Derivative Works in Source or Object form. | ||
| 73 | - | ||
| 74 | - 3. Grant of Patent License. Subject to the terms and conditions of | ||
| 75 | - this License, each Contributor hereby grants to You a perpetual, | ||
| 76 | - worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
| 77 | - (except as stated in this section) patent license to make, have made, | ||
| 78 | - use, offer to sell, sell, import, and otherwise transfer the Work, | ||
| 79 | - where such license applies only to those patent claims licensable | ||
| 80 | - by such Contributor that are necessarily infringed by their | ||
| 81 | - Contribution(s) alone or by combination of their Contribution(s) | ||
| 82 | - with the Work to which such Contribution(s) was submitted. If You | ||
| 83 | - institute patent litigation against any entity (including a | ||
| 84 | - cross-claim or counterclaim in a lawsuit) alleging that the Work | ||
| 85 | - or a Contribution incorporated within the Work constitutes direct | ||
| 86 | - or contributory patent infringement, then any patent licenses | ||
| 87 | - granted to You under this License for that Work shall terminate | ||
| 88 | - as of the date such litigation is filed. | ||
| 89 | - | ||
| 90 | - 4. Redistribution. You may reproduce and distribute copies of the | ||
| 91 | - Work or Derivative Works thereof in any medium, with or without | ||
| 92 | - modifications, and in Source or Object form, provided that You | ||
| 93 | - meet the following conditions: | ||
| 94 | - | ||
| 95 | - (a) You must give any other recipients of the Work or | ||
| 96 | - Derivative Works a copy of this License; and | ||
| 97 | - | ||
| 98 | - (b) You must cause any modified files to carry prominent notices | ||
| 99 | - stating that You changed the files; and | ||
| 100 | - | ||
| 101 | - (c) You must retain, in the Source form of any Derivative Works | ||
| 102 | - that You distribute, all copyright, patent, trademark, and | ||
| 103 | - attribution notices from the Source form of the Work, | ||
| 104 | - excluding those notices that do not pertain to any part of | ||
| 105 | - the Derivative Works; and | ||
| 106 | - | ||
| 107 | - (d) If the Work includes a "NOTICE" text file as part of its | ||
| 108 | - distribution, then any Derivative Works that You distribute must | ||
| 109 | - include a readable copy of the attribution notices contained | ||
| 110 | - within such NOTICE file, excluding those notices that do not | ||
| 111 | - pertain to any part of the Derivative Works, in at least one | ||
| 112 | - of the following places: within a NOTICE text file distributed | ||
| 113 | - as part of the Derivative Works; within the Source form or | ||
| 114 | - documentation, if provided along with the Derivative Works; or, | ||
| 115 | - within a display generated by the Derivative Works, if and | ||
| 116 | - wherever such third-party notices normally appear. The contents | ||
| 117 | - of the NOTICE file are for informational purposes only and | ||
| 118 | - do not modify the License. You may add Your own attribution | ||
| 119 | - notices within Derivative Works that You distribute, alongside | ||
| 120 | - or as an addendum to the NOTICE text from the Work, provided | ||
| 121 | - that such additional attribution notices cannot be construed | ||
| 122 | - as modifying the License. | ||
| 123 | - | ||
| 124 | - You may add Your own copyright statement to Your modifications and | ||
| 125 | - may provide additional or different license terms and conditions | ||
| 126 | - for use, reproduction, or distribution of Your modifications, or | ||
| 127 | - for any such Derivative Works as a whole, provided Your use, | ||
| 128 | - reproduction, and distribution of the Work otherwise complies with | ||
| 129 | - the conditions stated in this License. | ||
| 130 | - | ||
| 131 | - 5. Submission of Contributions. Unless You explicitly state otherwise, | ||
| 132 | - any Contribution intentionally submitted for inclusion in the Work | ||
| 133 | - by You to the Licensor shall be under the terms and conditions of | ||
| 134 | - this License, without any additional terms or conditions. | ||
| 135 | - Notwithstanding the above, nothing herein shall supersede or modify | ||
| 136 | - the terms of any separate license agreement you may have executed | ||
| 137 | - with Licensor regarding such Contributions. | ||
| 138 | - | ||
| 139 | - 6. Trademarks. This License does not grant permission to use the trade | ||
| 140 | - names, trademarks, service marks, or product names of the Licensor, | ||
| 141 | - except as required for reasonable and customary use in describing the | ||
| 142 | - origin of the Work and reproducing the content of the NOTICE file. | ||
| 143 | - | ||
| 144 | - 7. Disclaimer of Warranty. Unless required by applicable law or | ||
| 145 | - agreed to in writing, Licensor provides the Work (and each | ||
| 146 | - Contributor provides its Contributions) on an "AS IS" BASIS, | ||
| 147 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
| 148 | - implied, including, without limitation, any warranties or conditions | ||
| 149 | - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||
| 150 | - PARTICULAR PURPOSE. You are solely responsible for determining the | ||
| 151 | - appropriateness of using or redistributing the Work and assume any | ||
| 152 | - risks associated with Your exercise of permissions under this License. | ||
| 153 | - | ||
| 154 | - 8. Limitation of Liability. In no event and under no legal theory, | ||
| 155 | - whether in tort (including negligence), contract, or otherwise, | ||
| 156 | - unless required by applicable law (such as deliberate and grossly | ||
| 157 | - negligent acts) or agreed to in writing, shall any Contributor be | ||
| 158 | - liable to You for damages, including any direct, indirect, special, | ||
| 159 | - incidental, or consequential damages of any character arising as a | ||
| 160 | - result of this License or out of the use or inability to use the | ||
| 161 | - Work (including but not limited to damages for loss of goodwill, | ||
| 162 | - work stoppage, computer failure or malfunction, or any and all | ||
| 163 | - other commercial damages or losses), even if such Contributor | ||
| 164 | - has been advised of the possibility of such damages. | ||
| 165 | - | ||
| 166 | - 9. Accepting Warranty or Additional Liability. While redistributing | ||
| 167 | - the Work or Derivative Works thereof, You may choose to offer, | ||
| 168 | - and charge a fee for, acceptance of support, warranty, indemnity, | ||
| 169 | - or other liability obligations and/or rights consistent with this | ||
| 170 | - License. However, in accepting such obligations, You may act only | ||
| 171 | - on Your own behalf and on Your sole responsibility, not on behalf | ||
| 172 | - of any other Contributor, and only if You agree to indemnify, | ||
| 173 | - defend, and hold each Contributor harmless for any liability | ||
| 174 | - incurred by, or claims asserted against, such Contributor by reason | ||
| 175 | - of your accepting any such warranty or additional liability. | ||
| 176 | - | ||
| 177 | - END OF TERMS AND CONDITIONS | ||
| 178 | - | ||
| 179 | - APPENDIX: How to apply the Apache License to your work. | ||
| 180 | - | ||
| 181 | - To apply the Apache License to your work, attach the following | ||
| 182 | - boilerplate notice, with the fields enclosed by brackets "[]" | ||
| 183 | - replaced with your own identifying information. (Don't include | ||
| 184 | - the brackets!) The text should be enclosed in the appropriate | ||
| 185 | - comment syntax for the file format. We also recommend that a | ||
| 186 | - file or class name and description of purpose be included on the | ||
| 187 | - same "printed page" as the copyright notice for easier | ||
| 188 | - identification within third-party archives. | ||
| 189 | - | ||
| 190 | - Copyright [yyyy] [name of copyright owner] | ||
| 191 | - | ||
| 192 | - Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 193 | - you may not use this file except in compliance with the License. | ||
| 194 | - You may obtain a copy of the License at | ||
| 195 | - | ||
| 196 | - http://www.apache.org/licenses/LICENSE-2.0 | ||
| 197 | - | ||
| 198 | - Unless required by applicable law or agreed to in writing, software | ||
| 199 | - distributed under the License is distributed on an "AS IS" BASIS, | ||
| 200 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 201 | - See the License for the specific language governing permissions and | ||
| 202 | - limitations under the License. |
| 1 | -# Introduction | ||
| 2 | - | ||
| 3 | -## Speaker identification | ||
| 4 | - | ||
| 5 | -```bash | ||
| 6 | -# switch to this directory and run | ||
| 7 | - | ||
| 8 | -wget https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx | ||
| 9 | -wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx | ||
| 10 | -git clone https://github.com/csukuangfj/sr-data | ||
| 11 | - | ||
| 12 | -rm -rf sr-data/.git | ||
| 13 | -``` |
不能预览此文件类型
不能预览此文件类型
sherpa-onnx/flutter/example/example.md
已删除
100644 → 0
| 1 | -# sherpa-onnx app example | ||
| 2 | - | ||
| 3 | -## Streaming speech recognition | ||
| 4 | - | ||
| 5 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/streaming-asr | ||
| 6 | - | ||
| 7 | -## Non-streaming speech recognition | ||
| 8 | - | ||
| 9 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/non-streaming-asr | ||
| 10 | - | ||
| 11 | -## Text to speech (TTS) | ||
| 12 | - | ||
| 13 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/tts | ||
| 14 | - | ||
| 15 | -## Voice activity detection (VAD) | ||
| 16 | - | ||
| 17 | -Please see https://github.com/k2-fsa/sherpa-onnx/tree/master/dart-api-examples/vad | ||
| 18 | - |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:flutter/material.dart'; | ||
| 3 | -import 'package:url_launcher/url_launcher.dart'; | ||
| 4 | - | ||
| 5 | -class InfoScreen extends StatelessWidget { | ||
| 6 | - @override | ||
| 7 | - Widget build(BuildContext context) { | ||
| 8 | - const double height = 20; | ||
| 9 | - return Container( | ||
| 10 | - child: Padding( | ||
| 11 | - padding: const EdgeInsets.all(8.0), | ||
| 12 | - child: Column( | ||
| 13 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 14 | - children: <Widget>[ | ||
| 15 | - Text('Everything is open-sourced.'), | ||
| 16 | - SizedBox(height: height), | ||
| 17 | - InkWell( | ||
| 18 | - child: Text('Code: https://github.com/k2-fsa/sherpa-onnx'), | ||
| 19 | - onTap: () => launch('https://k2-fsa.github.io/sherpa/onnx/'), | ||
| 20 | - ), | ||
| 21 | - SizedBox(height: height), | ||
| 22 | - InkWell( | ||
| 23 | - child: Text('Doc: https://k2-fsa.github.io/sherpa/onnx/'), | ||
| 24 | - onTap: () => launch('https://k2-fsa.github.io/sherpa/onnx/'), | ||
| 25 | - ), | ||
| 26 | - SizedBox(height: height), | ||
| 27 | - Text('QQ 群: 744602236'), | ||
| 28 | - SizedBox(height: height), | ||
| 29 | - InkWell( | ||
| 30 | - child: Text( | ||
| 31 | - '微信群: https://k2-fsa.github.io/sherpa/social-groups.html'), | ||
| 32 | - onTap: () => | ||
| 33 | - launch('https://k2-fsa.github.io/sherpa/social-groups.html'), | ||
| 34 | - ), | ||
| 35 | - ], | ||
| 36 | - ), | ||
| 37 | - ), | ||
| 38 | - ); | ||
| 39 | - } | ||
| 40 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 3 | -import 'package:flutter/material.dart'; | ||
| 4 | - | ||
| 5 | -import './vad.dart'; | ||
| 6 | -import './streaming_asr.dart'; | ||
| 7 | -import './info.dart'; | ||
| 8 | - | ||
| 9 | -void main() { | ||
| 10 | - runApp(const MyApp()); | ||
| 11 | -} | ||
| 12 | - | ||
| 13 | -class MyApp extends StatelessWidget { | ||
| 14 | - const MyApp({Key? key}) : super(key: key); | ||
| 15 | - @override | ||
| 16 | - Widget build(BuildContext context) { | ||
| 17 | - return MaterialApp( | ||
| 18 | - title: 'Next-gen Kaldi', | ||
| 19 | - theme: ThemeData( | ||
| 20 | - primarySwatch: Colors.blue, | ||
| 21 | - ), | ||
| 22 | - home: const MyHomePage(title: 'Next-gen Kaldi Demo'), | ||
| 23 | - ); | ||
| 24 | - } | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -class MyHomePage extends StatefulWidget { | ||
| 28 | - const MyHomePage({Key? key, required this.title}) : super(key: key); | ||
| 29 | - final String title; | ||
| 30 | - @override | ||
| 31 | - State<MyHomePage> createState() => _MyHomePageState(); | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -class _MyHomePageState extends State<MyHomePage> { | ||
| 35 | - int _currentIndex = 0; | ||
| 36 | - final List<Widget> _tabs = [ | ||
| 37 | - StreamingAsrScreen(), | ||
| 38 | - VadScreen(), | ||
| 39 | - InfoScreen(), | ||
| 40 | - ]; | ||
| 41 | - @override | ||
| 42 | - Widget build(BuildContext context) { | ||
| 43 | - return Scaffold( | ||
| 44 | - appBar: AppBar( | ||
| 45 | - title: Text(widget.title), | ||
| 46 | - ), | ||
| 47 | - body: _tabs[_currentIndex], | ||
| 48 | - bottomNavigationBar: BottomNavigationBar( | ||
| 49 | - currentIndex: _currentIndex, | ||
| 50 | - onTap: (int index) { | ||
| 51 | - setState(() { | ||
| 52 | - _currentIndex = index; | ||
| 53 | - }); | ||
| 54 | - }, | ||
| 55 | - // https://www.xiconeditor.com/ | ||
| 56 | - items: [ | ||
| 57 | - BottomNavigationBarItem( | ||
| 58 | - icon: new Image.asset("assets/streaming-asr.ico"), | ||
| 59 | - label: '', | ||
| 60 | - ), | ||
| 61 | - BottomNavigationBarItem( | ||
| 62 | - icon: new Image.asset("assets/vad.ico"), | ||
| 63 | - label: '', | ||
| 64 | - ), | ||
| 65 | - BottomNavigationBarItem( | ||
| 66 | - icon: Icon(Icons.info), | ||
| 67 | - label: 'Info', | ||
| 68 | - ), | ||
| 69 | - ], | ||
| 70 | - ), | ||
| 71 | - ); | ||
| 72 | - } | ||
| 73 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:path/path.dart'; | ||
| 3 | -import 'package:path_provider/path_provider.dart'; | ||
| 4 | -import 'package:flutter/services.dart' show rootBundle; | ||
| 5 | -import 'dart:typed_data'; | ||
| 6 | -import "dart:io"; | ||
| 7 | - | ||
| 8 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 9 | -import './utils.dart'; | ||
| 10 | - | ||
| 11 | -Future<void> testNonStreamingParaformerAsr() async { | ||
| 12 | - var model = 'assets/sherpa-onnx-paraformer-zh-2023-03-28/model.int8.onnx'; | ||
| 13 | - var tokens = 'assets/sherpa-onnx-paraformer-zh-2023-03-28/tokens.txt'; | ||
| 14 | - var testWave = 'assets/sherpa-onnx-paraformer-zh-2023-03-28/test_wavs/0.wav'; | ||
| 15 | - | ||
| 16 | - model = await copyAssetFile(src: model, dst: 'model.int8.onnx'); | ||
| 17 | - tokens = await copyAssetFile(src: tokens, dst: 'tokens.txt'); | ||
| 18 | - testWave = await copyAssetFile(src: testWave, dst: '0.wav'); | ||
| 19 | - | ||
| 20 | - final paraformer = sherpa_onnx.OfflineParaformerModelConfig( | ||
| 21 | - model: model, | ||
| 22 | - ); | ||
| 23 | - | ||
| 24 | - final modelConfig = sherpa_onnx.OfflineModelConfig( | ||
| 25 | - paraformer: paraformer, | ||
| 26 | - tokens: tokens, | ||
| 27 | - modelType: 'paraformer', | ||
| 28 | - ); | ||
| 29 | - | ||
| 30 | - final config = sherpa_onnx.OfflineRecognizerConfig(model: modelConfig); | ||
| 31 | - print(config); | ||
| 32 | - final recognizer = sherpa_onnx.OfflineRecognizer(config); | ||
| 33 | - | ||
| 34 | - final waveData = sherpa_onnx.readWave(testWave); | ||
| 35 | - final stream = recognizer.createStream(); | ||
| 36 | - | ||
| 37 | - stream.acceptWaveform( | ||
| 38 | - samples: waveData.samples, sampleRate: waveData.sampleRate); | ||
| 39 | - recognizer.decode(stream); | ||
| 40 | - | ||
| 41 | - final result = recognizer.getResult(stream); | ||
| 42 | - print('result is: ${result}'); | ||
| 43 | - | ||
| 44 | - print('recognizer: ${recognizer.ptr}'); | ||
| 45 | - stream.free(); | ||
| 46 | - recognizer.free(); | ||
| 47 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:path/path.dart'; | ||
| 5 | -import './utils.dart'; | ||
| 6 | - | ||
| 7 | -Float32List computeEmbedding( | ||
| 8 | - {required sherpa_onnx.SpeakerEmbeddingExtractor extractor, | ||
| 9 | - required String filename}) { | ||
| 10 | - final stream = extractor.createStream(); | ||
| 11 | - final waveData = sherpa_onnx.readWave(filename); | ||
| 12 | - | ||
| 13 | - stream.acceptWaveform( | ||
| 14 | - samples: waveData.samples, sampleRate: waveData.sampleRate); | ||
| 15 | - | ||
| 16 | - stream.inputFinished(); | ||
| 17 | - | ||
| 18 | - final embedding = extractor.compute(stream); | ||
| 19 | - | ||
| 20 | - stream.free(); | ||
| 21 | - | ||
| 22 | - return embedding; | ||
| 23 | -} | ||
| 24 | - | ||
| 25 | -Future<void> testSpeakerID() async { | ||
| 26 | - final src = | ||
| 27 | - 'assets/3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx'; | ||
| 28 | - final modelPath = await copyAssetFile(src: src, dst: 'model.onnx'); | ||
| 29 | - | ||
| 30 | - final config = sherpa_onnx.SpeakerEmbeddingExtractorConfig(model: modelPath); | ||
| 31 | - final extractor = sherpa_onnx.SpeakerEmbeddingExtractor(config: config); | ||
| 32 | - | ||
| 33 | - const _spk1Files = [ | ||
| 34 | - 'assets/sr-data/enroll/fangjun-sr-1.wav', | ||
| 35 | - 'assets/sr-data/enroll/fangjun-sr-2.wav', | ||
| 36 | - 'assets/sr-data/enroll/fangjun-sr-3.wav', | ||
| 37 | - ]; | ||
| 38 | - final spk1Files = <String>[]; | ||
| 39 | - for (final f in _spk1Files) { | ||
| 40 | - spk1Files.add(await copyAssetFile(src: f, dst: basename(f))); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - final spk1Vec = <Float32List>[]; | ||
| 44 | - for (final f in spk1Files) { | ||
| 45 | - spk1Vec.add(computeEmbedding(extractor: extractor, filename: f)); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - const _spk2Files = [ | ||
| 49 | - 'assets/sr-data/enroll/leijun-sr-1.wav', | ||
| 50 | - 'assets/sr-data/enroll/leijun-sr-2.wav', | ||
| 51 | - ]; | ||
| 52 | - final spk2Files = <String>[]; | ||
| 53 | - for (final f in _spk2Files) { | ||
| 54 | - spk2Files.add(await copyAssetFile(src: f, dst: basename(f))); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - final spk2Vec = <Float32List>[]; | ||
| 58 | - for (final f in spk2Files) { | ||
| 59 | - spk2Vec.add(computeEmbedding(extractor: extractor, filename: f)); | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - final manager = sherpa_onnx.SpeakerEmbeddingManager(extractor.dim); | ||
| 63 | - assert(manager.numSpeakers == 0, '${manager.numSpeakers}'); | ||
| 64 | - | ||
| 65 | - bool ok = manager.addMulti(name: 'fangjun', embeddingList: spk1Vec); | ||
| 66 | - assert(ok, "Failed to add fangjun"); | ||
| 67 | - assert(manager.numSpeakers == 1, '${manager.numSpeakers}'); | ||
| 68 | - | ||
| 69 | - ok = manager.addMulti(name: 'leijun', embeddingList: spk2Vec); | ||
| 70 | - assert(ok, "Failed to add leijun"); | ||
| 71 | - assert(manager.numSpeakers == 2, '${manager.numSpeakers}'); | ||
| 72 | - | ||
| 73 | - bool found = manager.contains('fangjun'); | ||
| 74 | - assert(found, 'Failed to find fangjun'); | ||
| 75 | - | ||
| 76 | - found = manager.contains('leijun'); | ||
| 77 | - assert(found, 'Failed to find leijun'); | ||
| 78 | - | ||
| 79 | - print('---All speakers---'); | ||
| 80 | - | ||
| 81 | - print(manager.allSpeakerNames); | ||
| 82 | - | ||
| 83 | - print('------------'); | ||
| 84 | - | ||
| 85 | - const _testFiles = [ | ||
| 86 | - 'assets/sr-data/test/fangjun-test-sr-1.wav', | ||
| 87 | - 'assets/sr-data/test/leijun-test-sr-1.wav', | ||
| 88 | - 'assets/sr-data/test/liudehua-test-sr-1.wav', | ||
| 89 | - ]; | ||
| 90 | - | ||
| 91 | - final testFiles = <String>[]; | ||
| 92 | - for (final f in _testFiles) { | ||
| 93 | - testFiles.add(await copyAssetFile(src: f, dst: basename(f))); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - const threshold = 0.6; | ||
| 97 | - | ||
| 98 | - for (final f in testFiles) { | ||
| 99 | - final embedding = computeEmbedding(extractor: extractor, filename: f); | ||
| 100 | - | ||
| 101 | - var name = manager.search(embedding: embedding, threshold: threshold); | ||
| 102 | - if (name == '') { | ||
| 103 | - name = '<Unknown>'; | ||
| 104 | - } | ||
| 105 | - print('${f}: ${name}'); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - ok = manager.verify( | ||
| 109 | - name: 'fangjun', | ||
| 110 | - embedding: computeEmbedding(extractor: extractor, filename: testFiles[0]), | ||
| 111 | - threshold: threshold); | ||
| 112 | - assert(ok, 'Failed to verify fangjun using ${testFiles[0]}'); | ||
| 113 | - | ||
| 114 | - ok = manager.remove('fangjun'); | ||
| 115 | - assert(ok, 'Failed to remove fangjun'); | ||
| 116 | - assert(manager.numSpeakers == 1, '${manager.numSpeakers}'); | ||
| 117 | - | ||
| 118 | - found = manager.contains('fangjun'); | ||
| 119 | - assert(!found, 'Still found fangjun!'); | ||
| 120 | - | ||
| 121 | - ok = manager.verify( | ||
| 122 | - name: 'fangjun', | ||
| 123 | - embedding: computeEmbedding(extractor: extractor, filename: testFiles[0]), | ||
| 124 | - threshold: threshold); | ||
| 125 | - assert(!ok, '${testFiles[0]}'); | ||
| 126 | - | ||
| 127 | - manager.free(); | ||
| 128 | - extractor.free(); | ||
| 129 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:async'; | ||
| 3 | - | ||
| 4 | -import 'package:flutter/foundation.dart'; | ||
| 5 | -import 'package:flutter/material.dart'; | ||
| 6 | -import 'package:path/path.dart' as p; | ||
| 7 | -import 'package:path_provider/path_provider.dart'; | ||
| 8 | -import 'package:record/record.dart'; | ||
| 9 | - | ||
| 10 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 11 | - | ||
| 12 | -import './utils.dart'; | ||
| 13 | - | ||
| 14 | -import './streaming_transducer_asr_test.dart'; // TODO(fangjun): remove it | ||
| 15 | - | ||
| 16 | -Future<sherpa_onnx.OnlineRecognizer> createOnlineRecognizer() async { | ||
| 17 | - var encoder = | ||
| 18 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.int8.onnx'; | ||
| 19 | - var decoder = | ||
| 20 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx'; | ||
| 21 | - var joiner = | ||
| 22 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.int8.onnx'; | ||
| 23 | - var tokens = | ||
| 24 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt'; | ||
| 25 | - | ||
| 26 | - encoder = await copyAssetFile(src: encoder, dst: 'encoder.onnx'); | ||
| 27 | - decoder = await copyAssetFile(src: decoder, dst: 'decoder.onnx'); | ||
| 28 | - joiner = await copyAssetFile(src: joiner, dst: 'joiner.onnx'); | ||
| 29 | - tokens = await copyAssetFile(src: tokens, dst: 'tokens.txt'); | ||
| 30 | - | ||
| 31 | - final transducer = sherpa_onnx.OnlineTransducerModelConfig( | ||
| 32 | - encoder: encoder, | ||
| 33 | - decoder: decoder, | ||
| 34 | - joiner: joiner, | ||
| 35 | - ); | ||
| 36 | - | ||
| 37 | - final modelConfig = sherpa_onnx.OnlineModelConfig( | ||
| 38 | - transducer: transducer, | ||
| 39 | - tokens: tokens, | ||
| 40 | - modelType: 'zipformer', | ||
| 41 | - ); | ||
| 42 | - | ||
| 43 | - final config = sherpa_onnx.OnlineRecognizerConfig(model: modelConfig); | ||
| 44 | - return sherpa_onnx.OnlineRecognizer(config); | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -class StreamingAsrScreen extends StatefulWidget { | ||
| 48 | - const StreamingAsrScreen({super.key}); | ||
| 49 | - | ||
| 50 | - @override | ||
| 51 | - State<StreamingAsrScreen> createState() => _StreamingAsrScreenState(); | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -class _StreamingAsrScreenState extends State<StreamingAsrScreen> { | ||
| 55 | - late final TextEditingController _controller; | ||
| 56 | - late final AudioRecorder _audioRecorder; | ||
| 57 | - | ||
| 58 | - String _title = 'Real-time speech recognition'; | ||
| 59 | - String _last = ''; | ||
| 60 | - int _index = 0; | ||
| 61 | - bool _isInitialized = false; | ||
| 62 | - | ||
| 63 | - sherpa_onnx.OnlineRecognizer? _recognizer; | ||
| 64 | - sherpa_onnx.OnlineStream? _stream; | ||
| 65 | - int _sampleRate = 16000; | ||
| 66 | - | ||
| 67 | - StreamSubscription<RecordState>? _recordSub; | ||
| 68 | - RecordState _recordState = RecordState.stop; | ||
| 69 | - | ||
| 70 | - @override | ||
| 71 | - void initState() { | ||
| 72 | - _audioRecorder = AudioRecorder(); | ||
| 73 | - _controller = TextEditingController(); | ||
| 74 | - | ||
| 75 | - _recordSub = _audioRecorder.onStateChanged().listen((recordState) { | ||
| 76 | - _updateRecordState(recordState); | ||
| 77 | - }); | ||
| 78 | - | ||
| 79 | - super.initState(); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - Future<void> _start() async { | ||
| 83 | - if (!_isInitialized) { | ||
| 84 | - sherpa_onnx.initBindings(); | ||
| 85 | - _recognizer = await createOnlineRecognizer(); | ||
| 86 | - _stream = _recognizer?.createStream(); | ||
| 87 | - | ||
| 88 | - _isInitialized = true; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - try { | ||
| 92 | - if (await _audioRecorder.hasPermission()) { | ||
| 93 | - const encoder = AudioEncoder.pcm16bits; | ||
| 94 | - | ||
| 95 | - if (!await _isEncoderSupported(encoder)) { | ||
| 96 | - return; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - final devs = await _audioRecorder.listInputDevices(); | ||
| 100 | - debugPrint(devs.toString()); | ||
| 101 | - | ||
| 102 | - const config = RecordConfig( | ||
| 103 | - encoder: encoder, | ||
| 104 | - sampleRate: 16000, | ||
| 105 | - numChannels: 1, | ||
| 106 | - ); | ||
| 107 | - | ||
| 108 | - final stream = await _audioRecorder.startStream(config); | ||
| 109 | - | ||
| 110 | - stream.listen( | ||
| 111 | - (data) { | ||
| 112 | - final samplesFloat32 = | ||
| 113 | - convertBytesToFloat32(Uint8List.fromList(data)); | ||
| 114 | - | ||
| 115 | - _stream!.acceptWaveform( | ||
| 116 | - samples: samplesFloat32, sampleRate: _sampleRate); | ||
| 117 | - while (_recognizer!.isReady(_stream!)) { | ||
| 118 | - _recognizer!.decode(_stream!); | ||
| 119 | - } | ||
| 120 | - final text = _recognizer!.getResult(_stream!).text; | ||
| 121 | - String textToDisplay = _last; | ||
| 122 | - if (text != '') { | ||
| 123 | - if (_last == '') { | ||
| 124 | - textToDisplay = '$_index: $text'; | ||
| 125 | - } else { | ||
| 126 | - textToDisplay = '$_index: $text\n$_last'; | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - if (_recognizer!.isEndpoint(_stream!)) { | ||
| 131 | - _recognizer!.reset(_stream!); | ||
| 132 | - if (text != '') { | ||
| 133 | - _last = textToDisplay; | ||
| 134 | - _index += 1; | ||
| 135 | - } | ||
| 136 | - } | ||
| 137 | - print('text: $textToDisplay'); | ||
| 138 | - | ||
| 139 | - _controller.value = TextEditingValue( | ||
| 140 | - text: textToDisplay, | ||
| 141 | - selection: TextSelection.collapsed(offset: textToDisplay.length), | ||
| 142 | - ); | ||
| 143 | - }, | ||
| 144 | - onDone: () { | ||
| 145 | - print('stream stopped.'); | ||
| 146 | - }, | ||
| 147 | - ); | ||
| 148 | - } | ||
| 149 | - } catch (e) { | ||
| 150 | - print(e); | ||
| 151 | - } | ||
| 152 | - } | ||
| 153 | - | ||
| 154 | - Future<void> _stop() async { | ||
| 155 | - _stream!.free(); | ||
| 156 | - _stream = _recognizer!.createStream(); | ||
| 157 | - | ||
| 158 | - await _audioRecorder.stop(); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - Future<void> _pause() => _audioRecorder.pause(); | ||
| 162 | - | ||
| 163 | - Future<void> _resume() => _audioRecorder.resume(); | ||
| 164 | - | ||
| 165 | - void _updateRecordState(RecordState recordState) { | ||
| 166 | - setState(() => _recordState = recordState); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - Future<bool> _isEncoderSupported(AudioEncoder encoder) async { | ||
| 170 | - final isSupported = await _audioRecorder.isEncoderSupported( | ||
| 171 | - encoder, | ||
| 172 | - ); | ||
| 173 | - | ||
| 174 | - if (!isSupported) { | ||
| 175 | - debugPrint('${encoder.name} is not supported on this platform.'); | ||
| 176 | - debugPrint('Supported encoders are:'); | ||
| 177 | - | ||
| 178 | - for (final e in AudioEncoder.values) { | ||
| 179 | - if (await _audioRecorder.isEncoderSupported(e)) { | ||
| 180 | - debugPrint('- ${encoder.name}'); | ||
| 181 | - } | ||
| 182 | - } | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - return isSupported; | ||
| 186 | - } | ||
| 187 | - | ||
| 188 | - @override | ||
| 189 | - Widget build(BuildContext context) { | ||
| 190 | - return MaterialApp( | ||
| 191 | - home: Scaffold( | ||
| 192 | - body: Column( | ||
| 193 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 194 | - children: [ | ||
| 195 | - Text(_title), | ||
| 196 | - const SizedBox(height: 50), | ||
| 197 | - TextField( | ||
| 198 | - maxLines: 5, | ||
| 199 | - controller: _controller, | ||
| 200 | - readOnly: true, | ||
| 201 | - ), | ||
| 202 | - const SizedBox(height: 50), | ||
| 203 | - Row( | ||
| 204 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 205 | - children: <Widget>[ | ||
| 206 | - _buildRecordStopControl(), | ||
| 207 | - const SizedBox(width: 20), | ||
| 208 | - _buildText(), | ||
| 209 | - ], | ||
| 210 | - ), | ||
| 211 | - ], | ||
| 212 | - ), | ||
| 213 | - ), | ||
| 214 | - ); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - @override | ||
| 218 | - void dispose() { | ||
| 219 | - _recordSub?.cancel(); | ||
| 220 | - _audioRecorder.dispose(); | ||
| 221 | - _stream?.free(); | ||
| 222 | - _recognizer?.free(); | ||
| 223 | - super.dispose(); | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - Widget _buildRecordStopControl() { | ||
| 227 | - late Icon icon; | ||
| 228 | - late Color color; | ||
| 229 | - | ||
| 230 | - if (_recordState != RecordState.stop) { | ||
| 231 | - icon = const Icon(Icons.stop, color: Colors.red, size: 30); | ||
| 232 | - color = Colors.red.withOpacity(0.1); | ||
| 233 | - } else { | ||
| 234 | - final theme = Theme.of(context); | ||
| 235 | - icon = Icon(Icons.mic, color: theme.primaryColor, size: 30); | ||
| 236 | - color = theme.primaryColor.withOpacity(0.1); | ||
| 237 | - } | ||
| 238 | - | ||
| 239 | - return ClipOval( | ||
| 240 | - child: Material( | ||
| 241 | - color: color, | ||
| 242 | - child: InkWell( | ||
| 243 | - child: SizedBox(width: 56, height: 56, child: icon), | ||
| 244 | - onTap: () { | ||
| 245 | - (_recordState != RecordState.stop) ? _stop() : _start(); | ||
| 246 | - }, | ||
| 247 | - ), | ||
| 248 | - ), | ||
| 249 | - ); | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | - Widget _buildText() { | ||
| 253 | - if (_recordState == RecordState.stop) { | ||
| 254 | - return const Text("Start"); | ||
| 255 | - } else { | ||
| 256 | - return const Text("Stop"); | ||
| 257 | - } | ||
| 258 | - } | ||
| 259 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:path/path.dart'; | ||
| 3 | -import 'package:path_provider/path_provider.dart'; | ||
| 4 | -import 'package:flutter/services.dart' show rootBundle; | ||
| 5 | -import 'dart:typed_data'; | ||
| 6 | -import "dart:io"; | ||
| 7 | - | ||
| 8 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 9 | -import './utils.dart'; | ||
| 10 | - | ||
| 11 | -Future<void> testStreamingTransducerAsr() async { | ||
| 12 | - var encoder = | ||
| 13 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.int8.onnx'; | ||
| 14 | - var decoder = | ||
| 15 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx'; | ||
| 16 | - var joiner = | ||
| 17 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.int8.onnx'; | ||
| 18 | - var tokens = | ||
| 19 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt'; | ||
| 20 | - | ||
| 21 | - var testWave = | ||
| 22 | - 'assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/0.wav'; | ||
| 23 | - | ||
| 24 | - encoder = await copyAssetFile(src: encoder, dst: 'encoder.onnx'); | ||
| 25 | - decoder = await copyAssetFile(src: decoder, dst: 'decoder.onnx'); | ||
| 26 | - joiner = await copyAssetFile(src: joiner, dst: 'joiner.onnx'); | ||
| 27 | - tokens = await copyAssetFile(src: tokens, dst: 'tokens.txt'); | ||
| 28 | - testWave = await copyAssetFile(src: testWave, dst: 'test.wav'); | ||
| 29 | - | ||
| 30 | - final transducer = sherpa_onnx.OnlineTransducerModelConfig( | ||
| 31 | - encoder: encoder, | ||
| 32 | - decoder: decoder, | ||
| 33 | - joiner: joiner, | ||
| 34 | - ); | ||
| 35 | - | ||
| 36 | - final modelConfig = sherpa_onnx.OnlineModelConfig( | ||
| 37 | - transducer: transducer, | ||
| 38 | - tokens: tokens, | ||
| 39 | - modelType: 'zipformer', | ||
| 40 | - ); | ||
| 41 | - | ||
| 42 | - final config = sherpa_onnx.OnlineRecognizerConfig(model: modelConfig); | ||
| 43 | - print(config); | ||
| 44 | - final recognizer = sherpa_onnx.OnlineRecognizer(config); | ||
| 45 | - | ||
| 46 | - final waveData = sherpa_onnx.readWave(testWave); | ||
| 47 | - final stream = recognizer.createStream(); | ||
| 48 | - | ||
| 49 | - stream.acceptWaveform( | ||
| 50 | - samples: waveData.samples, sampleRate: waveData.sampleRate); | ||
| 51 | - while (recognizer.isReady(stream)) { | ||
| 52 | - recognizer.decode(stream); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - final result = recognizer.getResult(stream); | ||
| 56 | - print('result is: ${result}'); | ||
| 57 | - | ||
| 58 | - print('recognizer: ${recognizer.ptr}'); | ||
| 59 | - stream.free(); | ||
| 60 | - recognizer.free(); | ||
| 61 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'package:path/path.dart'; | ||
| 3 | -import 'package:path_provider/path_provider.dart'; | ||
| 4 | -import 'package:flutter/services.dart' show rootBundle; | ||
| 5 | -import 'dart:typed_data'; | ||
| 6 | -import "dart:io"; | ||
| 7 | - | ||
| 8 | -// Copy the asset file from src to dst | ||
| 9 | -Future<String> copyAssetFile({required String src, required String dst}) async { | ||
| 10 | - final Directory directory = await getApplicationDocumentsDirectory(); | ||
| 11 | - final target = join(directory.path, dst); | ||
| 12 | - | ||
| 13 | - final data = await rootBundle.load(src); | ||
| 14 | - final List<int> bytes = | ||
| 15 | - data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); | ||
| 16 | - await File(target).writeAsBytes(bytes); | ||
| 17 | - | ||
| 18 | - return target; | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -Float32List convertBytesToFloat32(Uint8List bytes, [endian = Endian.little]) { | ||
| 22 | - final values = Float32List(bytes.length ~/ 2); | ||
| 23 | - | ||
| 24 | - final data = ByteData.view(bytes.buffer); | ||
| 25 | - | ||
| 26 | - for (var i = 0; i < bytes.length; i += 2) { | ||
| 27 | - int short = data.getInt16(i, endian); | ||
| 28 | - values[i ~/ 2] = short / 32678.0; | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - return values; | ||
| 32 | -} |
sherpa-onnx/flutter/example/lib/vad.dart
已删除
100644 → 0
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:async'; | ||
| 3 | - | ||
| 4 | -import 'package:flutter/foundation.dart'; | ||
| 5 | -import 'package:flutter/material.dart'; | ||
| 6 | -import 'package:path/path.dart' as p; | ||
| 7 | -import 'package:path_provider/path_provider.dart'; | ||
| 8 | -import 'package:record/record.dart'; | ||
| 9 | - | ||
| 10 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 11 | - | ||
| 12 | -import './utils.dart'; | ||
| 13 | - | ||
| 14 | -class VadScreen extends StatefulWidget { | ||
| 15 | - const VadScreen({super.key}); | ||
| 16 | - | ||
| 17 | - @override | ||
| 18 | - State<VadScreen> createState() => _VadScreenState(); | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -class _VadScreenState extends State<VadScreen> { | ||
| 22 | - late final AudioRecorder _audioRecorder; | ||
| 23 | - | ||
| 24 | - bool _printed = false; | ||
| 25 | - var _color = Colors.black; | ||
| 26 | - bool _isInitialized = false; | ||
| 27 | - | ||
| 28 | - sherpa_onnx.VoiceActivityDetector? _vad; | ||
| 29 | - sherpa_onnx.CircularBuffer? _buffer; | ||
| 30 | - | ||
| 31 | - StreamSubscription<RecordState>? _recordSub; | ||
| 32 | - RecordState _recordState = RecordState.stop; | ||
| 33 | - | ||
| 34 | - @override | ||
| 35 | - void initState() { | ||
| 36 | - _audioRecorder = AudioRecorder(); | ||
| 37 | - | ||
| 38 | - _recordSub = _audioRecorder.onStateChanged().listen((recordState) { | ||
| 39 | - _updateRecordState(recordState); | ||
| 40 | - }); | ||
| 41 | - | ||
| 42 | - super.initState(); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - Future<void> _start() async { | ||
| 46 | - if (!_isInitialized) { | ||
| 47 | - sherpa_onnx.initBindings(); | ||
| 48 | - final src = 'assets/silero_vad.onnx'; | ||
| 49 | - final modelPath = await copyAssetFile(src: src, dst: 'silero_vad.onnx'); | ||
| 50 | - | ||
| 51 | - final sileroVadConfig = sherpa_onnx.SileroVadModelConfig( | ||
| 52 | - model: modelPath, | ||
| 53 | - minSpeechDuration: 0.25, | ||
| 54 | - minSilenceDuration: 0.5, | ||
| 55 | - ); | ||
| 56 | - | ||
| 57 | - final config = sherpa_onnx.VadModelConfig( | ||
| 58 | - sileroVad: sileroVadConfig, | ||
| 59 | - numThreads: 1, | ||
| 60 | - debug: true, | ||
| 61 | - ); | ||
| 62 | - | ||
| 63 | - _vad = sherpa_onnx.VoiceActivityDetector( | ||
| 64 | - config: config, bufferSizeInSeconds: 30); | ||
| 65 | - | ||
| 66 | - _buffer = sherpa_onnx.CircularBuffer(capacity: 16000 * 30); | ||
| 67 | - print(_buffer!.ptr); | ||
| 68 | - | ||
| 69 | - _isInitialized = true; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - try { | ||
| 73 | - if (await _audioRecorder.hasPermission()) { | ||
| 74 | - const encoder = AudioEncoder.pcm16bits; | ||
| 75 | - | ||
| 76 | - if (!await _isEncoderSupported(encoder)) { | ||
| 77 | - return; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - final devs = await _audioRecorder.listInputDevices(); | ||
| 81 | - debugPrint(devs.toString()); | ||
| 82 | - | ||
| 83 | - const config = RecordConfig( | ||
| 84 | - encoder: encoder, | ||
| 85 | - sampleRate: 16000, | ||
| 86 | - numChannels: 1, | ||
| 87 | - ); | ||
| 88 | - | ||
| 89 | - final stream = await _audioRecorder.startStream(config); | ||
| 90 | - | ||
| 91 | - final dir = await getApplicationDocumentsDirectory(); | ||
| 92 | - | ||
| 93 | - stream.listen( | ||
| 94 | - (data) { | ||
| 95 | - final samplesFloat32 = | ||
| 96 | - convertBytesToFloat32(Uint8List.fromList(data)); | ||
| 97 | - | ||
| 98 | - _buffer!.push(samplesFloat32); | ||
| 99 | - | ||
| 100 | - final windowSize = _vad!.config.sileroVad.windowSize; | ||
| 101 | - while (_buffer!.size > windowSize) { | ||
| 102 | - final samples = | ||
| 103 | - _buffer!.get(startIndex: _buffer!.head, n: windowSize); | ||
| 104 | - _buffer!.pop(windowSize); | ||
| 105 | - _vad!.acceptWaveform(samples); | ||
| 106 | - if (_vad!.isDetected() && !_printed) { | ||
| 107 | - print('detected'); | ||
| 108 | - _printed = true; | ||
| 109 | - | ||
| 110 | - setState(() => _color = Colors.red); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - if (!_vad!.isDetected()) { | ||
| 114 | - _printed = false; | ||
| 115 | - setState(() => _color = Colors.black); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - while (!_vad!.isEmpty()) { | ||
| 119 | - final segment = _vad!.front(); | ||
| 120 | - final duration = segment.samples.length / 16000; | ||
| 121 | - final d = DateTime.now(); | ||
| 122 | - final filename = p.join(dir.path, | ||
| 123 | - '${d.year}-${d.month}-${d.day}-${d.hour}-${d.minute}-${d.second}-duration-${duration.toStringAsPrecision(3)}s.wav'); | ||
| 124 | - | ||
| 125 | - bool ok = sherpa_onnx.writeWave( | ||
| 126 | - filename: filename, | ||
| 127 | - samples: segment.samples, | ||
| 128 | - sampleRate: 16000); | ||
| 129 | - if (!ok) { | ||
| 130 | - print('Failed to write $filename'); | ||
| 131 | - } else { | ||
| 132 | - print('Saved to write $filename'); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - _vad!.pop(); | ||
| 136 | - } | ||
| 137 | - } | ||
| 138 | - }, | ||
| 139 | - onDone: () { | ||
| 140 | - print('stream stopped.'); | ||
| 141 | - }, | ||
| 142 | - ); | ||
| 143 | - } | ||
| 144 | - } catch (e) { | ||
| 145 | - print(e); | ||
| 146 | - } | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - Future<void> _stop() async { | ||
| 150 | - _buffer!.reset(); | ||
| 151 | - _vad!.clear(); | ||
| 152 | - | ||
| 153 | - await _audioRecorder.stop(); | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - Future<void> _pause() => _audioRecorder.pause(); | ||
| 157 | - | ||
| 158 | - Future<void> _resume() => _audioRecorder.resume(); | ||
| 159 | - | ||
| 160 | - void _updateRecordState(RecordState recordState) { | ||
| 161 | - setState(() => _recordState = recordState); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - Future<bool> _isEncoderSupported(AudioEncoder encoder) async { | ||
| 165 | - final isSupported = await _audioRecorder.isEncoderSupported( | ||
| 166 | - encoder, | ||
| 167 | - ); | ||
| 168 | - | ||
| 169 | - if (!isSupported) { | ||
| 170 | - debugPrint('${encoder.name} is not supported on this platform.'); | ||
| 171 | - debugPrint('Supported encoders are:'); | ||
| 172 | - | ||
| 173 | - for (final e in AudioEncoder.values) { | ||
| 174 | - if (await _audioRecorder.isEncoderSupported(e)) { | ||
| 175 | - debugPrint('- ${encoder.name}'); | ||
| 176 | - } | ||
| 177 | - } | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - return isSupported; | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - @override | ||
| 184 | - Widget build(BuildContext context) { | ||
| 185 | - return MaterialApp( | ||
| 186 | - home: Scaffold( | ||
| 187 | - body: Column( | ||
| 188 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 189 | - children: [ | ||
| 190 | - Container( | ||
| 191 | - width: 100.0, | ||
| 192 | - height: 100.0, | ||
| 193 | - decoration: BoxDecoration( | ||
| 194 | - shape: BoxShape.circle, | ||
| 195 | - color: _color, | ||
| 196 | - ), | ||
| 197 | - ), | ||
| 198 | - const SizedBox(height: 50), | ||
| 199 | - Row( | ||
| 200 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 201 | - children: <Widget>[ | ||
| 202 | - _buildRecordStopControl(), | ||
| 203 | - const SizedBox(width: 20), | ||
| 204 | - _buildText(), | ||
| 205 | - ], | ||
| 206 | - ), | ||
| 207 | - ], | ||
| 208 | - ), | ||
| 209 | - ), | ||
| 210 | - ); | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - @override | ||
| 214 | - void dispose() { | ||
| 215 | - _recordSub?.cancel(); | ||
| 216 | - _audioRecorder.dispose(); | ||
| 217 | - _vad?.free(); | ||
| 218 | - _buffer?.free(); | ||
| 219 | - super.dispose(); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - Widget _buildRecordStopControl() { | ||
| 223 | - late Icon icon; | ||
| 224 | - late Color color; | ||
| 225 | - | ||
| 226 | - if (_recordState != RecordState.stop) { | ||
| 227 | - icon = const Icon(Icons.stop, color: Colors.red, size: 30); | ||
| 228 | - color = Colors.red.withOpacity(0.1); | ||
| 229 | - } else { | ||
| 230 | - final theme = Theme.of(context); | ||
| 231 | - icon = Icon(Icons.mic, color: theme.primaryColor, size: 30); | ||
| 232 | - color = theme.primaryColor.withOpacity(0.1); | ||
| 233 | - } | ||
| 234 | - | ||
| 235 | - return ClipOval( | ||
| 236 | - child: Material( | ||
| 237 | - color: color, | ||
| 238 | - child: InkWell( | ||
| 239 | - child: SizedBox(width: 56, height: 56, child: icon), | ||
| 240 | - onTap: () { | ||
| 241 | - (_recordState != RecordState.stop) ? _stop() : _start(); | ||
| 242 | - }, | ||
| 243 | - ), | ||
| 244 | - ), | ||
| 245 | - ); | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - Widget _buildText() { | ||
| 249 | - if (_recordState == RecordState.stop) { | ||
| 250 | - return const Text("Start"); | ||
| 251 | - } else { | ||
| 252 | - return const Text("Stop"); | ||
| 253 | - } | ||
| 254 | - } | ||
| 255 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:typed_data'; | ||
| 3 | -import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 4 | -import './utils.dart'; | ||
| 5 | - | ||
| 6 | -Future<void> testVad() async { | ||
| 7 | - final src = 'assets/silero_vad.onnx'; | ||
| 8 | - final modelPath = await copyAssetFile(src: src, dst: 'silero_vad.onnx'); | ||
| 9 | - | ||
| 10 | - final sileroVadConfig = sherpa_onnx.SileroVadModelConfig(model: modelPath); | ||
| 11 | - final config = sherpa_onnx.VadModelConfig( | ||
| 12 | - sileroVad: sileroVadConfig, | ||
| 13 | - numThreads: 1, | ||
| 14 | - debug: true, | ||
| 15 | - ); | ||
| 16 | - | ||
| 17 | - final vad = sherpa_onnx.VoiceActivityDetector( | ||
| 18 | - config: config, bufferSizeInSeconds: 10); | ||
| 19 | - print('before vad.free(): ${vad.ptr}'); | ||
| 20 | - vad.free(); | ||
| 21 | - print('after vad.free(): ${vad.ptr}'); | ||
| 22 | - | ||
| 23 | - final buffer = sherpa_onnx.CircularBuffer(capacity: 16000 * 2); | ||
| 24 | - | ||
| 25 | - final d = Float32List.fromList([0, 10, 20, 30]); | ||
| 26 | - buffer.push(d); | ||
| 27 | - assert(d.length == buffer.size, '${d.length} vs ${buffer.size}'); | ||
| 28 | - | ||
| 29 | - final f = Float32List.fromList([-5, 100.25, 599]); | ||
| 30 | - buffer.push(f); | ||
| 31 | - | ||
| 32 | - assert(buffer.size == d.length + f.length); | ||
| 33 | - final g = buffer.get(startIndex: 0, n: 5); | ||
| 34 | - | ||
| 35 | - assert(g.length == 5); | ||
| 36 | - assert(g[0] == 0); | ||
| 37 | - assert(g[1] == 10); | ||
| 38 | - assert(g[2] == 20); | ||
| 39 | - assert(g[3] == 30); | ||
| 40 | - assert(g[4] == -5); | ||
| 41 | - | ||
| 42 | - assert(buffer.size == d.length + f.length); | ||
| 43 | - | ||
| 44 | - buffer.pop(3); | ||
| 45 | - assert(buffer.size == d.length + f.length - 3); | ||
| 46 | - | ||
| 47 | - final h = buffer.get(startIndex: buffer.head, n: 4); | ||
| 48 | - assert(h.length == 4); | ||
| 49 | - assert(h[0] == 30); | ||
| 50 | - assert(h[1] == -5); | ||
| 51 | - assert(h[2] == 100.25); | ||
| 52 | - assert(h[3] == 599); | ||
| 53 | - | ||
| 54 | - buffer.reset(); | ||
| 55 | - | ||
| 56 | - assert(buffer.size == 0); | ||
| 57 | - assert(buffer.head == 0); | ||
| 58 | - | ||
| 59 | - print('before free: ${buffer.ptr}'); | ||
| 60 | - buffer.free(); | ||
| 61 | - print('after free: ${buffer.ptr}'); | ||
| 62 | -} |
| 1 | -flutter/ephemeral |
| 1 | -# Project-level configuration. | ||
| 2 | -cmake_minimum_required(VERSION 3.10) | ||
| 3 | -project(runner LANGUAGES CXX) | ||
| 4 | - | ||
| 5 | -# The name of the executable created for the application. Change this to change | ||
| 6 | -# the on-disk name of your application. | ||
| 7 | -set(BINARY_NAME "sherpa_onnx") | ||
| 8 | -# The unique GTK application identifier for this application. See: | ||
| 9 | -# https://wiki.gnome.org/HowDoI/ChooseApplicationID | ||
| 10 | -set(APPLICATION_ID "com.k2fsa.sherpa.onnx") | ||
| 11 | - | ||
| 12 | -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent | ||
| 13 | -# versions of CMake. | ||
| 14 | -cmake_policy(SET CMP0063 NEW) | ||
| 15 | - | ||
| 16 | -# Load bundled libraries from the lib/ directory relative to the binary. | ||
| 17 | -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") | ||
| 18 | - | ||
| 19 | -# Root filesystem for cross-building. | ||
| 20 | -if(FLUTTER_TARGET_PLATFORM_SYSROOT) | ||
| 21 | - set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) | ||
| 22 | - set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) | ||
| 23 | - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| 24 | - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
| 25 | - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| 26 | - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
| 27 | -endif() | ||
| 28 | - | ||
| 29 | -# Define build configuration options. | ||
| 30 | -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
| 31 | - set(CMAKE_BUILD_TYPE "Debug" CACHE | ||
| 32 | - STRING "Flutter build mode" FORCE) | ||
| 33 | - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
| 34 | - "Debug" "Profile" "Release") | ||
| 35 | -endif() | ||
| 36 | - | ||
| 37 | -# Compilation settings that should be applied to most targets. | ||
| 38 | -# | ||
| 39 | -# Be cautious about adding new options here, as plugins use this function by | ||
| 40 | -# default. In most cases, you should add new options to specific targets instead | ||
| 41 | -# of modifying this function. | ||
| 42 | -function(APPLY_STANDARD_SETTINGS TARGET) | ||
| 43 | - target_compile_features(${TARGET} PUBLIC cxx_std_14) | ||
| 44 | - target_compile_options(${TARGET} PRIVATE -Wall -Werror) | ||
| 45 | - target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") | ||
| 46 | - target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") | ||
| 47 | -endfunction() | ||
| 48 | - | ||
| 49 | -# Flutter library and tool build rules. | ||
| 50 | -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") | ||
| 51 | -add_subdirectory(${FLUTTER_MANAGED_DIR}) | ||
| 52 | - | ||
| 53 | -# System-level dependencies. | ||
| 54 | -find_package(PkgConfig REQUIRED) | ||
| 55 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
| 56 | - | ||
| 57 | -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") | ||
| 58 | - | ||
| 59 | -# Define the application target. To change its name, change BINARY_NAME above, | ||
| 60 | -# not the value here, or `flutter run` will no longer work. | ||
| 61 | -# | ||
| 62 | -# Any new source files that you add to the application should be added here. | ||
| 63 | -add_executable(${BINARY_NAME} | ||
| 64 | - "main.cc" | ||
| 65 | - "my_application.cc" | ||
| 66 | - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
| 67 | -) | ||
| 68 | - | ||
| 69 | -# Apply the standard set of build settings. This can be removed for applications | ||
| 70 | -# that need different build settings. | ||
| 71 | -apply_standard_settings(${BINARY_NAME}) | ||
| 72 | - | ||
| 73 | -# Add dependency libraries. Add any application-specific dependencies here. | ||
| 74 | -target_link_libraries(${BINARY_NAME} PRIVATE flutter) | ||
| 75 | -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) | ||
| 76 | - | ||
| 77 | -# Run the Flutter tool portions of the build. This must not be removed. | ||
| 78 | -add_dependencies(${BINARY_NAME} flutter_assemble) | ||
| 79 | - | ||
| 80 | -# Only the install-generated bundle's copy of the executable will launch | ||
| 81 | -# correctly, since the resources must in the right relative locations. To avoid | ||
| 82 | -# people trying to run the unbundled copy, put it in a subdirectory instead of | ||
| 83 | -# the default top-level location. | ||
| 84 | -set_target_properties(${BINARY_NAME} | ||
| 85 | - PROPERTIES | ||
| 86 | - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" | ||
| 87 | -) | ||
| 88 | - | ||
| 89 | - | ||
| 90 | -# Generated plugin build rules, which manage building the plugins and adding | ||
| 91 | -# them to the application. | ||
| 92 | -include(flutter/generated_plugins.cmake) | ||
| 93 | - | ||
| 94 | - | ||
| 95 | -# === Installation === | ||
| 96 | -# By default, "installing" just makes a relocatable bundle in the build | ||
| 97 | -# directory. | ||
| 98 | -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") | ||
| 99 | -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
| 100 | - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) | ||
| 101 | -endif() | ||
| 102 | - | ||
| 103 | -# Start with a clean build bundle directory every time. | ||
| 104 | -install(CODE " | ||
| 105 | - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") | ||
| 106 | - " COMPONENT Runtime) | ||
| 107 | - | ||
| 108 | -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") | ||
| 109 | -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") | ||
| 110 | - | ||
| 111 | -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" | ||
| 112 | - COMPONENT Runtime) | ||
| 113 | - | ||
| 114 | -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
| 115 | - COMPONENT Runtime) | ||
| 116 | - | ||
| 117 | -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 118 | - COMPONENT Runtime) | ||
| 119 | - | ||
| 120 | -foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) | ||
| 121 | - install(FILES "${bundled_library}" | ||
| 122 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 123 | - COMPONENT Runtime) | ||
| 124 | -endforeach(bundled_library) | ||
| 125 | - | ||
| 126 | -# Copy the native assets provided by the build.dart from all packages. | ||
| 127 | -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") | ||
| 128 | -install(DIRECTORY "${NATIVE_ASSETS_DIR}" | ||
| 129 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 130 | - COMPONENT Runtime) | ||
| 131 | - | ||
| 132 | -# Fully re-copy the assets directory on each build to avoid having stale files | ||
| 133 | -# from a previous install. | ||
| 134 | -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") | ||
| 135 | -install(CODE " | ||
| 136 | - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") | ||
| 137 | - " COMPONENT Runtime) | ||
| 138 | -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" | ||
| 139 | - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) | ||
| 140 | - | ||
| 141 | -# Install the AOT library on non-Debug builds only. | ||
| 142 | -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") | ||
| 143 | - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 144 | - COMPONENT Runtime) | ||
| 145 | -endif() |
| 1 | -# This file controls Flutter-level build steps. It should not be edited. | ||
| 2 | -cmake_minimum_required(VERSION 3.10) | ||
| 3 | - | ||
| 4 | -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
| 5 | - | ||
| 6 | -# Configuration provided via flutter tool. | ||
| 7 | -include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
| 8 | - | ||
| 9 | -# TODO: Move the rest of this into files in ephemeral. See | ||
| 10 | -# https://github.com/flutter/flutter/issues/57146. | ||
| 11 | - | ||
| 12 | -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), | ||
| 13 | -# which isn't available in 3.10. | ||
| 14 | -function(list_prepend LIST_NAME PREFIX) | ||
| 15 | - set(NEW_LIST "") | ||
| 16 | - foreach(element ${${LIST_NAME}}) | ||
| 17 | - list(APPEND NEW_LIST "${PREFIX}${element}") | ||
| 18 | - endforeach(element) | ||
| 19 | - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) | ||
| 20 | -endfunction() | ||
| 21 | - | ||
| 22 | -# === Flutter Library === | ||
| 23 | -# System-level dependencies. | ||
| 24 | -find_package(PkgConfig REQUIRED) | ||
| 25 | -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
| 26 | -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
| 27 | -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) | ||
| 28 | - | ||
| 29 | -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") | ||
| 30 | - | ||
| 31 | -# Published to parent scope for install step. | ||
| 32 | -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
| 33 | -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
| 34 | -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
| 35 | -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) | ||
| 36 | - | ||
| 37 | -list(APPEND FLUTTER_LIBRARY_HEADERS | ||
| 38 | - "fl_basic_message_channel.h" | ||
| 39 | - "fl_binary_codec.h" | ||
| 40 | - "fl_binary_messenger.h" | ||
| 41 | - "fl_dart_project.h" | ||
| 42 | - "fl_engine.h" | ||
| 43 | - "fl_json_message_codec.h" | ||
| 44 | - "fl_json_method_codec.h" | ||
| 45 | - "fl_message_codec.h" | ||
| 46 | - "fl_method_call.h" | ||
| 47 | - "fl_method_channel.h" | ||
| 48 | - "fl_method_codec.h" | ||
| 49 | - "fl_method_response.h" | ||
| 50 | - "fl_plugin_registrar.h" | ||
| 51 | - "fl_plugin_registry.h" | ||
| 52 | - "fl_standard_message_codec.h" | ||
| 53 | - "fl_standard_method_codec.h" | ||
| 54 | - "fl_string_codec.h" | ||
| 55 | - "fl_value.h" | ||
| 56 | - "fl_view.h" | ||
| 57 | - "flutter_linux.h" | ||
| 58 | -) | ||
| 59 | -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") | ||
| 60 | -add_library(flutter INTERFACE) | ||
| 61 | -target_include_directories(flutter INTERFACE | ||
| 62 | - "${EPHEMERAL_DIR}" | ||
| 63 | -) | ||
| 64 | -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") | ||
| 65 | -target_link_libraries(flutter INTERFACE | ||
| 66 | - PkgConfig::GTK | ||
| 67 | - PkgConfig::GLIB | ||
| 68 | - PkgConfig::GIO | ||
| 69 | -) | ||
| 70 | -add_dependencies(flutter flutter_assemble) | ||
| 71 | - | ||
| 72 | -# === Flutter tool backend === | ||
| 73 | -# _phony_ is a non-existent file to force this command to run every time, | ||
| 74 | -# since currently there's no way to get a full input/output list from the | ||
| 75 | -# flutter tool. | ||
| 76 | -add_custom_command( | ||
| 77 | - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
| 78 | - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ | ||
| 79 | - COMMAND ${CMAKE_COMMAND} -E env | ||
| 80 | - ${FLUTTER_TOOL_ENVIRONMENT} | ||
| 81 | - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" | ||
| 82 | - ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} | ||
| 83 | - VERBATIM | ||
| 84 | -) | ||
| 85 | -add_custom_target(flutter_assemble DEPENDS | ||
| 86 | - "${FLUTTER_LIBRARY}" | ||
| 87 | - ${FLUTTER_LIBRARY_HEADERS} | ||
| 88 | -) |
| 1 | -#include "my_application.h" | ||
| 2 | - | ||
| 3 | -#include <flutter_linux/flutter_linux.h> | ||
| 4 | -#ifdef GDK_WINDOWING_X11 | ||
| 5 | -#include <gdk/gdkx.h> | ||
| 6 | -#endif | ||
| 7 | - | ||
| 8 | -#include "flutter/generated_plugin_registrant.h" | ||
| 9 | - | ||
| 10 | -struct _MyApplication { | ||
| 11 | - GtkApplication parent_instance; | ||
| 12 | - char** dart_entrypoint_arguments; | ||
| 13 | -}; | ||
| 14 | - | ||
| 15 | -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) | ||
| 16 | - | ||
| 17 | -// Implements GApplication::activate. | ||
| 18 | -static void my_application_activate(GApplication* application) { | ||
| 19 | - MyApplication* self = MY_APPLICATION(application); | ||
| 20 | - GtkWindow* window = | ||
| 21 | - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); | ||
| 22 | - | ||
| 23 | - // Use a header bar when running in GNOME as this is the common style used | ||
| 24 | - // by applications and is the setup most users will be using (e.g. Ubuntu | ||
| 25 | - // desktop). | ||
| 26 | - // If running on X and not using GNOME then just use a traditional title bar | ||
| 27 | - // in case the window manager does more exotic layout, e.g. tiling. | ||
| 28 | - // If running on Wayland assume the header bar will work (may need changing | ||
| 29 | - // if future cases occur). | ||
| 30 | - gboolean use_header_bar = TRUE; | ||
| 31 | -#ifdef GDK_WINDOWING_X11 | ||
| 32 | - GdkScreen* screen = gtk_window_get_screen(window); | ||
| 33 | - if (GDK_IS_X11_SCREEN(screen)) { | ||
| 34 | - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); | ||
| 35 | - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { | ||
| 36 | - use_header_bar = FALSE; | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | -#endif | ||
| 40 | - if (use_header_bar) { | ||
| 41 | - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
| 42 | - gtk_widget_show(GTK_WIDGET(header_bar)); | ||
| 43 | - gtk_header_bar_set_title(header_bar, "sherpa_onnx"); | ||
| 44 | - gtk_header_bar_set_show_close_button(header_bar, TRUE); | ||
| 45 | - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); | ||
| 46 | - } else { | ||
| 47 | - gtk_window_set_title(window, "sherpa_onnx"); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - gtk_window_set_default_size(window, 1280, 720); | ||
| 51 | - gtk_widget_show(GTK_WIDGET(window)); | ||
| 52 | - | ||
| 53 | - g_autoptr(FlDartProject) project = fl_dart_project_new(); | ||
| 54 | - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); | ||
| 55 | - | ||
| 56 | - FlView* view = fl_view_new(project); | ||
| 57 | - gtk_widget_show(GTK_WIDGET(view)); | ||
| 58 | - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); | ||
| 59 | - | ||
| 60 | - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); | ||
| 61 | - | ||
| 62 | - gtk_widget_grab_focus(GTK_WIDGET(view)); | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | -// Implements GApplication::local_command_line. | ||
| 66 | -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { | ||
| 67 | - MyApplication* self = MY_APPLICATION(application); | ||
| 68 | - // Strip out the first argument as it is the binary name. | ||
| 69 | - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); | ||
| 70 | - | ||
| 71 | - g_autoptr(GError) error = nullptr; | ||
| 72 | - if (!g_application_register(application, nullptr, &error)) { | ||
| 73 | - g_warning("Failed to register: %s", error->message); | ||
| 74 | - *exit_status = 1; | ||
| 75 | - return TRUE; | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - g_application_activate(application); | ||
| 79 | - *exit_status = 0; | ||
| 80 | - | ||
| 81 | - return TRUE; | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -// Implements GApplication::startup. | ||
| 85 | -static void my_application_startup(GApplication* application) { | ||
| 86 | - //MyApplication* self = MY_APPLICATION(object); | ||
| 87 | - | ||
| 88 | - // Perform any actions required at application startup. | ||
| 89 | - | ||
| 90 | - G_APPLICATION_CLASS(my_application_parent_class)->startup(application); | ||
| 91 | -} | ||
| 92 | - | ||
| 93 | -// Implements GApplication::shutdown. | ||
| 94 | -static void my_application_shutdown(GApplication* application) { | ||
| 95 | - //MyApplication* self = MY_APPLICATION(object); | ||
| 96 | - | ||
| 97 | - // Perform any actions required at application shutdown. | ||
| 98 | - | ||
| 99 | - G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); | ||
| 100 | -} | ||
| 101 | - | ||
| 102 | -// Implements GObject::dispose. | ||
| 103 | -static void my_application_dispose(GObject* object) { | ||
| 104 | - MyApplication* self = MY_APPLICATION(object); | ||
| 105 | - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); | ||
| 106 | - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | -static void my_application_class_init(MyApplicationClass* klass) { | ||
| 110 | - G_APPLICATION_CLASS(klass)->activate = my_application_activate; | ||
| 111 | - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; | ||
| 112 | - G_APPLICATION_CLASS(klass)->startup = my_application_startup; | ||
| 113 | - G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; | ||
| 114 | - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | -static void my_application_init(MyApplication* self) {} | ||
| 118 | - | ||
| 119 | -MyApplication* my_application_new() { | ||
| 120 | - return MY_APPLICATION(g_object_new(my_application_get_type(), | ||
| 121 | - "application-id", APPLICATION_ID, | ||
| 122 | - "flags", G_APPLICATION_NON_UNIQUE, | ||
| 123 | - nullptr)); | ||
| 124 | -} |
| 1 | -#ifndef FLUTTER_MY_APPLICATION_H_ | ||
| 2 | -#define FLUTTER_MY_APPLICATION_H_ | ||
| 3 | - | ||
| 4 | -#include <gtk/gtk.h> | ||
| 5 | - | ||
| 6 | -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, | ||
| 7 | - GtkApplication) | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * my_application_new: | ||
| 11 | - * | ||
| 12 | - * Creates a new Flutter-based application. | ||
| 13 | - * | ||
| 14 | - * Returns: a new #MyApplication. | ||
| 15 | - */ | ||
| 16 | -MyApplication* my_application_new(); | ||
| 17 | - | ||
| 18 | -#endif // FLUTTER_MY_APPLICATION_H_ |
| 1 | -platform :osx, '10.15' | ||
| 2 | - | ||
| 3 | -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
| 4 | -ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
| 5 | - | ||
| 6 | -project 'Runner', { | ||
| 7 | - 'Debug' => :debug, | ||
| 8 | - 'Profile' => :release, | ||
| 9 | - 'Release' => :release, | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -def flutter_root | ||
| 13 | - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) | ||
| 14 | - unless File.exist?(generated_xcode_build_settings_path) | ||
| 15 | - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" | ||
| 16 | - end | ||
| 17 | - | ||
| 18 | - File.foreach(generated_xcode_build_settings_path) do |line| | ||
| 19 | - matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
| 20 | - return matches[1].strip if matches | ||
| 21 | - end | ||
| 22 | - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" | ||
| 23 | -end | ||
| 24 | - | ||
| 25 | -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
| 26 | - | ||
| 27 | -flutter_macos_podfile_setup | ||
| 28 | - | ||
| 29 | -target 'Runner' do | ||
| 30 | - use_frameworks! | ||
| 31 | - use_modular_headers! | ||
| 32 | - | ||
| 33 | - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) | ||
| 34 | - target 'RunnerTests' do | ||
| 35 | - inherit! :search_paths | ||
| 36 | - end | ||
| 37 | -end | ||
| 38 | - | ||
| 39 | -post_install do |installer| | ||
| 40 | - installer.pods_project.targets.each do |target| | ||
| 41 | - flutter_additional_macos_build_settings(target) | ||
| 42 | - end | ||
| 43 | -end |
| 1 | -// !$*UTF8*$! | ||
| 2 | -{ | ||
| 3 | - archiveVersion = 1; | ||
| 4 | - classes = { | ||
| 5 | - }; | ||
| 6 | - objectVersion = 54; | ||
| 7 | - objects = { | ||
| 8 | - | ||
| 9 | -/* Begin PBXAggregateTarget section */ | ||
| 10 | - 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { | ||
| 11 | - isa = PBXAggregateTarget; | ||
| 12 | - buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; | ||
| 13 | - buildPhases = ( | ||
| 14 | - 33CC111E2044C6BF0003C045 /* ShellScript */, | ||
| 15 | - ); | ||
| 16 | - dependencies = ( | ||
| 17 | - ); | ||
| 18 | - name = "Flutter Assemble"; | ||
| 19 | - productName = FLX; | ||
| 20 | - }; | ||
| 21 | -/* End PBXAggregateTarget section */ | ||
| 22 | - | ||
| 23 | -/* Begin PBXBuildFile section */ | ||
| 24 | - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; | ||
| 25 | - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; | ||
| 26 | - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; | ||
| 27 | - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; | ||
| 28 | - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; | ||
| 29 | - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; | ||
| 30 | - AD18C81BD25EB64A10A74721 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EEF159F4D7912B9311CB282 /* Pods_Runner.framework */; }; | ||
| 31 | - F1F6B0C655533B7F45E75DA0 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA92A3C1CA5533C24C7C7468 /* Pods_RunnerTests.framework */; }; | ||
| 32 | -/* End PBXBuildFile section */ | ||
| 33 | - | ||
| 34 | -/* Begin PBXContainerItemProxy section */ | ||
| 35 | - 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { | ||
| 36 | - isa = PBXContainerItemProxy; | ||
| 37 | - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; | ||
| 38 | - proxyType = 1; | ||
| 39 | - remoteGlobalIDString = 33CC10EC2044A3C60003C045; | ||
| 40 | - remoteInfo = Runner; | ||
| 41 | - }; | ||
| 42 | - 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { | ||
| 43 | - isa = PBXContainerItemProxy; | ||
| 44 | - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; | ||
| 45 | - proxyType = 1; | ||
| 46 | - remoteGlobalIDString = 33CC111A2044C6BA0003C045; | ||
| 47 | - remoteInfo = FLX; | ||
| 48 | - }; | ||
| 49 | -/* End PBXContainerItemProxy section */ | ||
| 50 | - | ||
| 51 | -/* Begin PBXCopyFilesBuildPhase section */ | ||
| 52 | - 33CC110E2044A8840003C045 /* Bundle Framework */ = { | ||
| 53 | - isa = PBXCopyFilesBuildPhase; | ||
| 54 | - buildActionMask = 2147483647; | ||
| 55 | - dstPath = ""; | ||
| 56 | - dstSubfolderSpec = 10; | ||
| 57 | - files = ( | ||
| 58 | - ); | ||
| 59 | - name = "Bundle Framework"; | ||
| 60 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 61 | - }; | ||
| 62 | -/* End PBXCopyFilesBuildPhase section */ | ||
| 63 | - | ||
| 64 | -/* Begin PBXFileReference section */ | ||
| 65 | - 09EF98B2CF4F049F4C7B5BAA /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; | ||
| 66 | - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 67 | - 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; }; | ||
| 68 | - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; }; | ||
| 69 | - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; }; | ||
| 70 | - 33CC10ED2044A3C60003C045 /* sherpa_onnx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sherpa_onnx.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 71 | - 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; | ||
| 72 | - 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; }; | ||
| 73 | - 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; }; | ||
| 74 | - 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = "<group>"; }; | ||
| 75 | - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = "<group>"; }; | ||
| 76 | - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 77 | - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; }; | ||
| 78 | - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; }; | ||
| 79 | - 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; }; | ||
| 80 | - 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; }; | ||
| 81 | - 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; }; | ||
| 82 | - 3EEF159F4D7912B9311CB282 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 83 | - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; }; | ||
| 84 | - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; }; | ||
| 85 | - A1236548122E91133BF39DA1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 86 | - BA92A3C1CA5533C24C7C7468 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 87 | - C9A014A0AF0A3CC243C5BA0C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; }; | ||
| 88 | - CDC9FAA17691FA4BA5F49074 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; }; | ||
| 89 | - E3A16097032C820A141E3D0C /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 90 | - F7379309434F931B509C87FA /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; }; | ||
| 91 | -/* End PBXFileReference section */ | ||
| 92 | - | ||
| 93 | -/* Begin PBXFrameworksBuildPhase section */ | ||
| 94 | - 331C80D2294CF70F00263BE5 /* Frameworks */ = { | ||
| 95 | - isa = PBXFrameworksBuildPhase; | ||
| 96 | - buildActionMask = 2147483647; | ||
| 97 | - files = ( | ||
| 98 | - F1F6B0C655533B7F45E75DA0 /* Pods_RunnerTests.framework in Frameworks */, | ||
| 99 | - ); | ||
| 100 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 101 | - }; | ||
| 102 | - 33CC10EA2044A3C60003C045 /* Frameworks */ = { | ||
| 103 | - isa = PBXFrameworksBuildPhase; | ||
| 104 | - buildActionMask = 2147483647; | ||
| 105 | - files = ( | ||
| 106 | - AD18C81BD25EB64A10A74721 /* Pods_Runner.framework in Frameworks */, | ||
| 107 | - ); | ||
| 108 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 109 | - }; | ||
| 110 | -/* End PBXFrameworksBuildPhase section */ | ||
| 111 | - | ||
| 112 | -/* Begin PBXGroup section */ | ||
| 113 | - 331C80D6294CF71000263BE5 /* RunnerTests */ = { | ||
| 114 | - isa = PBXGroup; | ||
| 115 | - children = ( | ||
| 116 | - 331C80D7294CF71000263BE5 /* RunnerTests.swift */, | ||
| 117 | - ); | ||
| 118 | - path = RunnerTests; | ||
| 119 | - sourceTree = "<group>"; | ||
| 120 | - }; | ||
| 121 | - 33BA886A226E78AF003329D5 /* Configs */ = { | ||
| 122 | - isa = PBXGroup; | ||
| 123 | - children = ( | ||
| 124 | - 33E5194F232828860026EE4D /* AppInfo.xcconfig */, | ||
| 125 | - 9740EEB21CF90195004384FC /* Debug.xcconfig */, | ||
| 126 | - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, | ||
| 127 | - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, | ||
| 128 | - ); | ||
| 129 | - path = Configs; | ||
| 130 | - sourceTree = "<group>"; | ||
| 131 | - }; | ||
| 132 | - 33CC10E42044A3C60003C045 = { | ||
| 133 | - isa = PBXGroup; | ||
| 134 | - children = ( | ||
| 135 | - 33FAB671232836740065AC1E /* Runner */, | ||
| 136 | - 33CEB47122A05771004F2AC0 /* Flutter */, | ||
| 137 | - 331C80D6294CF71000263BE5 /* RunnerTests */, | ||
| 138 | - 33CC10EE2044A3C60003C045 /* Products */, | ||
| 139 | - D73912EC22F37F3D000D13A0 /* Frameworks */, | ||
| 140 | - 782733D97D5852B42F7DAD3B /* Pods */, | ||
| 141 | - ); | ||
| 142 | - sourceTree = "<group>"; | ||
| 143 | - }; | ||
| 144 | - 33CC10EE2044A3C60003C045 /* Products */ = { | ||
| 145 | - isa = PBXGroup; | ||
| 146 | - children = ( | ||
| 147 | - 33CC10ED2044A3C60003C045 /* sherpa_onnx.app */, | ||
| 148 | - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, | ||
| 149 | - ); | ||
| 150 | - name = Products; | ||
| 151 | - sourceTree = "<group>"; | ||
| 152 | - }; | ||
| 153 | - 33CC11242044D66E0003C045 /* Resources */ = { | ||
| 154 | - isa = PBXGroup; | ||
| 155 | - children = ( | ||
| 156 | - 33CC10F22044A3C60003C045 /* Assets.xcassets */, | ||
| 157 | - 33CC10F42044A3C60003C045 /* MainMenu.xib */, | ||
| 158 | - 33CC10F72044A3C60003C045 /* Info.plist */, | ||
| 159 | - ); | ||
| 160 | - name = Resources; | ||
| 161 | - path = ..; | ||
| 162 | - sourceTree = "<group>"; | ||
| 163 | - }; | ||
| 164 | - 33CEB47122A05771004F2AC0 /* Flutter */ = { | ||
| 165 | - isa = PBXGroup; | ||
| 166 | - children = ( | ||
| 167 | - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, | ||
| 168 | - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, | ||
| 169 | - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, | ||
| 170 | - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, | ||
| 171 | - ); | ||
| 172 | - path = Flutter; | ||
| 173 | - sourceTree = "<group>"; | ||
| 174 | - }; | ||
| 175 | - 33FAB671232836740065AC1E /* Runner */ = { | ||
| 176 | - isa = PBXGroup; | ||
| 177 | - children = ( | ||
| 178 | - 33CC10F02044A3C60003C045 /* AppDelegate.swift */, | ||
| 179 | - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, | ||
| 180 | - 33E51913231747F40026EE4D /* DebugProfile.entitlements */, | ||
| 181 | - 33E51914231749380026EE4D /* Release.entitlements */, | ||
| 182 | - 33CC11242044D66E0003C045 /* Resources */, | ||
| 183 | - 33BA886A226E78AF003329D5 /* Configs */, | ||
| 184 | - ); | ||
| 185 | - path = Runner; | ||
| 186 | - sourceTree = "<group>"; | ||
| 187 | - }; | ||
| 188 | - 782733D97D5852B42F7DAD3B /* Pods */ = { | ||
| 189 | - isa = PBXGroup; | ||
| 190 | - children = ( | ||
| 191 | - A1236548122E91133BF39DA1 /* Pods-Runner.debug.xcconfig */, | ||
| 192 | - 09EF98B2CF4F049F4C7B5BAA /* Pods-Runner.release.xcconfig */, | ||
| 193 | - CDC9FAA17691FA4BA5F49074 /* Pods-Runner.profile.xcconfig */, | ||
| 194 | - E3A16097032C820A141E3D0C /* Pods-RunnerTests.debug.xcconfig */, | ||
| 195 | - C9A014A0AF0A3CC243C5BA0C /* Pods-RunnerTests.release.xcconfig */, | ||
| 196 | - F7379309434F931B509C87FA /* Pods-RunnerTests.profile.xcconfig */, | ||
| 197 | - ); | ||
| 198 | - name = Pods; | ||
| 199 | - path = Pods; | ||
| 200 | - sourceTree = "<group>"; | ||
| 201 | - }; | ||
| 202 | - D73912EC22F37F3D000D13A0 /* Frameworks */ = { | ||
| 203 | - isa = PBXGroup; | ||
| 204 | - children = ( | ||
| 205 | - 3EEF159F4D7912B9311CB282 /* Pods_Runner.framework */, | ||
| 206 | - BA92A3C1CA5533C24C7C7468 /* Pods_RunnerTests.framework */, | ||
| 207 | - ); | ||
| 208 | - name = Frameworks; | ||
| 209 | - sourceTree = "<group>"; | ||
| 210 | - }; | ||
| 211 | -/* End PBXGroup section */ | ||
| 212 | - | ||
| 213 | -/* Begin PBXNativeTarget section */ | ||
| 214 | - 331C80D4294CF70F00263BE5 /* RunnerTests */ = { | ||
| 215 | - isa = PBXNativeTarget; | ||
| 216 | - buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; | ||
| 217 | - buildPhases = ( | ||
| 218 | - A6B10289F00794F0134DF87E /* [CP] Check Pods Manifest.lock */, | ||
| 219 | - 331C80D1294CF70F00263BE5 /* Sources */, | ||
| 220 | - 331C80D2294CF70F00263BE5 /* Frameworks */, | ||
| 221 | - 331C80D3294CF70F00263BE5 /* Resources */, | ||
| 222 | - ); | ||
| 223 | - buildRules = ( | ||
| 224 | - ); | ||
| 225 | - dependencies = ( | ||
| 226 | - 331C80DA294CF71000263BE5 /* PBXTargetDependency */, | ||
| 227 | - ); | ||
| 228 | - name = RunnerTests; | ||
| 229 | - productName = RunnerTests; | ||
| 230 | - productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; | ||
| 231 | - productType = "com.apple.product-type.bundle.unit-test"; | ||
| 232 | - }; | ||
| 233 | - 33CC10EC2044A3C60003C045 /* Runner */ = { | ||
| 234 | - isa = PBXNativeTarget; | ||
| 235 | - buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; | ||
| 236 | - buildPhases = ( | ||
| 237 | - 1CEDB7D27400A1C1B87B926C /* [CP] Check Pods Manifest.lock */, | ||
| 238 | - 33CC10E92044A3C60003C045 /* Sources */, | ||
| 239 | - 33CC10EA2044A3C60003C045 /* Frameworks */, | ||
| 240 | - 33CC10EB2044A3C60003C045 /* Resources */, | ||
| 241 | - 33CC110E2044A8840003C045 /* Bundle Framework */, | ||
| 242 | - 3399D490228B24CF009A79C7 /* ShellScript */, | ||
| 243 | - C2CEDA50A000327A806944DD /* [CP] Embed Pods Frameworks */, | ||
| 244 | - ); | ||
| 245 | - buildRules = ( | ||
| 246 | - ); | ||
| 247 | - dependencies = ( | ||
| 248 | - 33CC11202044C79F0003C045 /* PBXTargetDependency */, | ||
| 249 | - ); | ||
| 250 | - name = Runner; | ||
| 251 | - productName = Runner; | ||
| 252 | - productReference = 33CC10ED2044A3C60003C045 /* sherpa_onnx.app */; | ||
| 253 | - productType = "com.apple.product-type.application"; | ||
| 254 | - }; | ||
| 255 | -/* End PBXNativeTarget section */ | ||
| 256 | - | ||
| 257 | -/* Begin PBXProject section */ | ||
| 258 | - 33CC10E52044A3C60003C045 /* Project object */ = { | ||
| 259 | - isa = PBXProject; | ||
| 260 | - attributes = { | ||
| 261 | - BuildIndependentTargetsInParallel = YES; | ||
| 262 | - LastSwiftUpdateCheck = 0920; | ||
| 263 | - LastUpgradeCheck = 1510; | ||
| 264 | - ORGANIZATIONNAME = ""; | ||
| 265 | - TargetAttributes = { | ||
| 266 | - 331C80D4294CF70F00263BE5 = { | ||
| 267 | - CreatedOnToolsVersion = 14.0; | ||
| 268 | - TestTargetID = 33CC10EC2044A3C60003C045; | ||
| 269 | - }; | ||
| 270 | - 33CC10EC2044A3C60003C045 = { | ||
| 271 | - CreatedOnToolsVersion = 9.2; | ||
| 272 | - LastSwiftMigration = 1100; | ||
| 273 | - ProvisioningStyle = Automatic; | ||
| 274 | - SystemCapabilities = { | ||
| 275 | - com.apple.Sandbox = { | ||
| 276 | - enabled = 1; | ||
| 277 | - }; | ||
| 278 | - }; | ||
| 279 | - }; | ||
| 280 | - 33CC111A2044C6BA0003C045 = { | ||
| 281 | - CreatedOnToolsVersion = 9.2; | ||
| 282 | - ProvisioningStyle = Manual; | ||
| 283 | - }; | ||
| 284 | - }; | ||
| 285 | - }; | ||
| 286 | - buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; | ||
| 287 | - compatibilityVersion = "Xcode 9.3"; | ||
| 288 | - developmentRegion = en; | ||
| 289 | - hasScannedForEncodings = 0; | ||
| 290 | - knownRegions = ( | ||
| 291 | - en, | ||
| 292 | - Base, | ||
| 293 | - ); | ||
| 294 | - mainGroup = 33CC10E42044A3C60003C045; | ||
| 295 | - productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; | ||
| 296 | - projectDirPath = ""; | ||
| 297 | - projectRoot = ""; | ||
| 298 | - targets = ( | ||
| 299 | - 33CC10EC2044A3C60003C045 /* Runner */, | ||
| 300 | - 331C80D4294CF70F00263BE5 /* RunnerTests */, | ||
| 301 | - 33CC111A2044C6BA0003C045 /* Flutter Assemble */, | ||
| 302 | - ); | ||
| 303 | - }; | ||
| 304 | -/* End PBXProject section */ | ||
| 305 | - | ||
| 306 | -/* Begin PBXResourcesBuildPhase section */ | ||
| 307 | - 331C80D3294CF70F00263BE5 /* Resources */ = { | ||
| 308 | - isa = PBXResourcesBuildPhase; | ||
| 309 | - buildActionMask = 2147483647; | ||
| 310 | - files = ( | ||
| 311 | - ); | ||
| 312 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 313 | - }; | ||
| 314 | - 33CC10EB2044A3C60003C045 /* Resources */ = { | ||
| 315 | - isa = PBXResourcesBuildPhase; | ||
| 316 | - buildActionMask = 2147483647; | ||
| 317 | - files = ( | ||
| 318 | - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, | ||
| 319 | - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, | ||
| 320 | - ); | ||
| 321 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 322 | - }; | ||
| 323 | -/* End PBXResourcesBuildPhase section */ | ||
| 324 | - | ||
| 325 | -/* Begin PBXShellScriptBuildPhase section */ | ||
| 326 | - 1CEDB7D27400A1C1B87B926C /* [CP] Check Pods Manifest.lock */ = { | ||
| 327 | - isa = PBXShellScriptBuildPhase; | ||
| 328 | - buildActionMask = 2147483647; | ||
| 329 | - files = ( | ||
| 330 | - ); | ||
| 331 | - inputFileListPaths = ( | ||
| 332 | - ); | ||
| 333 | - inputPaths = ( | ||
| 334 | - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", | ||
| 335 | - "${PODS_ROOT}/Manifest.lock", | ||
| 336 | - ); | ||
| 337 | - name = "[CP] Check Pods Manifest.lock"; | ||
| 338 | - outputFileListPaths = ( | ||
| 339 | - ); | ||
| 340 | - outputPaths = ( | ||
| 341 | - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", | ||
| 342 | - ); | ||
| 343 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 344 | - shellPath = /bin/sh; | ||
| 345 | - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; | ||
| 346 | - showEnvVarsInLog = 0; | ||
| 347 | - }; | ||
| 348 | - 3399D490228B24CF009A79C7 /* ShellScript */ = { | ||
| 349 | - isa = PBXShellScriptBuildPhase; | ||
| 350 | - alwaysOutOfDate = 1; | ||
| 351 | - buildActionMask = 2147483647; | ||
| 352 | - files = ( | ||
| 353 | - ); | ||
| 354 | - inputFileListPaths = ( | ||
| 355 | - ); | ||
| 356 | - inputPaths = ( | ||
| 357 | - ); | ||
| 358 | - outputFileListPaths = ( | ||
| 359 | - ); | ||
| 360 | - outputPaths = ( | ||
| 361 | - ); | ||
| 362 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 363 | - shellPath = /bin/sh; | ||
| 364 | - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; | ||
| 365 | - }; | ||
| 366 | - 33CC111E2044C6BF0003C045 /* ShellScript */ = { | ||
| 367 | - isa = PBXShellScriptBuildPhase; | ||
| 368 | - buildActionMask = 2147483647; | ||
| 369 | - files = ( | ||
| 370 | - ); | ||
| 371 | - inputFileListPaths = ( | ||
| 372 | - Flutter/ephemeral/FlutterInputs.xcfilelist, | ||
| 373 | - ); | ||
| 374 | - inputPaths = ( | ||
| 375 | - Flutter/ephemeral/tripwire, | ||
| 376 | - ); | ||
| 377 | - outputFileListPaths = ( | ||
| 378 | - Flutter/ephemeral/FlutterOutputs.xcfilelist, | ||
| 379 | - ); | ||
| 380 | - outputPaths = ( | ||
| 381 | - ); | ||
| 382 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 383 | - shellPath = /bin/sh; | ||
| 384 | - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; | ||
| 385 | - }; | ||
| 386 | - A6B10289F00794F0134DF87E /* [CP] Check Pods Manifest.lock */ = { | ||
| 387 | - isa = PBXShellScriptBuildPhase; | ||
| 388 | - buildActionMask = 2147483647; | ||
| 389 | - files = ( | ||
| 390 | - ); | ||
| 391 | - inputFileListPaths = ( | ||
| 392 | - ); | ||
| 393 | - inputPaths = ( | ||
| 394 | - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", | ||
| 395 | - "${PODS_ROOT}/Manifest.lock", | ||
| 396 | - ); | ||
| 397 | - name = "[CP] Check Pods Manifest.lock"; | ||
| 398 | - outputFileListPaths = ( | ||
| 399 | - ); | ||
| 400 | - outputPaths = ( | ||
| 401 | - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", | ||
| 402 | - ); | ||
| 403 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 404 | - shellPath = /bin/sh; | ||
| 405 | - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; | ||
| 406 | - showEnvVarsInLog = 0; | ||
| 407 | - }; | ||
| 408 | - C2CEDA50A000327A806944DD /* [CP] Embed Pods Frameworks */ = { | ||
| 409 | - isa = PBXShellScriptBuildPhase; | ||
| 410 | - buildActionMask = 2147483647; | ||
| 411 | - files = ( | ||
| 412 | - ); | ||
| 413 | - inputFileListPaths = ( | ||
| 414 | - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", | ||
| 415 | - ); | ||
| 416 | - name = "[CP] Embed Pods Frameworks"; | ||
| 417 | - outputFileListPaths = ( | ||
| 418 | - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", | ||
| 419 | - ); | ||
| 420 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 421 | - shellPath = /bin/sh; | ||
| 422 | - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; | ||
| 423 | - showEnvVarsInLog = 0; | ||
| 424 | - }; | ||
| 425 | -/* End PBXShellScriptBuildPhase section */ | ||
| 426 | - | ||
| 427 | -/* Begin PBXSourcesBuildPhase section */ | ||
| 428 | - 331C80D1294CF70F00263BE5 /* Sources */ = { | ||
| 429 | - isa = PBXSourcesBuildPhase; | ||
| 430 | - buildActionMask = 2147483647; | ||
| 431 | - files = ( | ||
| 432 | - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, | ||
| 433 | - ); | ||
| 434 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 435 | - }; | ||
| 436 | - 33CC10E92044A3C60003C045 /* Sources */ = { | ||
| 437 | - isa = PBXSourcesBuildPhase; | ||
| 438 | - buildActionMask = 2147483647; | ||
| 439 | - files = ( | ||
| 440 | - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, | ||
| 441 | - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, | ||
| 442 | - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, | ||
| 443 | - ); | ||
| 444 | - runOnlyForDeploymentPostprocessing = 0; | ||
| 445 | - }; | ||
| 446 | -/* End PBXSourcesBuildPhase section */ | ||
| 447 | - | ||
| 448 | -/* Begin PBXTargetDependency section */ | ||
| 449 | - 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { | ||
| 450 | - isa = PBXTargetDependency; | ||
| 451 | - target = 33CC10EC2044A3C60003C045 /* Runner */; | ||
| 452 | - targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; | ||
| 453 | - }; | ||
| 454 | - 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { | ||
| 455 | - isa = PBXTargetDependency; | ||
| 456 | - target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; | ||
| 457 | - targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; | ||
| 458 | - }; | ||
| 459 | -/* End PBXTargetDependency section */ | ||
| 460 | - | ||
| 461 | -/* Begin PBXVariantGroup section */ | ||
| 462 | - 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { | ||
| 463 | - isa = PBXVariantGroup; | ||
| 464 | - children = ( | ||
| 465 | - 33CC10F52044A3C60003C045 /* Base */, | ||
| 466 | - ); | ||
| 467 | - name = MainMenu.xib; | ||
| 468 | - path = Runner; | ||
| 469 | - sourceTree = "<group>"; | ||
| 470 | - }; | ||
| 471 | -/* End PBXVariantGroup section */ | ||
| 472 | - | ||
| 473 | -/* Begin XCBuildConfiguration section */ | ||
| 474 | - 331C80DB294CF71000263BE5 /* Debug */ = { | ||
| 475 | - isa = XCBuildConfiguration; | ||
| 476 | - baseConfigurationReference = E3A16097032C820A141E3D0C /* Pods-RunnerTests.debug.xcconfig */; | ||
| 477 | - buildSettings = { | ||
| 478 | - BUNDLE_LOADER = "$(TEST_HOST)"; | ||
| 479 | - CURRENT_PROJECT_VERSION = 1; | ||
| 480 | - GENERATE_INFOPLIST_FILE = YES; | ||
| 481 | - MARKETING_VERSION = 1.0; | ||
| 482 | - PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx.RunnerTests; | ||
| 483 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 484 | - SWIFT_VERSION = 5.0; | ||
| 485 | - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sherpa_onnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sherpa_onnx"; | ||
| 486 | - }; | ||
| 487 | - name = Debug; | ||
| 488 | - }; | ||
| 489 | - 331C80DC294CF71000263BE5 /* Release */ = { | ||
| 490 | - isa = XCBuildConfiguration; | ||
| 491 | - baseConfigurationReference = C9A014A0AF0A3CC243C5BA0C /* Pods-RunnerTests.release.xcconfig */; | ||
| 492 | - buildSettings = { | ||
| 493 | - BUNDLE_LOADER = "$(TEST_HOST)"; | ||
| 494 | - CURRENT_PROJECT_VERSION = 1; | ||
| 495 | - GENERATE_INFOPLIST_FILE = YES; | ||
| 496 | - MARKETING_VERSION = 1.0; | ||
| 497 | - PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx.RunnerTests; | ||
| 498 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 499 | - SWIFT_VERSION = 5.0; | ||
| 500 | - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sherpa_onnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sherpa_onnx"; | ||
| 501 | - }; | ||
| 502 | - name = Release; | ||
| 503 | - }; | ||
| 504 | - 331C80DD294CF71000263BE5 /* Profile */ = { | ||
| 505 | - isa = XCBuildConfiguration; | ||
| 506 | - baseConfigurationReference = F7379309434F931B509C87FA /* Pods-RunnerTests.profile.xcconfig */; | ||
| 507 | - buildSettings = { | ||
| 508 | - BUNDLE_LOADER = "$(TEST_HOST)"; | ||
| 509 | - CURRENT_PROJECT_VERSION = 1; | ||
| 510 | - GENERATE_INFOPLIST_FILE = YES; | ||
| 511 | - MARKETING_VERSION = 1.0; | ||
| 512 | - PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx.RunnerTests; | ||
| 513 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 514 | - SWIFT_VERSION = 5.0; | ||
| 515 | - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sherpa_onnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sherpa_onnx"; | ||
| 516 | - }; | ||
| 517 | - name = Profile; | ||
| 518 | - }; | ||
| 519 | - 338D0CE9231458BD00FA5F75 /* Profile */ = { | ||
| 520 | - isa = XCBuildConfiguration; | ||
| 521 | - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; | ||
| 522 | - buildSettings = { | ||
| 523 | - ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 524 | - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; | ||
| 525 | - CLANG_ANALYZER_NONNULL = YES; | ||
| 526 | - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
| 527 | - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | ||
| 528 | - CLANG_CXX_LIBRARY = "libc++"; | ||
| 529 | - CLANG_ENABLE_MODULES = YES; | ||
| 530 | - CLANG_ENABLE_OBJC_ARC = YES; | ||
| 531 | - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 532 | - CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 533 | - CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 534 | - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 535 | - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 536 | - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
| 537 | - CLANG_WARN_EMPTY_BODY = YES; | ||
| 538 | - CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 539 | - CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 540 | - CLANG_WARN_INT_CONVERSION = YES; | ||
| 541 | - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 542 | - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 543 | - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 544 | - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 545 | - CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 546 | - CODE_SIGN_IDENTITY = "-"; | ||
| 547 | - COPY_PHASE_STRIP = NO; | ||
| 548 | - DEAD_CODE_STRIPPING = YES; | ||
| 549 | - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
| 550 | - ENABLE_NS_ASSERTIONS = NO; | ||
| 551 | - ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 552 | - ENABLE_USER_SCRIPT_SANDBOXING = NO; | ||
| 553 | - GCC_C_LANGUAGE_STANDARD = gnu11; | ||
| 554 | - GCC_NO_COMMON_BLOCKS = YES; | ||
| 555 | - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 556 | - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 557 | - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 558 | - GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 559 | - GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 560 | - MACOSX_DEPLOYMENT_TARGET = 10.15; | ||
| 561 | - MTL_ENABLE_DEBUG_INFO = NO; | ||
| 562 | - SDKROOT = macosx; | ||
| 563 | - SWIFT_COMPILATION_MODE = wholemodule; | ||
| 564 | - SWIFT_OPTIMIZATION_LEVEL = "-O"; | ||
| 565 | - }; | ||
| 566 | - name = Profile; | ||
| 567 | - }; | ||
| 568 | - 338D0CEA231458BD00FA5F75 /* Profile */ = { | ||
| 569 | - isa = XCBuildConfiguration; | ||
| 570 | - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; | ||
| 571 | - buildSettings = { | ||
| 572 | - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 573 | - CLANG_ENABLE_MODULES = YES; | ||
| 574 | - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; | ||
| 575 | - CODE_SIGN_STYLE = Automatic; | ||
| 576 | - COMBINE_HIDPI_IMAGES = YES; | ||
| 577 | - INFOPLIST_FILE = Runner/Info.plist; | ||
| 578 | - LD_RUNPATH_SEARCH_PATHS = ( | ||
| 579 | - "$(inherited)", | ||
| 580 | - "@executable_path/../Frameworks", | ||
| 581 | - ); | ||
| 582 | - PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| 583 | - SWIFT_VERSION = 5.0; | ||
| 584 | - }; | ||
| 585 | - name = Profile; | ||
| 586 | - }; | ||
| 587 | - 338D0CEB231458BD00FA5F75 /* Profile */ = { | ||
| 588 | - isa = XCBuildConfiguration; | ||
| 589 | - buildSettings = { | ||
| 590 | - CODE_SIGN_STYLE = Manual; | ||
| 591 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 592 | - }; | ||
| 593 | - name = Profile; | ||
| 594 | - }; | ||
| 595 | - 33CC10F92044A3C60003C045 /* Debug */ = { | ||
| 596 | - isa = XCBuildConfiguration; | ||
| 597 | - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; | ||
| 598 | - buildSettings = { | ||
| 599 | - ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 600 | - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; | ||
| 601 | - CLANG_ANALYZER_NONNULL = YES; | ||
| 602 | - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
| 603 | - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | ||
| 604 | - CLANG_CXX_LIBRARY = "libc++"; | ||
| 605 | - CLANG_ENABLE_MODULES = YES; | ||
| 606 | - CLANG_ENABLE_OBJC_ARC = YES; | ||
| 607 | - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 608 | - CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 609 | - CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 610 | - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 611 | - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 612 | - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
| 613 | - CLANG_WARN_EMPTY_BODY = YES; | ||
| 614 | - CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 615 | - CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 616 | - CLANG_WARN_INT_CONVERSION = YES; | ||
| 617 | - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 618 | - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 619 | - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 620 | - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 621 | - CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 622 | - CODE_SIGN_IDENTITY = "-"; | ||
| 623 | - COPY_PHASE_STRIP = NO; | ||
| 624 | - DEAD_CODE_STRIPPING = YES; | ||
| 625 | - DEBUG_INFORMATION_FORMAT = dwarf; | ||
| 626 | - ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 627 | - ENABLE_TESTABILITY = YES; | ||
| 628 | - ENABLE_USER_SCRIPT_SANDBOXING = NO; | ||
| 629 | - GCC_C_LANGUAGE_STANDARD = gnu11; | ||
| 630 | - GCC_DYNAMIC_NO_PIC = NO; | ||
| 631 | - GCC_NO_COMMON_BLOCKS = YES; | ||
| 632 | - GCC_OPTIMIZATION_LEVEL = 0; | ||
| 633 | - GCC_PREPROCESSOR_DEFINITIONS = ( | ||
| 634 | - "DEBUG=1", | ||
| 635 | - "$(inherited)", | ||
| 636 | - ); | ||
| 637 | - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 638 | - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 639 | - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 640 | - GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 641 | - GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 642 | - MACOSX_DEPLOYMENT_TARGET = 10.15; | ||
| 643 | - MTL_ENABLE_DEBUG_INFO = YES; | ||
| 644 | - ONLY_ACTIVE_ARCH = YES; | ||
| 645 | - SDKROOT = macosx; | ||
| 646 | - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; | ||
| 647 | - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| 648 | - }; | ||
| 649 | - name = Debug; | ||
| 650 | - }; | ||
| 651 | - 33CC10FA2044A3C60003C045 /* Release */ = { | ||
| 652 | - isa = XCBuildConfiguration; | ||
| 653 | - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; | ||
| 654 | - buildSettings = { | ||
| 655 | - ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 656 | - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; | ||
| 657 | - CLANG_ANALYZER_NONNULL = YES; | ||
| 658 | - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
| 659 | - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | ||
| 660 | - CLANG_CXX_LIBRARY = "libc++"; | ||
| 661 | - CLANG_ENABLE_MODULES = YES; | ||
| 662 | - CLANG_ENABLE_OBJC_ARC = YES; | ||
| 663 | - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 664 | - CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 665 | - CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 666 | - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 667 | - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 668 | - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
| 669 | - CLANG_WARN_EMPTY_BODY = YES; | ||
| 670 | - CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 671 | - CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 672 | - CLANG_WARN_INT_CONVERSION = YES; | ||
| 673 | - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 674 | - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 675 | - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 676 | - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 677 | - CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 678 | - CODE_SIGN_IDENTITY = "-"; | ||
| 679 | - COPY_PHASE_STRIP = NO; | ||
| 680 | - DEAD_CODE_STRIPPING = YES; | ||
| 681 | - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
| 682 | - ENABLE_NS_ASSERTIONS = NO; | ||
| 683 | - ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 684 | - ENABLE_USER_SCRIPT_SANDBOXING = NO; | ||
| 685 | - GCC_C_LANGUAGE_STANDARD = gnu11; | ||
| 686 | - GCC_NO_COMMON_BLOCKS = YES; | ||
| 687 | - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 688 | - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 689 | - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 690 | - GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 691 | - GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 692 | - MACOSX_DEPLOYMENT_TARGET = 10.15; | ||
| 693 | - MTL_ENABLE_DEBUG_INFO = NO; | ||
| 694 | - SDKROOT = macosx; | ||
| 695 | - SWIFT_COMPILATION_MODE = wholemodule; | ||
| 696 | - SWIFT_OPTIMIZATION_LEVEL = "-O"; | ||
| 697 | - }; | ||
| 698 | - name = Release; | ||
| 699 | - }; | ||
| 700 | - 33CC10FC2044A3C60003C045 /* Debug */ = { | ||
| 701 | - isa = XCBuildConfiguration; | ||
| 702 | - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; | ||
| 703 | - buildSettings = { | ||
| 704 | - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 705 | - CLANG_ENABLE_MODULES = YES; | ||
| 706 | - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; | ||
| 707 | - CODE_SIGN_STYLE = Automatic; | ||
| 708 | - COMBINE_HIDPI_IMAGES = YES; | ||
| 709 | - INFOPLIST_FILE = Runner/Info.plist; | ||
| 710 | - LD_RUNPATH_SEARCH_PATHS = ( | ||
| 711 | - "$(inherited)", | ||
| 712 | - "@executable_path/../Frameworks", | ||
| 713 | - ); | ||
| 714 | - PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| 715 | - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| 716 | - SWIFT_VERSION = 5.0; | ||
| 717 | - }; | ||
| 718 | - name = Debug; | ||
| 719 | - }; | ||
| 720 | - 33CC10FD2044A3C60003C045 /* Release */ = { | ||
| 721 | - isa = XCBuildConfiguration; | ||
| 722 | - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; | ||
| 723 | - buildSettings = { | ||
| 724 | - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 725 | - CLANG_ENABLE_MODULES = YES; | ||
| 726 | - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; | ||
| 727 | - CODE_SIGN_STYLE = Automatic; | ||
| 728 | - COMBINE_HIDPI_IMAGES = YES; | ||
| 729 | - INFOPLIST_FILE = Runner/Info.plist; | ||
| 730 | - LD_RUNPATH_SEARCH_PATHS = ( | ||
| 731 | - "$(inherited)", | ||
| 732 | - "@executable_path/../Frameworks", | ||
| 733 | - ); | ||
| 734 | - PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| 735 | - SWIFT_VERSION = 5.0; | ||
| 736 | - }; | ||
| 737 | - name = Release; | ||
| 738 | - }; | ||
| 739 | - 33CC111C2044C6BA0003C045 /* Debug */ = { | ||
| 740 | - isa = XCBuildConfiguration; | ||
| 741 | - buildSettings = { | ||
| 742 | - CODE_SIGN_STYLE = Manual; | ||
| 743 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 744 | - }; | ||
| 745 | - name = Debug; | ||
| 746 | - }; | ||
| 747 | - 33CC111D2044C6BA0003C045 /* Release */ = { | ||
| 748 | - isa = XCBuildConfiguration; | ||
| 749 | - buildSettings = { | ||
| 750 | - CODE_SIGN_STYLE = Automatic; | ||
| 751 | - PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 752 | - }; | ||
| 753 | - name = Release; | ||
| 754 | - }; | ||
| 755 | -/* End XCBuildConfiguration section */ | ||
| 756 | - | ||
| 757 | -/* Begin XCConfigurationList section */ | ||
| 758 | - 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { | ||
| 759 | - isa = XCConfigurationList; | ||
| 760 | - buildConfigurations = ( | ||
| 761 | - 331C80DB294CF71000263BE5 /* Debug */, | ||
| 762 | - 331C80DC294CF71000263BE5 /* Release */, | ||
| 763 | - 331C80DD294CF71000263BE5 /* Profile */, | ||
| 764 | - ); | ||
| 765 | - defaultConfigurationIsVisible = 0; | ||
| 766 | - defaultConfigurationName = Release; | ||
| 767 | - }; | ||
| 768 | - 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { | ||
| 769 | - isa = XCConfigurationList; | ||
| 770 | - buildConfigurations = ( | ||
| 771 | - 33CC10F92044A3C60003C045 /* Debug */, | ||
| 772 | - 33CC10FA2044A3C60003C045 /* Release */, | ||
| 773 | - 338D0CE9231458BD00FA5F75 /* Profile */, | ||
| 774 | - ); | ||
| 775 | - defaultConfigurationIsVisible = 0; | ||
| 776 | - defaultConfigurationName = Release; | ||
| 777 | - }; | ||
| 778 | - 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { | ||
| 779 | - isa = XCConfigurationList; | ||
| 780 | - buildConfigurations = ( | ||
| 781 | - 33CC10FC2044A3C60003C045 /* Debug */, | ||
| 782 | - 33CC10FD2044A3C60003C045 /* Release */, | ||
| 783 | - 338D0CEA231458BD00FA5F75 /* Profile */, | ||
| 784 | - ); | ||
| 785 | - defaultConfigurationIsVisible = 0; | ||
| 786 | - defaultConfigurationName = Release; | ||
| 787 | - }; | ||
| 788 | - 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { | ||
| 789 | - isa = XCConfigurationList; | ||
| 790 | - buildConfigurations = ( | ||
| 791 | - 33CC111C2044C6BA0003C045 /* Debug */, | ||
| 792 | - 33CC111D2044C6BA0003C045 /* Release */, | ||
| 793 | - 338D0CEB231458BD00FA5F75 /* Profile */, | ||
| 794 | - ); | ||
| 795 | - defaultConfigurationIsVisible = 0; | ||
| 796 | - defaultConfigurationName = Release; | ||
| 797 | - }; | ||
| 798 | -/* End XCConfigurationList section */ | ||
| 799 | - }; | ||
| 800 | - rootObject = 33CC10E52044A3C60003C045 /* Project object */; | ||
| 801 | -} |
sherpa-onnx/flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
已删除
100644 → 0
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<Scheme | ||
| 3 | - LastUpgradeVersion = "1510" | ||
| 4 | - version = "1.3"> | ||
| 5 | - <BuildAction | ||
| 6 | - parallelizeBuildables = "YES" | ||
| 7 | - buildImplicitDependencies = "YES"> | ||
| 8 | - <BuildActionEntries> | ||
| 9 | - <BuildActionEntry | ||
| 10 | - buildForTesting = "YES" | ||
| 11 | - buildForRunning = "YES" | ||
| 12 | - buildForProfiling = "YES" | ||
| 13 | - buildForArchiving = "YES" | ||
| 14 | - buildForAnalyzing = "YES"> | ||
| 15 | - <BuildableReference | ||
| 16 | - BuildableIdentifier = "primary" | ||
| 17 | - BlueprintIdentifier = "33CC10EC2044A3C60003C045" | ||
| 18 | - BuildableName = "sherpa_onnx.app" | ||
| 19 | - BlueprintName = "Runner" | ||
| 20 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 21 | - </BuildableReference> | ||
| 22 | - </BuildActionEntry> | ||
| 23 | - </BuildActionEntries> | ||
| 24 | - </BuildAction> | ||
| 25 | - <TestAction | ||
| 26 | - buildConfiguration = "Debug" | ||
| 27 | - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| 28 | - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| 29 | - shouldUseLaunchSchemeArgsEnv = "YES"> | ||
| 30 | - <MacroExpansion> | ||
| 31 | - <BuildableReference | ||
| 32 | - BuildableIdentifier = "primary" | ||
| 33 | - BlueprintIdentifier = "33CC10EC2044A3C60003C045" | ||
| 34 | - BuildableName = "sherpa_onnx.app" | ||
| 35 | - BlueprintName = "Runner" | ||
| 36 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 37 | - </BuildableReference> | ||
| 38 | - </MacroExpansion> | ||
| 39 | - <Testables> | ||
| 40 | - <TestableReference | ||
| 41 | - skipped = "NO" | ||
| 42 | - parallelizable = "YES"> | ||
| 43 | - <BuildableReference | ||
| 44 | - BuildableIdentifier = "primary" | ||
| 45 | - BlueprintIdentifier = "331C80D4294CF70F00263BE5" | ||
| 46 | - BuildableName = "RunnerTests.xctest" | ||
| 47 | - BlueprintName = "RunnerTests" | ||
| 48 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 49 | - </BuildableReference> | ||
| 50 | - </TestableReference> | ||
| 51 | - </Testables> | ||
| 52 | - </TestAction> | ||
| 53 | - <LaunchAction | ||
| 54 | - buildConfiguration = "Debug" | ||
| 55 | - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| 56 | - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| 57 | - launchStyle = "0" | ||
| 58 | - useCustomWorkingDirectory = "NO" | ||
| 59 | - ignoresPersistentStateOnLaunch = "NO" | ||
| 60 | - debugDocumentVersioning = "YES" | ||
| 61 | - debugServiceExtension = "internal" | ||
| 62 | - allowLocationSimulation = "YES"> | ||
| 63 | - <BuildableProductRunnable | ||
| 64 | - runnableDebuggingMode = "0"> | ||
| 65 | - <BuildableReference | ||
| 66 | - BuildableIdentifier = "primary" | ||
| 67 | - BlueprintIdentifier = "33CC10EC2044A3C60003C045" | ||
| 68 | - BuildableName = "sherpa_onnx.app" | ||
| 69 | - BlueprintName = "Runner" | ||
| 70 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 71 | - </BuildableReference> | ||
| 72 | - </BuildableProductRunnable> | ||
| 73 | - </LaunchAction> | ||
| 74 | - <ProfileAction | ||
| 75 | - buildConfiguration = "Profile" | ||
| 76 | - shouldUseLaunchSchemeArgsEnv = "YES" | ||
| 77 | - savedToolIdentifier = "" | ||
| 78 | - useCustomWorkingDirectory = "NO" | ||
| 79 | - debugDocumentVersioning = "YES"> | ||
| 80 | - <BuildableProductRunnable | ||
| 81 | - runnableDebuggingMode = "0"> | ||
| 82 | - <BuildableReference | ||
| 83 | - BuildableIdentifier = "primary" | ||
| 84 | - BlueprintIdentifier = "33CC10EC2044A3C60003C045" | ||
| 85 | - BuildableName = "sherpa_onnx.app" | ||
| 86 | - BlueprintName = "Runner" | ||
| 87 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 88 | - </BuildableReference> | ||
| 89 | - </BuildableProductRunnable> | ||
| 90 | - </ProfileAction> | ||
| 91 | - <AnalyzeAction | ||
| 92 | - buildConfiguration = "Debug"> | ||
| 93 | - </AnalyzeAction> | ||
| 94 | - <ArchiveAction | ||
| 95 | - buildConfiguration = "Release" | ||
| 96 | - revealArchiveInOrganizer = "YES"> | ||
| 97 | - </ArchiveAction> | ||
| 98 | -</Scheme> |
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
已删除
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "size" : "16x16", | ||
| 5 | - "idiom" : "mac", | ||
| 6 | - "filename" : "app_icon_16.png", | ||
| 7 | - "scale" : "1x" | ||
| 8 | - }, | ||
| 9 | - { | ||
| 10 | - "size" : "16x16", | ||
| 11 | - "idiom" : "mac", | ||
| 12 | - "filename" : "app_icon_32.png", | ||
| 13 | - "scale" : "2x" | ||
| 14 | - }, | ||
| 15 | - { | ||
| 16 | - "size" : "32x32", | ||
| 17 | - "idiom" : "mac", | ||
| 18 | - "filename" : "app_icon_32.png", | ||
| 19 | - "scale" : "1x" | ||
| 20 | - }, | ||
| 21 | - { | ||
| 22 | - "size" : "32x32", | ||
| 23 | - "idiom" : "mac", | ||
| 24 | - "filename" : "app_icon_64.png", | ||
| 25 | - "scale" : "2x" | ||
| 26 | - }, | ||
| 27 | - { | ||
| 28 | - "size" : "128x128", | ||
| 29 | - "idiom" : "mac", | ||
| 30 | - "filename" : "app_icon_128.png", | ||
| 31 | - "scale" : "1x" | ||
| 32 | - }, | ||
| 33 | - { | ||
| 34 | - "size" : "128x128", | ||
| 35 | - "idiom" : "mac", | ||
| 36 | - "filename" : "app_icon_256.png", | ||
| 37 | - "scale" : "2x" | ||
| 38 | - }, | ||
| 39 | - { | ||
| 40 | - "size" : "256x256", | ||
| 41 | - "idiom" : "mac", | ||
| 42 | - "filename" : "app_icon_256.png", | ||
| 43 | - "scale" : "1x" | ||
| 44 | - }, | ||
| 45 | - { | ||
| 46 | - "size" : "256x256", | ||
| 47 | - "idiom" : "mac", | ||
| 48 | - "filename" : "app_icon_512.png", | ||
| 49 | - "scale" : "2x" | ||
| 50 | - }, | ||
| 51 | - { | ||
| 52 | - "size" : "512x512", | ||
| 53 | - "idiom" : "mac", | ||
| 54 | - "filename" : "app_icon_512.png", | ||
| 55 | - "scale" : "1x" | ||
| 56 | - }, | ||
| 57 | - { | ||
| 58 | - "size" : "512x512", | ||
| 59 | - "idiom" : "mac", | ||
| 60 | - "filename" : "app_icon_1024.png", | ||
| 61 | - "scale" : "2x" | ||
| 62 | - } | ||
| 63 | - ], | ||
| 64 | - "info" : { | ||
| 65 | - "version" : 1, | ||
| 66 | - "author" : "xcode" | ||
| 67 | - } | ||
| 68 | -} |
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
已删除
100644 → 0
100.6 KB
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
已删除
100644 → 0
5.5 KB
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
已删除
100644 → 0
520 字节
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
已删除
100644 → 0
13.8 KB
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
已删除
100644 → 0
1.0 KB
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
已删除
100644 → 0
35.6 KB
sherpa-onnx/flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
已删除
100644 → 0
2.2 KB
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> | ||
| 3 | - <dependencies> | ||
| 4 | - <deployment identifier="macosx"/> | ||
| 5 | - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/> | ||
| 6 | - <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
| 7 | - </dependencies> | ||
| 8 | - <objects> | ||
| 9 | - <customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> | ||
| 10 | - <connections> | ||
| 11 | - <outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/> | ||
| 12 | - </connections> | ||
| 13 | - </customObject> | ||
| 14 | - <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> | ||
| 15 | - <customObject id="-3" userLabel="Application" customClass="NSObject"/> | ||
| 16 | - <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Runner" customModuleProvider="target"> | ||
| 17 | - <connections> | ||
| 18 | - <outlet property="applicationMenu" destination="uQy-DD-JDr" id="XBo-yE-nKs"/> | ||
| 19 | - <outlet property="mainFlutterWindow" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/> | ||
| 20 | - </connections> | ||
| 21 | - </customObject> | ||
| 22 | - <customObject id="YLy-65-1bz" customClass="NSFontManager"/> | ||
| 23 | - <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6"> | ||
| 24 | - <items> | ||
| 25 | - <menuItem title="APP_NAME" id="1Xt-HY-uBw"> | ||
| 26 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 27 | - <menu key="submenu" title="APP_NAME" systemMenu="apple" id="uQy-DD-JDr"> | ||
| 28 | - <items> | ||
| 29 | - <menuItem title="About APP_NAME" id="5kV-Vb-QxS"> | ||
| 30 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 31 | - <connections> | ||
| 32 | - <action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/> | ||
| 33 | - </connections> | ||
| 34 | - </menuItem> | ||
| 35 | - <menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/> | ||
| 36 | - <menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/> | ||
| 37 | - <menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/> | ||
| 38 | - <menuItem title="Services" id="NMo-om-nkz"> | ||
| 39 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 40 | - <menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/> | ||
| 41 | - </menuItem> | ||
| 42 | - <menuItem isSeparatorItem="YES" id="4je-JR-u6R"/> | ||
| 43 | - <menuItem title="Hide APP_NAME" keyEquivalent="h" id="Olw-nP-bQN"> | ||
| 44 | - <connections> | ||
| 45 | - <action selector="hide:" target="-1" id="PnN-Uc-m68"/> | ||
| 46 | - </connections> | ||
| 47 | - </menuItem> | ||
| 48 | - <menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO"> | ||
| 49 | - <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> | ||
| 50 | - <connections> | ||
| 51 | - <action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/> | ||
| 52 | - </connections> | ||
| 53 | - </menuItem> | ||
| 54 | - <menuItem title="Show All" id="Kd2-mp-pUS"> | ||
| 55 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 56 | - <connections> | ||
| 57 | - <action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/> | ||
| 58 | - </connections> | ||
| 59 | - </menuItem> | ||
| 60 | - <menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/> | ||
| 61 | - <menuItem title="Quit APP_NAME" keyEquivalent="q" id="4sb-4s-VLi"> | ||
| 62 | - <connections> | ||
| 63 | - <action selector="terminate:" target="-1" id="Te7-pn-YzF"/> | ||
| 64 | - </connections> | ||
| 65 | - </menuItem> | ||
| 66 | - </items> | ||
| 67 | - </menu> | ||
| 68 | - </menuItem> | ||
| 69 | - <menuItem title="Edit" id="5QF-Oa-p0T"> | ||
| 70 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 71 | - <menu key="submenu" title="Edit" id="W48-6f-4Dl"> | ||
| 72 | - <items> | ||
| 73 | - <menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg"> | ||
| 74 | - <connections> | ||
| 75 | - <action selector="undo:" target="-1" id="M6e-cu-g7V"/> | ||
| 76 | - </connections> | ||
| 77 | - </menuItem> | ||
| 78 | - <menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam"> | ||
| 79 | - <connections> | ||
| 80 | - <action selector="redo:" target="-1" id="oIA-Rs-6OD"/> | ||
| 81 | - </connections> | ||
| 82 | - </menuItem> | ||
| 83 | - <menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/> | ||
| 84 | - <menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG"> | ||
| 85 | - <connections> | ||
| 86 | - <action selector="cut:" target="-1" id="YJe-68-I9s"/> | ||
| 87 | - </connections> | ||
| 88 | - </menuItem> | ||
| 89 | - <menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU"> | ||
| 90 | - <connections> | ||
| 91 | - <action selector="copy:" target="-1" id="G1f-GL-Joy"/> | ||
| 92 | - </connections> | ||
| 93 | - </menuItem> | ||
| 94 | - <menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL"> | ||
| 95 | - <connections> | ||
| 96 | - <action selector="paste:" target="-1" id="UvS-8e-Qdg"/> | ||
| 97 | - </connections> | ||
| 98 | - </menuItem> | ||
| 99 | - <menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk"> | ||
| 100 | - <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> | ||
| 101 | - <connections> | ||
| 102 | - <action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/> | ||
| 103 | - </connections> | ||
| 104 | - </menuItem> | ||
| 105 | - <menuItem title="Delete" id="pa3-QI-u2k"> | ||
| 106 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 107 | - <connections> | ||
| 108 | - <action selector="delete:" target="-1" id="0Mk-Ml-PaM"/> | ||
| 109 | - </connections> | ||
| 110 | - </menuItem> | ||
| 111 | - <menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m"> | ||
| 112 | - <connections> | ||
| 113 | - <action selector="selectAll:" target="-1" id="VNm-Mi-diN"/> | ||
| 114 | - </connections> | ||
| 115 | - </menuItem> | ||
| 116 | - <menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/> | ||
| 117 | - <menuItem title="Find" id="4EN-yA-p0u"> | ||
| 118 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 119 | - <menu key="submenu" title="Find" id="1b7-l0-nxx"> | ||
| 120 | - <items> | ||
| 121 | - <menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W"> | ||
| 122 | - <connections> | ||
| 123 | - <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/> | ||
| 124 | - </connections> | ||
| 125 | - </menuItem> | ||
| 126 | - <menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz"> | ||
| 127 | - <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> | ||
| 128 | - <connections> | ||
| 129 | - <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/> | ||
| 130 | - </connections> | ||
| 131 | - </menuItem> | ||
| 132 | - <menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye"> | ||
| 133 | - <connections> | ||
| 134 | - <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/> | ||
| 135 | - </connections> | ||
| 136 | - </menuItem> | ||
| 137 | - <menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV"> | ||
| 138 | - <connections> | ||
| 139 | - <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/> | ||
| 140 | - </connections> | ||
| 141 | - </menuItem> | ||
| 142 | - <menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt"> | ||
| 143 | - <connections> | ||
| 144 | - <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/> | ||
| 145 | - </connections> | ||
| 146 | - </menuItem> | ||
| 147 | - <menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd"> | ||
| 148 | - <connections> | ||
| 149 | - <action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/> | ||
| 150 | - </connections> | ||
| 151 | - </menuItem> | ||
| 152 | - </items> | ||
| 153 | - </menu> | ||
| 154 | - </menuItem> | ||
| 155 | - <menuItem title="Spelling and Grammar" id="Dv1-io-Yv7"> | ||
| 156 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 157 | - <menu key="submenu" title="Spelling" id="3IN-sU-3Bg"> | ||
| 158 | - <items> | ||
| 159 | - <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI"> | ||
| 160 | - <connections> | ||
| 161 | - <action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/> | ||
| 162 | - </connections> | ||
| 163 | - </menuItem> | ||
| 164 | - <menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7"> | ||
| 165 | - <connections> | ||
| 166 | - <action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/> | ||
| 167 | - </connections> | ||
| 168 | - </menuItem> | ||
| 169 | - <menuItem isSeparatorItem="YES" id="bNw-od-mp5"/> | ||
| 170 | - <menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN"> | ||
| 171 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 172 | - <connections> | ||
| 173 | - <action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/> | ||
| 174 | - </connections> | ||
| 175 | - </menuItem> | ||
| 176 | - <menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG"> | ||
| 177 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 178 | - <connections> | ||
| 179 | - <action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/> | ||
| 180 | - </connections> | ||
| 181 | - </menuItem> | ||
| 182 | - <menuItem title="Correct Spelling Automatically" id="78Y-hA-62v"> | ||
| 183 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 184 | - <connections> | ||
| 185 | - <action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/> | ||
| 186 | - </connections> | ||
| 187 | - </menuItem> | ||
| 188 | - </items> | ||
| 189 | - </menu> | ||
| 190 | - </menuItem> | ||
| 191 | - <menuItem title="Substitutions" id="9ic-FL-obx"> | ||
| 192 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 193 | - <menu key="submenu" title="Substitutions" id="FeM-D8-WVr"> | ||
| 194 | - <items> | ||
| 195 | - <menuItem title="Show Substitutions" id="z6F-FW-3nz"> | ||
| 196 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 197 | - <connections> | ||
| 198 | - <action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/> | ||
| 199 | - </connections> | ||
| 200 | - </menuItem> | ||
| 201 | - <menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/> | ||
| 202 | - <menuItem title="Smart Copy/Paste" id="9yt-4B-nSM"> | ||
| 203 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 204 | - <connections> | ||
| 205 | - <action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/> | ||
| 206 | - </connections> | ||
| 207 | - </menuItem> | ||
| 208 | - <menuItem title="Smart Quotes" id="hQb-2v-fYv"> | ||
| 209 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 210 | - <connections> | ||
| 211 | - <action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/> | ||
| 212 | - </connections> | ||
| 213 | - </menuItem> | ||
| 214 | - <menuItem title="Smart Dashes" id="rgM-f4-ycn"> | ||
| 215 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 216 | - <connections> | ||
| 217 | - <action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/> | ||
| 218 | - </connections> | ||
| 219 | - </menuItem> | ||
| 220 | - <menuItem title="Smart Links" id="cwL-P1-jid"> | ||
| 221 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 222 | - <connections> | ||
| 223 | - <action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/> | ||
| 224 | - </connections> | ||
| 225 | - </menuItem> | ||
| 226 | - <menuItem title="Data Detectors" id="tRr-pd-1PS"> | ||
| 227 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 228 | - <connections> | ||
| 229 | - <action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/> | ||
| 230 | - </connections> | ||
| 231 | - </menuItem> | ||
| 232 | - <menuItem title="Text Replacement" id="HFQ-gK-NFA"> | ||
| 233 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 234 | - <connections> | ||
| 235 | - <action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/> | ||
| 236 | - </connections> | ||
| 237 | - </menuItem> | ||
| 238 | - </items> | ||
| 239 | - </menu> | ||
| 240 | - </menuItem> | ||
| 241 | - <menuItem title="Transformations" id="2oI-Rn-ZJC"> | ||
| 242 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 243 | - <menu key="submenu" title="Transformations" id="c8a-y6-VQd"> | ||
| 244 | - <items> | ||
| 245 | - <menuItem title="Make Upper Case" id="vmV-6d-7jI"> | ||
| 246 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 247 | - <connections> | ||
| 248 | - <action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/> | ||
| 249 | - </connections> | ||
| 250 | - </menuItem> | ||
| 251 | - <menuItem title="Make Lower Case" id="d9M-CD-aMd"> | ||
| 252 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 253 | - <connections> | ||
| 254 | - <action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/> | ||
| 255 | - </connections> | ||
| 256 | - </menuItem> | ||
| 257 | - <menuItem title="Capitalize" id="UEZ-Bs-lqG"> | ||
| 258 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 259 | - <connections> | ||
| 260 | - <action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/> | ||
| 261 | - </connections> | ||
| 262 | - </menuItem> | ||
| 263 | - </items> | ||
| 264 | - </menu> | ||
| 265 | - </menuItem> | ||
| 266 | - <menuItem title="Speech" id="xrE-MZ-jX0"> | ||
| 267 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 268 | - <menu key="submenu" title="Speech" id="3rS-ZA-NoH"> | ||
| 269 | - <items> | ||
| 270 | - <menuItem title="Start Speaking" id="Ynk-f8-cLZ"> | ||
| 271 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 272 | - <connections> | ||
| 273 | - <action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/> | ||
| 274 | - </connections> | ||
| 275 | - </menuItem> | ||
| 276 | - <menuItem title="Stop Speaking" id="Oyz-dy-DGm"> | ||
| 277 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 278 | - <connections> | ||
| 279 | - <action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/> | ||
| 280 | - </connections> | ||
| 281 | - </menuItem> | ||
| 282 | - </items> | ||
| 283 | - </menu> | ||
| 284 | - </menuItem> | ||
| 285 | - </items> | ||
| 286 | - </menu> | ||
| 287 | - </menuItem> | ||
| 288 | - <menuItem title="View" id="H8h-7b-M4v"> | ||
| 289 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 290 | - <menu key="submenu" title="View" id="HyV-fh-RgO"> | ||
| 291 | - <items> | ||
| 292 | - <menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa"> | ||
| 293 | - <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/> | ||
| 294 | - <connections> | ||
| 295 | - <action selector="toggleFullScreen:" target="-1" id="dU3-MA-1Rq"/> | ||
| 296 | - </connections> | ||
| 297 | - </menuItem> | ||
| 298 | - </items> | ||
| 299 | - </menu> | ||
| 300 | - </menuItem> | ||
| 301 | - <menuItem title="Window" id="aUF-d1-5bR"> | ||
| 302 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 303 | - <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo"> | ||
| 304 | - <items> | ||
| 305 | - <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV"> | ||
| 306 | - <connections> | ||
| 307 | - <action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/> | ||
| 308 | - </connections> | ||
| 309 | - </menuItem> | ||
| 310 | - <menuItem title="Zoom" id="R4o-n2-Eq4"> | ||
| 311 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 312 | - <connections> | ||
| 313 | - <action selector="performZoom:" target="-1" id="DIl-cC-cCs"/> | ||
| 314 | - </connections> | ||
| 315 | - </menuItem> | ||
| 316 | - <menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/> | ||
| 317 | - <menuItem title="Bring All to Front" id="LE2-aR-0XJ"> | ||
| 318 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 319 | - <connections> | ||
| 320 | - <action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/> | ||
| 321 | - </connections> | ||
| 322 | - </menuItem> | ||
| 323 | - </items> | ||
| 324 | - </menu> | ||
| 325 | - </menuItem> | ||
| 326 | - <menuItem title="Help" id="EPT-qC-fAb"> | ||
| 327 | - <modifierMask key="keyEquivalentModifierMask"/> | ||
| 328 | - <menu key="submenu" title="Help" systemMenu="help" id="rJ0-wn-3NY"/> | ||
| 329 | - </menuItem> | ||
| 330 | - </items> | ||
| 331 | - <point key="canvasLocation" x="142" y="-258"/> | ||
| 332 | - </menu> | ||
| 333 | - <window title="APP_NAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="MainFlutterWindow" customModule="Runner" customModuleProvider="target"> | ||
| 334 | - <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> | ||
| 335 | - <rect key="contentRect" x="335" y="390" width="800" height="600"/> | ||
| 336 | - <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/> | ||
| 337 | - <view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ"> | ||
| 338 | - <rect key="frame" x="0.0" y="0.0" width="800" height="600"/> | ||
| 339 | - <autoresizingMask key="autoresizingMask"/> | ||
| 340 | - </view> | ||
| 341 | - </window> | ||
| 342 | - </objects> | ||
| 343 | -</document> |
| 1 | -// Application-level settings for the Runner target. | ||
| 2 | -// | ||
| 3 | -// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the | ||
| 4 | -// future. If not, the values below would default to using the project name when this becomes a | ||
| 5 | -// 'flutter create' template. | ||
| 6 | - | ||
| 7 | -// The application's name. By default this is also the title of the Flutter window. | ||
| 8 | -PRODUCT_NAME = sherpa_onnx | ||
| 9 | - | ||
| 10 | -// The application's bundle identifier | ||
| 11 | -PRODUCT_BUNDLE_IDENTIFIER = com.k2fsa.sherpa.onnx | ||
| 12 | - | ||
| 13 | -// The copyright displayed in application information | ||
| 14 | -PRODUCT_COPYRIGHT = Copyright © 2024 Next-gen Kaldi. All rights reserved. |
| 1 | -WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings | ||
| 2 | -GCC_WARN_UNDECLARED_SELECTOR = YES | ||
| 3 | -CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES | ||
| 4 | -CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE | ||
| 5 | -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES | ||
| 6 | -CLANG_WARN_PRAGMA_PACK = YES | ||
| 7 | -CLANG_WARN_STRICT_PROTOTYPES = YES | ||
| 8 | -CLANG_WARN_COMMA = YES | ||
| 9 | -GCC_WARN_STRICT_SELECTOR_MATCH = YES | ||
| 10 | -CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES | ||
| 11 | -CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES | ||
| 12 | -GCC_WARN_SHADOW = YES | ||
| 13 | -CLANG_WARN_UNREACHABLE_CODE = YES |
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | -<plist version="1.0"> | ||
| 4 | -<dict> | ||
| 5 | - <key>com.apple.security.app-sandbox</key> | ||
| 6 | - <true/> | ||
| 7 | - <key>com.apple.security.cs.allow-jit</key> | ||
| 8 | - <true/> | ||
| 9 | - <key>com.apple.security.device.audio-input</key> | ||
| 10 | - <true/> | ||
| 11 | - <key>com.apple.security.network.server</key> | ||
| 12 | - <true/> | ||
| 13 | -</dict> | ||
| 14 | -</plist> |
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | -<plist version="1.0"> | ||
| 4 | -<dict> | ||
| 5 | - <key>NSMicrophoneUsageDescription</key> | ||
| 6 | - <string>Need microphone access for Next-gen kaldi to work</string> | ||
| 7 | - <key>CFBundleDevelopmentRegion</key> | ||
| 8 | - <string>$(DEVELOPMENT_LANGUAGE)</string> | ||
| 9 | - <key>CFBundleExecutable</key> | ||
| 10 | - <string>$(EXECUTABLE_NAME)</string> | ||
| 11 | - <key>CFBundleIconFile</key> | ||
| 12 | - <string></string> | ||
| 13 | - <key>CFBundleIdentifier</key> | ||
| 14 | - <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| 15 | - <key>CFBundleInfoDictionaryVersion</key> | ||
| 16 | - <string>6.0</string> | ||
| 17 | - <key>CFBundleName</key> | ||
| 18 | - <string>$(PRODUCT_NAME)</string> | ||
| 19 | - <key>CFBundlePackageType</key> | ||
| 20 | - <string>APPL</string> | ||
| 21 | - <key>CFBundleShortVersionString</key> | ||
| 22 | - <string>$(FLUTTER_BUILD_NAME)</string> | ||
| 23 | - <key>CFBundleVersion</key> | ||
| 24 | - <string>$(FLUTTER_BUILD_NUMBER)</string> | ||
| 25 | - <key>LSMinimumSystemVersion</key> | ||
| 26 | - <string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
| 27 | - <key>NSHumanReadableCopyright</key> | ||
| 28 | - <string>$(PRODUCT_COPYRIGHT)</string> | ||
| 29 | - <key>NSMainNibFile</key> | ||
| 30 | - <string>MainMenu</string> | ||
| 31 | - <key>NSPrincipalClass</key> | ||
| 32 | - <string>NSApplication</string> | ||
| 33 | -</dict> | ||
| 34 | -</plist> |
| 1 | -import Cocoa | ||
| 2 | -import FlutterMacOS | ||
| 3 | - | ||
| 4 | -class MainFlutterWindow: NSWindow { | ||
| 5 | - override func awakeFromNib() { | ||
| 6 | - let flutterViewController = FlutterViewController() | ||
| 7 | - let windowFrame = self.frame | ||
| 8 | - self.contentViewController = flutterViewController | ||
| 9 | - self.setFrame(windowFrame, display: true) | ||
| 10 | - | ||
| 11 | - RegisterGeneratedPlugins(registry: flutterViewController) | ||
| 12 | - | ||
| 13 | - super.awakeFromNib() | ||
| 14 | - } | ||
| 15 | -} |
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | -<plist version="1.0"> | ||
| 4 | -<dict> | ||
| 5 | - <key>com.apple.security.app-sandbox</key> | ||
| 6 | - <true/> | ||
| 7 | - <key>com.apple.security.device.audio-input</key> | ||
| 8 | - <true/> | ||
| 9 | -</dict> | ||
| 10 | -</plist> |
| 1 | -import Cocoa | ||
| 2 | -import FlutterMacOS | ||
| 3 | -import XCTest | ||
| 4 | - | ||
| 5 | -class RunnerTests: XCTestCase { | ||
| 6 | - | ||
| 7 | - func testExample() { | ||
| 8 | - // If you add code to the Runner application, consider adding tests here. | ||
| 9 | - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | -} |
sherpa-onnx/flutter/example/pubspec.yaml
已删除
100644 → 0
| 1 | -name: hello_sherpa_onnx | ||
| 2 | -description: "Demonstrates how to use the sherpa_onnx ffi plugin." | ||
| 3 | -# The following line prevents the package from being accidentally published to | ||
| 4 | -# pub.dev using `flutter pub publish`. This is preferred for private packages. | ||
| 5 | -publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ||
| 6 | - | ||
| 7 | -# The following defines the version and build number for your application. | ||
| 8 | -# A version number is three numbers separated by dots, like 1.2.43 | ||
| 9 | -# followed by an optional build number separated by a +. | ||
| 10 | -# Both the version and the builder number may be overridden in flutter | ||
| 11 | -# build by specifying --build-name and --build-number, respectively. | ||
| 12 | -# In Android, build-name is used as versionName while build-number used as versionCode. | ||
| 13 | -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning | ||
| 14 | -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. | ||
| 15 | -# Read more about iOS versioning at | ||
| 16 | -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | ||
| 17 | -# In Windows, build-name is used as the major, minor, and patch parts | ||
| 18 | -# of the product and file versions while build-number is used as the build suffix. | ||
| 19 | -version: 1.0.0+1 | ||
| 20 | - | ||
| 21 | -environment: | ||
| 22 | - sdk: '>=3.4.0 <4.0.0' | ||
| 23 | - | ||
| 24 | -# Dependencies specify other packages that your package needs in order to work. | ||
| 25 | -# To automatically upgrade your package dependencies to the latest versions | ||
| 26 | -# consider running `flutter pub upgrade --major-versions`. Alternatively, | ||
| 27 | -# dependencies can be manually updated by changing the version numbers below to | ||
| 28 | -# the latest version available on pub.dev. To see which dependencies have newer | ||
| 29 | -# versions available, run `flutter pub outdated`. | ||
| 30 | -dependencies: | ||
| 31 | - flutter: | ||
| 32 | - sdk: flutter | ||
| 33 | - | ||
| 34 | - path_provider: ^2.1.3 | ||
| 35 | - path: ^1.9.0 | ||
| 36 | - record: ^5.1.0 | ||
| 37 | - url_launcher: ^6.2.6 | ||
| 38 | - | ||
| 39 | - sherpa_onnx: | ||
| 40 | - # When depending on this package from a real application you should use: | ||
| 41 | - # sherpa_onnx: ^x.y.z | ||
| 42 | - # See https://dart.dev/tools/pub/dependencies#version-constraints | ||
| 43 | - # The example app is bundled with the plugin so we use a path dependency on | ||
| 44 | - # the parent directory to use the current plugin's version. | ||
| 45 | - path: ../ | ||
| 46 | - | ||
| 47 | - # The following adds the Cupertino Icons font to your application. | ||
| 48 | - # Use with the CupertinoIcons class for iOS style icons. | ||
| 49 | - cupertino_icons: ^1.0.6 | ||
| 50 | - | ||
| 51 | -dev_dependencies: | ||
| 52 | - flutter_test: | ||
| 53 | - sdk: flutter | ||
| 54 | - | ||
| 55 | - # The "flutter_lints" package below contains a set of recommended lints to | ||
| 56 | - # encourage good coding practices. The lint set provided by the package is | ||
| 57 | - # activated in the `analysis_options.yaml` file located at the root of your | ||
| 58 | - # package. See that file for information about deactivating specific lint | ||
| 59 | - # rules and activating additional ones. | ||
| 60 | - flutter_lints: ^3.0.0 | ||
| 61 | - | ||
| 62 | -# For information on the generic Dart part of this file, see the | ||
| 63 | -# following page: https://dart.dev/tools/pub/pubspec | ||
| 64 | - | ||
| 65 | -# The following section is specific to Flutter packages. | ||
| 66 | -flutter: | ||
| 67 | - | ||
| 68 | - # The following line ensures that the Material Icons font is | ||
| 69 | - # included with your application, so that you can use the icons in | ||
| 70 | - # the material Icons class. | ||
| 71 | - uses-material-design: true | ||
| 72 | - | ||
| 73 | - # To add assets to your application, add an assets section, like this: | ||
| 74 | - assets: | ||
| 75 | - - assets/ | ||
| 76 | - - assets/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/ | ||
| 77 | - # - assets/sherpa-onnx-paraformer-zh-2023-03-28/ | ||
| 78 | - # - assets/sherpa-onnx-paraformer-zh-2023-03-28/test_wavs/ | ||
| 79 | - # - assets/sr-data/enroll/ | ||
| 80 | - # - assets/sr-data/test/ | ||
| 81 | - # - images/a_dot_ham.jpeg | ||
| 82 | - | ||
| 83 | - # An image asset can refer to one or more resolution-specific "variants", see | ||
| 84 | - # https://flutter.dev/assets-and-images/#resolution-aware | ||
| 85 | - | ||
| 86 | - # For details regarding adding assets from package dependencies, see | ||
| 87 | - # https://flutter.dev/assets-and-images/#from-packages | ||
| 88 | - | ||
| 89 | - # To add custom fonts to your application, add a fonts section here, | ||
| 90 | - # in this "flutter" section. Each entry in this list should have a | ||
| 91 | - # "family" key with the font family name, and a "fonts" key with a | ||
| 92 | - # list giving the asset and other descriptors for the font. For | ||
| 93 | - # example: | ||
| 94 | - # fonts: | ||
| 95 | - # - family: Schyler | ||
| 96 | - # fonts: | ||
| 97 | - # - asset: fonts/Schyler-Regular.ttf | ||
| 98 | - # - asset: fonts/Schyler-Italic.ttf | ||
| 99 | - # style: italic | ||
| 100 | - # - family: Trajan Pro | ||
| 101 | - # fonts: | ||
| 102 | - # - asset: fonts/TrajanPro.ttf | ||
| 103 | - # - asset: fonts/TrajanPro_Bold.ttf | ||
| 104 | - # weight: 700 | ||
| 105 | - # | ||
| 106 | - # For details regarding fonts from package dependencies, | ||
| 107 | - # see https://flutter.dev/custom-fonts/#from-packages |
| 1 | -flutter/ephemeral/ | ||
| 2 | - | ||
| 3 | -# Visual Studio user-specific files. | ||
| 4 | -*.suo | ||
| 5 | -*.user | ||
| 6 | -*.userosscache | ||
| 7 | -*.sln.docstates | ||
| 8 | - | ||
| 9 | -# Visual Studio build-related files. | ||
| 10 | -x64/ | ||
| 11 | -x86/ | ||
| 12 | - | ||
| 13 | -# Visual Studio cache files | ||
| 14 | -# files ending in .cache can be ignored | ||
| 15 | -*.[Cc]ache | ||
| 16 | -# but keep track of directories ending in .cache | ||
| 17 | -!*.[Cc]ache/ |
| 1 | -# Project-level configuration. | ||
| 2 | -cmake_minimum_required(VERSION 3.14) | ||
| 3 | -project(sherpa_onnx LANGUAGES CXX) | ||
| 4 | - | ||
| 5 | -# The name of the executable created for the application. Change this to change | ||
| 6 | -# the on-disk name of your application. | ||
| 7 | -set(BINARY_NAME "sherpa_onnx") | ||
| 8 | - | ||
| 9 | -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent | ||
| 10 | -# versions of CMake. | ||
| 11 | -cmake_policy(VERSION 3.14...3.25) | ||
| 12 | - | ||
| 13 | -# Define build configuration option. | ||
| 14 | -get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) | ||
| 15 | -if(IS_MULTICONFIG) | ||
| 16 | - set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" | ||
| 17 | - CACHE STRING "" FORCE) | ||
| 18 | -else() | ||
| 19 | - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
| 20 | - set(CMAKE_BUILD_TYPE "Debug" CACHE | ||
| 21 | - STRING "Flutter build mode" FORCE) | ||
| 22 | - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
| 23 | - "Debug" "Profile" "Release") | ||
| 24 | - endif() | ||
| 25 | -endif() | ||
| 26 | -# Define settings for the Profile build mode. | ||
| 27 | -set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") | ||
| 28 | -set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") | ||
| 29 | -set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") | ||
| 30 | -set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
| 31 | - | ||
| 32 | -# Use Unicode for all projects. | ||
| 33 | -add_definitions(-DUNICODE -D_UNICODE) | ||
| 34 | - | ||
| 35 | -# Compilation settings that should be applied to most targets. | ||
| 36 | -# | ||
| 37 | -# Be cautious about adding new options here, as plugins use this function by | ||
| 38 | -# default. In most cases, you should add new options to specific targets instead | ||
| 39 | -# of modifying this function. | ||
| 40 | -function(APPLY_STANDARD_SETTINGS TARGET) | ||
| 41 | - target_compile_features(${TARGET} PUBLIC cxx_std_17) | ||
| 42 | - target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") | ||
| 43 | - target_compile_options(${TARGET} PRIVATE /EHsc) | ||
| 44 | - target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") | ||
| 45 | - target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>") | ||
| 46 | -endfunction() | ||
| 47 | - | ||
| 48 | -# Flutter library and tool build rules. | ||
| 49 | -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") | ||
| 50 | -add_subdirectory(${FLUTTER_MANAGED_DIR}) | ||
| 51 | - | ||
| 52 | -# Application build; see runner/CMakeLists.txt. | ||
| 53 | -add_subdirectory("runner") | ||
| 54 | - | ||
| 55 | - | ||
| 56 | -# Generated plugin build rules, which manage building the plugins and adding | ||
| 57 | -# them to the application. | ||
| 58 | -include(flutter/generated_plugins.cmake) | ||
| 59 | - | ||
| 60 | - | ||
| 61 | -# === Installation === | ||
| 62 | -# Support files are copied into place next to the executable, so that it can | ||
| 63 | -# run in place. This is done instead of making a separate bundle (as on Linux) | ||
| 64 | -# so that building and running from within Visual Studio will work. | ||
| 65 | -set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>") | ||
| 66 | -# Make the "install" step default, as it's required to run. | ||
| 67 | -set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) | ||
| 68 | -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
| 69 | - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) | ||
| 70 | -endif() | ||
| 71 | - | ||
| 72 | -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") | ||
| 73 | -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") | ||
| 74 | - | ||
| 75 | -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" | ||
| 76 | - COMPONENT Runtime) | ||
| 77 | - | ||
| 78 | -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
| 79 | - COMPONENT Runtime) | ||
| 80 | - | ||
| 81 | -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 82 | - COMPONENT Runtime) | ||
| 83 | - | ||
| 84 | -if(PLUGIN_BUNDLED_LIBRARIES) | ||
| 85 | - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" | ||
| 86 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 87 | - COMPONENT Runtime) | ||
| 88 | -endif() | ||
| 89 | - | ||
| 90 | -# Copy the native assets provided by the build.dart from all packages. | ||
| 91 | -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") | ||
| 92 | -install(DIRECTORY "${NATIVE_ASSETS_DIR}" | ||
| 93 | - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
| 94 | - COMPONENT Runtime) | ||
| 95 | - | ||
| 96 | -# Fully re-copy the assets directory on each build to avoid having stale files | ||
| 97 | -# from a previous install. | ||
| 98 | -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") | ||
| 99 | -install(CODE " | ||
| 100 | - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") | ||
| 101 | - " COMPONENT Runtime) | ||
| 102 | -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" | ||
| 103 | - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) | ||
| 104 | - | ||
| 105 | -# Install the AOT library on non-Debug builds only. | ||
| 106 | -install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
| 107 | - CONFIGURATIONS Profile;Release | ||
| 108 | - COMPONENT Runtime) |
| 1 | -# This file controls Flutter-level build steps. It should not be edited. | ||
| 2 | -cmake_minimum_required(VERSION 3.14) | ||
| 3 | - | ||
| 4 | -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
| 5 | - | ||
| 6 | -# Configuration provided via flutter tool. | ||
| 7 | -include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
| 8 | - | ||
| 9 | -# TODO: Move the rest of this into files in ephemeral. See | ||
| 10 | -# https://github.com/flutter/flutter/issues/57146. | ||
| 11 | -set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") | ||
| 12 | - | ||
| 13 | -# Set fallback configurations for older versions of the flutter tool. | ||
| 14 | -if (NOT DEFINED FLUTTER_TARGET_PLATFORM) | ||
| 15 | - set(FLUTTER_TARGET_PLATFORM "windows-x64") | ||
| 16 | -endif() | ||
| 17 | - | ||
| 18 | -# === Flutter Library === | ||
| 19 | -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") | ||
| 20 | - | ||
| 21 | -# Published to parent scope for install step. | ||
| 22 | -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
| 23 | -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
| 24 | -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
| 25 | -set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) | ||
| 26 | - | ||
| 27 | -list(APPEND FLUTTER_LIBRARY_HEADERS | ||
| 28 | - "flutter_export.h" | ||
| 29 | - "flutter_windows.h" | ||
| 30 | - "flutter_messenger.h" | ||
| 31 | - "flutter_plugin_registrar.h" | ||
| 32 | - "flutter_texture_registrar.h" | ||
| 33 | -) | ||
| 34 | -list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") | ||
| 35 | -add_library(flutter INTERFACE) | ||
| 36 | -target_include_directories(flutter INTERFACE | ||
| 37 | - "${EPHEMERAL_DIR}" | ||
| 38 | -) | ||
| 39 | -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") | ||
| 40 | -add_dependencies(flutter flutter_assemble) | ||
| 41 | - | ||
| 42 | -# === Wrapper === | ||
| 43 | -list(APPEND CPP_WRAPPER_SOURCES_CORE | ||
| 44 | - "core_implementations.cc" | ||
| 45 | - "standard_codec.cc" | ||
| 46 | -) | ||
| 47 | -list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") | ||
| 48 | -list(APPEND CPP_WRAPPER_SOURCES_PLUGIN | ||
| 49 | - "plugin_registrar.cc" | ||
| 50 | -) | ||
| 51 | -list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") | ||
| 52 | -list(APPEND CPP_WRAPPER_SOURCES_APP | ||
| 53 | - "flutter_engine.cc" | ||
| 54 | - "flutter_view_controller.cc" | ||
| 55 | -) | ||
| 56 | -list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") | ||
| 57 | - | ||
| 58 | -# Wrapper sources needed for a plugin. | ||
| 59 | -add_library(flutter_wrapper_plugin STATIC | ||
| 60 | - ${CPP_WRAPPER_SOURCES_CORE} | ||
| 61 | - ${CPP_WRAPPER_SOURCES_PLUGIN} | ||
| 62 | -) | ||
| 63 | -apply_standard_settings(flutter_wrapper_plugin) | ||
| 64 | -set_target_properties(flutter_wrapper_plugin PROPERTIES | ||
| 65 | - POSITION_INDEPENDENT_CODE ON) | ||
| 66 | -set_target_properties(flutter_wrapper_plugin PROPERTIES | ||
| 67 | - CXX_VISIBILITY_PRESET hidden) | ||
| 68 | -target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) | ||
| 69 | -target_include_directories(flutter_wrapper_plugin PUBLIC | ||
| 70 | - "${WRAPPER_ROOT}/include" | ||
| 71 | -) | ||
| 72 | -add_dependencies(flutter_wrapper_plugin flutter_assemble) | ||
| 73 | - | ||
| 74 | -# Wrapper sources needed for the runner. | ||
| 75 | -add_library(flutter_wrapper_app STATIC | ||
| 76 | - ${CPP_WRAPPER_SOURCES_CORE} | ||
| 77 | - ${CPP_WRAPPER_SOURCES_APP} | ||
| 78 | -) | ||
| 79 | -apply_standard_settings(flutter_wrapper_app) | ||
| 80 | -target_link_libraries(flutter_wrapper_app PUBLIC flutter) | ||
| 81 | -target_include_directories(flutter_wrapper_app PUBLIC | ||
| 82 | - "${WRAPPER_ROOT}/include" | ||
| 83 | -) | ||
| 84 | -add_dependencies(flutter_wrapper_app flutter_assemble) | ||
| 85 | - | ||
| 86 | -# === Flutter tool backend === | ||
| 87 | -# _phony_ is a non-existent file to force this command to run every time, | ||
| 88 | -# since currently there's no way to get a full input/output list from the | ||
| 89 | -# flutter tool. | ||
| 90 | -set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") | ||
| 91 | -set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) | ||
| 92 | -add_custom_command( | ||
| 93 | - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
| 94 | - ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} | ||
| 95 | - ${CPP_WRAPPER_SOURCES_APP} | ||
| 96 | - ${PHONY_OUTPUT} | ||
| 97 | - COMMAND ${CMAKE_COMMAND} -E env | ||
| 98 | - ${FLUTTER_TOOL_ENVIRONMENT} | ||
| 99 | - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" | ||
| 100 | - ${FLUTTER_TARGET_PLATFORM} $<CONFIG> | ||
| 101 | - VERBATIM | ||
| 102 | -) | ||
| 103 | -add_custom_target(flutter_assemble DEPENDS | ||
| 104 | - "${FLUTTER_LIBRARY}" | ||
| 105 | - ${FLUTTER_LIBRARY_HEADERS} | ||
| 106 | - ${CPP_WRAPPER_SOURCES_CORE} | ||
| 107 | - ${CPP_WRAPPER_SOURCES_PLUGIN} | ||
| 108 | - ${CPP_WRAPPER_SOURCES_APP} | ||
| 109 | -) |
| 1 | -cmake_minimum_required(VERSION 3.14) | ||
| 2 | -project(runner LANGUAGES CXX) | ||
| 3 | - | ||
| 4 | -# Define the application target. To change its name, change BINARY_NAME in the | ||
| 5 | -# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer | ||
| 6 | -# work. | ||
| 7 | -# | ||
| 8 | -# Any new source files that you add to the application should be added here. | ||
| 9 | -add_executable(${BINARY_NAME} WIN32 | ||
| 10 | - "flutter_window.cpp" | ||
| 11 | - "main.cpp" | ||
| 12 | - "utils.cpp" | ||
| 13 | - "win32_window.cpp" | ||
| 14 | - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
| 15 | - "Runner.rc" | ||
| 16 | - "runner.exe.manifest" | ||
| 17 | -) | ||
| 18 | - | ||
| 19 | -# Apply the standard set of build settings. This can be removed for applications | ||
| 20 | -# that need different build settings. | ||
| 21 | -apply_standard_settings(${BINARY_NAME}) | ||
| 22 | - | ||
| 23 | -# Add preprocessor definitions for the build version. | ||
| 24 | -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") | ||
| 25 | -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") | ||
| 26 | -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") | ||
| 27 | -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") | ||
| 28 | -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") | ||
| 29 | - | ||
| 30 | -# Disable Windows macros that collide with C++ standard library functions. | ||
| 31 | -target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") | ||
| 32 | - | ||
| 33 | -# Add dependency libraries and include directories. Add any application-specific | ||
| 34 | -# dependencies here. | ||
| 35 | -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) | ||
| 36 | -target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") | ||
| 37 | -target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") | ||
| 38 | - | ||
| 39 | -# Run the Flutter tool portions of the build. This must not be removed. | ||
| 40 | -add_dependencies(${BINARY_NAME} flutter_assemble) |
| 1 | -// Microsoft Visual C++ generated resource script. | ||
| 2 | -// | ||
| 3 | -#pragma code_page(65001) | ||
| 4 | -#include "resource.h" | ||
| 5 | - | ||
| 6 | -#define APSTUDIO_READONLY_SYMBOLS | ||
| 7 | -///////////////////////////////////////////////////////////////////////////// | ||
| 8 | -// | ||
| 9 | -// Generated from the TEXTINCLUDE 2 resource. | ||
| 10 | -// | ||
| 11 | -#include "winres.h" | ||
| 12 | - | ||
| 13 | -///////////////////////////////////////////////////////////////////////////// | ||
| 14 | -#undef APSTUDIO_READONLY_SYMBOLS | ||
| 15 | - | ||
| 16 | -///////////////////////////////////////////////////////////////////////////// | ||
| 17 | -// English (United States) resources | ||
| 18 | - | ||
| 19 | -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
| 20 | -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
| 21 | - | ||
| 22 | -#ifdef APSTUDIO_INVOKED | ||
| 23 | -///////////////////////////////////////////////////////////////////////////// | ||
| 24 | -// | ||
| 25 | -// TEXTINCLUDE | ||
| 26 | -// | ||
| 27 | - | ||
| 28 | -1 TEXTINCLUDE | ||
| 29 | -BEGIN | ||
| 30 | - "resource.h\0" | ||
| 31 | -END | ||
| 32 | - | ||
| 33 | -2 TEXTINCLUDE | ||
| 34 | -BEGIN | ||
| 35 | - "#include ""winres.h""\r\n" | ||
| 36 | - "\0" | ||
| 37 | -END | ||
| 38 | - | ||
| 39 | -3 TEXTINCLUDE | ||
| 40 | -BEGIN | ||
| 41 | - "\r\n" | ||
| 42 | - "\0" | ||
| 43 | -END | ||
| 44 | - | ||
| 45 | -#endif // APSTUDIO_INVOKED | ||
| 46 | - | ||
| 47 | - | ||
| 48 | -///////////////////////////////////////////////////////////////////////////// | ||
| 49 | -// | ||
| 50 | -// Icon | ||
| 51 | -// | ||
| 52 | - | ||
| 53 | -// Icon with lowest ID value placed first to ensure application icon | ||
| 54 | -// remains consistent on all systems. | ||
| 55 | -IDI_APP_ICON ICON "resources\\app_icon.ico" | ||
| 56 | - | ||
| 57 | - | ||
| 58 | -///////////////////////////////////////////////////////////////////////////// | ||
| 59 | -// | ||
| 60 | -// Version | ||
| 61 | -// | ||
| 62 | - | ||
| 63 | -#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) | ||
| 64 | -#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD | ||
| 65 | -#else | ||
| 66 | -#define VERSION_AS_NUMBER 1,0,0,0 | ||
| 67 | -#endif | ||
| 68 | - | ||
| 69 | -#if defined(FLUTTER_VERSION) | ||
| 70 | -#define VERSION_AS_STRING FLUTTER_VERSION | ||
| 71 | -#else | ||
| 72 | -#define VERSION_AS_STRING "1.0.0" | ||
| 73 | -#endif | ||
| 74 | - | ||
| 75 | -VS_VERSION_INFO VERSIONINFO | ||
| 76 | - FILEVERSION VERSION_AS_NUMBER | ||
| 77 | - PRODUCTVERSION VERSION_AS_NUMBER | ||
| 78 | - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
| 79 | -#ifdef _DEBUG | ||
| 80 | - FILEFLAGS VS_FF_DEBUG | ||
| 81 | -#else | ||
| 82 | - FILEFLAGS 0x0L | ||
| 83 | -#endif | ||
| 84 | - FILEOS VOS__WINDOWS32 | ||
| 85 | - FILETYPE VFT_APP | ||
| 86 | - FILESUBTYPE 0x0L | ||
| 87 | -BEGIN | ||
| 88 | - BLOCK "StringFileInfo" | ||
| 89 | - BEGIN | ||
| 90 | - BLOCK "040904e4" | ||
| 91 | - BEGIN | ||
| 92 | - VALUE "CompanyName", "Next-gen Kaldi" "\0" | ||
| 93 | - VALUE "FileDescription", "sherpa_onnx" "\0" | ||
| 94 | - VALUE "FileVersion", VERSION_AS_STRING "\0" | ||
| 95 | - VALUE "InternalName", "sherpa_onnx" "\0" | ||
| 96 | - VALUE "LegalCopyright", "Copyright (C) 2024 Next-gen Kaldi. All rights reserved." "\0" | ||
| 97 | - VALUE "OriginalFilename", "sherpa_onnx.exe" "\0" | ||
| 98 | - VALUE "ProductName", "sherpa_onnx" "\0" | ||
| 99 | - VALUE "ProductVersion", VERSION_AS_STRING "\0" | ||
| 100 | - END | ||
| 101 | - END | ||
| 102 | - BLOCK "VarFileInfo" | ||
| 103 | - BEGIN | ||
| 104 | - VALUE "Translation", 0x409, 1252 | ||
| 105 | - END | ||
| 106 | -END | ||
| 107 | - | ||
| 108 | -#endif // English (United States) resources | ||
| 109 | -///////////////////////////////////////////////////////////////////////////// | ||
| 110 | - | ||
| 111 | - | ||
| 112 | - | ||
| 113 | -#ifndef APSTUDIO_INVOKED | ||
| 114 | -///////////////////////////////////////////////////////////////////////////// | ||
| 115 | -// | ||
| 116 | -// Generated from the TEXTINCLUDE 3 resource. | ||
| 117 | -// | ||
| 118 | - | ||
| 119 | - | ||
| 120 | -///////////////////////////////////////////////////////////////////////////// | ||
| 121 | -#endif // not APSTUDIO_INVOKED |
| 1 | -#include "flutter_window.h" | ||
| 2 | - | ||
| 3 | -#include <optional> | ||
| 4 | - | ||
| 5 | -#include "flutter/generated_plugin_registrant.h" | ||
| 6 | - | ||
| 7 | -FlutterWindow::FlutterWindow(const flutter::DartProject& project) | ||
| 8 | - : project_(project) {} | ||
| 9 | - | ||
| 10 | -FlutterWindow::~FlutterWindow() {} | ||
| 11 | - | ||
| 12 | -bool FlutterWindow::OnCreate() { | ||
| 13 | - if (!Win32Window::OnCreate()) { | ||
| 14 | - return false; | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - RECT frame = GetClientArea(); | ||
| 18 | - | ||
| 19 | - // The size here must match the window dimensions to avoid unnecessary surface | ||
| 20 | - // creation / destruction in the startup path. | ||
| 21 | - flutter_controller_ = std::make_unique<flutter::FlutterViewController>( | ||
| 22 | - frame.right - frame.left, frame.bottom - frame.top, project_); | ||
| 23 | - // Ensure that basic setup of the controller was successful. | ||
| 24 | - if (!flutter_controller_->engine() || !flutter_controller_->view()) { | ||
| 25 | - return false; | ||
| 26 | - } | ||
| 27 | - RegisterPlugins(flutter_controller_->engine()); | ||
| 28 | - SetChildContent(flutter_controller_->view()->GetNativeWindow()); | ||
| 29 | - | ||
| 30 | - flutter_controller_->engine()->SetNextFrameCallback([&]() { | ||
| 31 | - this->Show(); | ||
| 32 | - }); | ||
| 33 | - | ||
| 34 | - // Flutter can complete the first frame before the "show window" callback is | ||
| 35 | - // registered. The following call ensures a frame is pending to ensure the | ||
| 36 | - // window is shown. It is a no-op if the first frame hasn't completed yet. | ||
| 37 | - flutter_controller_->ForceRedraw(); | ||
| 38 | - | ||
| 39 | - return true; | ||
| 40 | -} | ||
| 41 | - | ||
| 42 | -void FlutterWindow::OnDestroy() { | ||
| 43 | - if (flutter_controller_) { | ||
| 44 | - flutter_controller_ = nullptr; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - Win32Window::OnDestroy(); | ||
| 48 | -} | ||
| 49 | - | ||
| 50 | -LRESULT | ||
| 51 | -FlutterWindow::MessageHandler(HWND hwnd, UINT const message, | ||
| 52 | - WPARAM const wparam, | ||
| 53 | - LPARAM const lparam) noexcept { | ||
| 54 | - // Give Flutter, including plugins, an opportunity to handle window messages. | ||
| 55 | - if (flutter_controller_) { | ||
| 56 | - std::optional<LRESULT> result = | ||
| 57 | - flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, | ||
| 58 | - lparam); | ||
| 59 | - if (result) { | ||
| 60 | - return *result; | ||
| 61 | - } | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - switch (message) { | ||
| 65 | - case WM_FONTCHANGE: | ||
| 66 | - flutter_controller_->engine()->ReloadSystemFonts(); | ||
| 67 | - break; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - return Win32Window::MessageHandler(hwnd, message, wparam, lparam); | ||
| 71 | -} |
| 1 | -#ifndef RUNNER_FLUTTER_WINDOW_H_ | ||
| 2 | -#define RUNNER_FLUTTER_WINDOW_H_ | ||
| 3 | - | ||
| 4 | -#include <flutter/dart_project.h> | ||
| 5 | -#include <flutter/flutter_view_controller.h> | ||
| 6 | - | ||
| 7 | -#include <memory> | ||
| 8 | - | ||
| 9 | -#include "win32_window.h" | ||
| 10 | - | ||
| 11 | -// A window that does nothing but host a Flutter view. | ||
| 12 | -class FlutterWindow : public Win32Window { | ||
| 13 | - public: | ||
| 14 | - // Creates a new FlutterWindow hosting a Flutter view running |project|. | ||
| 15 | - explicit FlutterWindow(const flutter::DartProject& project); | ||
| 16 | - virtual ~FlutterWindow(); | ||
| 17 | - | ||
| 18 | - protected: | ||
| 19 | - // Win32Window: | ||
| 20 | - bool OnCreate() override; | ||
| 21 | - void OnDestroy() override; | ||
| 22 | - LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, | ||
| 23 | - LPARAM const lparam) noexcept override; | ||
| 24 | - | ||
| 25 | - private: | ||
| 26 | - // The project to run. | ||
| 27 | - flutter::DartProject project_; | ||
| 28 | - | ||
| 29 | - // The Flutter instance hosted by this window. | ||
| 30 | - std::unique_ptr<flutter::FlutterViewController> flutter_controller_; | ||
| 31 | -}; | ||
| 32 | - | ||
| 33 | -#endif // RUNNER_FLUTTER_WINDOW_H_ |
| 1 | -#include <flutter/dart_project.h> | ||
| 2 | -#include <flutter/flutter_view_controller.h> | ||
| 3 | -#include <windows.h> | ||
| 4 | - | ||
| 5 | -#include "flutter_window.h" | ||
| 6 | -#include "utils.h" | ||
| 7 | - | ||
| 8 | -int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, | ||
| 9 | - _In_ wchar_t *command_line, _In_ int show_command) { | ||
| 10 | - // Attach to console when present (e.g., 'flutter run') or create a | ||
| 11 | - // new console when running with a debugger. | ||
| 12 | - if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { | ||
| 13 | - CreateAndAttachConsole(); | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - // Initialize COM, so that it is available for use in the library and/or | ||
| 17 | - // plugins. | ||
| 18 | - ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); | ||
| 19 | - | ||
| 20 | - flutter::DartProject project(L"data"); | ||
| 21 | - | ||
| 22 | - std::vector<std::string> command_line_arguments = | ||
| 23 | - GetCommandLineArguments(); | ||
| 24 | - | ||
| 25 | - project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); | ||
| 26 | - | ||
| 27 | - FlutterWindow window(project); | ||
| 28 | - Win32Window::Point origin(10, 10); | ||
| 29 | - Win32Window::Size size(1280, 720); | ||
| 30 | - if (!window.Create(L"sherpa_onnx", origin, size)) { | ||
| 31 | - return EXIT_FAILURE; | ||
| 32 | - } | ||
| 33 | - window.SetQuitOnClose(true); | ||
| 34 | - | ||
| 35 | - ::MSG msg; | ||
| 36 | - while (::GetMessage(&msg, nullptr, 0, 0)) { | ||
| 37 | - ::TranslateMessage(&msg); | ||
| 38 | - ::DispatchMessage(&msg); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - ::CoUninitialize(); | ||
| 42 | - return EXIT_SUCCESS; | ||
| 43 | -} |
| 1 | -//{{NO_DEPENDENCIES}} | ||
| 2 | -// Microsoft Visual C++ generated include file. | ||
| 3 | -// Used by Runner.rc | ||
| 4 | -// | ||
| 5 | -#define IDI_APP_ICON 101 | ||
| 6 | - | ||
| 7 | -// Next default values for new objects | ||
| 8 | -// | ||
| 9 | -#ifdef APSTUDIO_INVOKED | ||
| 10 | -#ifndef APSTUDIO_READONLY_SYMBOLS | ||
| 11 | -#define _APS_NEXT_RESOURCE_VALUE 102 | ||
| 12 | -#define _APS_NEXT_COMMAND_VALUE 40001 | ||
| 13 | -#define _APS_NEXT_CONTROL_VALUE 1001 | ||
| 14 | -#define _APS_NEXT_SYMED_VALUE 101 | ||
| 15 | -#endif | ||
| 16 | -#endif |
不能预览此文件类型
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
| 2 | -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
| 3 | - <application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
| 4 | - <windowsSettings> | ||
| 5 | - <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> | ||
| 6 | - </windowsSettings> | ||
| 7 | - </application> | ||
| 8 | - <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
| 9 | - <application> | ||
| 10 | - <!-- Windows 10 and Windows 11 --> | ||
| 11 | - <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> | ||
| 12 | - <!-- Windows 8.1 --> | ||
| 13 | - <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> | ||
| 14 | - <!-- Windows 8 --> | ||
| 15 | - <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> | ||
| 16 | - <!-- Windows 7 --> | ||
| 17 | - <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> | ||
| 18 | - </application> | ||
| 19 | - </compatibility> | ||
| 20 | -</assembly> |
| 1 | -#include "utils.h" | ||
| 2 | - | ||
| 3 | -#include <flutter_windows.h> | ||
| 4 | -#include <io.h> | ||
| 5 | -#include <stdio.h> | ||
| 6 | -#include <windows.h> | ||
| 7 | - | ||
| 8 | -#include <iostream> | ||
| 9 | - | ||
| 10 | -void CreateAndAttachConsole() { | ||
| 11 | - if (::AllocConsole()) { | ||
| 12 | - FILE *unused; | ||
| 13 | - if (freopen_s(&unused, "CONOUT$", "w", stdout)) { | ||
| 14 | - _dup2(_fileno(stdout), 1); | ||
| 15 | - } | ||
| 16 | - if (freopen_s(&unused, "CONOUT$", "w", stderr)) { | ||
| 17 | - _dup2(_fileno(stdout), 2); | ||
| 18 | - } | ||
| 19 | - std::ios::sync_with_stdio(); | ||
| 20 | - FlutterDesktopResyncOutputStreams(); | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -std::vector<std::string> GetCommandLineArguments() { | ||
| 25 | - // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. | ||
| 26 | - int argc; | ||
| 27 | - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); | ||
| 28 | - if (argv == nullptr) { | ||
| 29 | - return std::vector<std::string>(); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - std::vector<std::string> command_line_arguments; | ||
| 33 | - | ||
| 34 | - // Skip the first argument as it's the binary name. | ||
| 35 | - for (int i = 1; i < argc; i++) { | ||
| 36 | - command_line_arguments.push_back(Utf8FromUtf16(argv[i])); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - ::LocalFree(argv); | ||
| 40 | - | ||
| 41 | - return command_line_arguments; | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -std::string Utf8FromUtf16(const wchar_t* utf16_string) { | ||
| 45 | - if (utf16_string == nullptr) { | ||
| 46 | - return std::string(); | ||
| 47 | - } | ||
| 48 | - unsigned int target_length = ::WideCharToMultiByte( | ||
| 49 | - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, | ||
| 50 | - -1, nullptr, 0, nullptr, nullptr) | ||
| 51 | - -1; // remove the trailing null character | ||
| 52 | - int input_length = (int)wcslen(utf16_string); | ||
| 53 | - std::string utf8_string; | ||
| 54 | - if (target_length == 0 || target_length > utf8_string.max_size()) { | ||
| 55 | - return utf8_string; | ||
| 56 | - } | ||
| 57 | - utf8_string.resize(target_length); | ||
| 58 | - int converted_length = ::WideCharToMultiByte( | ||
| 59 | - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, | ||
| 60 | - input_length, utf8_string.data(), target_length, nullptr, nullptr); | ||
| 61 | - if (converted_length == 0) { | ||
| 62 | - return std::string(); | ||
| 63 | - } | ||
| 64 | - return utf8_string; | ||
| 65 | -} |
| 1 | -#ifndef RUNNER_UTILS_H_ | ||
| 2 | -#define RUNNER_UTILS_H_ | ||
| 3 | - | ||
| 4 | -#include <string> | ||
| 5 | -#include <vector> | ||
| 6 | - | ||
| 7 | -// Creates a console for the process, and redirects stdout and stderr to | ||
| 8 | -// it for both the runner and the Flutter library. | ||
| 9 | -void CreateAndAttachConsole(); | ||
| 10 | - | ||
| 11 | -// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string | ||
| 12 | -// encoded in UTF-8. Returns an empty std::string on failure. | ||
| 13 | -std::string Utf8FromUtf16(const wchar_t* utf16_string); | ||
| 14 | - | ||
| 15 | -// Gets the command line arguments passed in as a std::vector<std::string>, | ||
| 16 | -// encoded in UTF-8. Returns an empty std::vector<std::string> on failure. | ||
| 17 | -std::vector<std::string> GetCommandLineArguments(); | ||
| 18 | - | ||
| 19 | -#endif // RUNNER_UTILS_H_ |
| 1 | -#include "win32_window.h" | ||
| 2 | - | ||
| 3 | -#include <dwmapi.h> | ||
| 4 | -#include <flutter_windows.h> | ||
| 5 | - | ||
| 6 | -#include "resource.h" | ||
| 7 | - | ||
| 8 | -namespace { | ||
| 9 | - | ||
| 10 | -/// Window attribute that enables dark mode window decorations. | ||
| 11 | -/// | ||
| 12 | -/// Redefined in case the developer's machine has a Windows SDK older than | ||
| 13 | -/// version 10.0.22000.0. | ||
| 14 | -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute | ||
| 15 | -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE | ||
| 16 | -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 | ||
| 17 | -#endif | ||
| 18 | - | ||
| 19 | -constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; | ||
| 20 | - | ||
| 21 | -/// Registry key for app theme preference. | ||
| 22 | -/// | ||
| 23 | -/// A value of 0 indicates apps should use dark mode. A non-zero or missing | ||
| 24 | -/// value indicates apps should use light mode. | ||
| 25 | -constexpr const wchar_t kGetPreferredBrightnessRegKey[] = | ||
| 26 | - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; | ||
| 27 | -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; | ||
| 28 | - | ||
| 29 | -// The number of Win32Window objects that currently exist. | ||
| 30 | -static int g_active_window_count = 0; | ||
| 31 | - | ||
| 32 | -using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); | ||
| 33 | - | ||
| 34 | -// Scale helper to convert logical scaler values to physical using passed in | ||
| 35 | -// scale factor | ||
| 36 | -int Scale(int source, double scale_factor) { | ||
| 37 | - return static_cast<int>(source * scale_factor); | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. | ||
| 41 | -// This API is only needed for PerMonitor V1 awareness mode. | ||
| 42 | -void EnableFullDpiSupportIfAvailable(HWND hwnd) { | ||
| 43 | - HMODULE user32_module = LoadLibraryA("User32.dll"); | ||
| 44 | - if (!user32_module) { | ||
| 45 | - return; | ||
| 46 | - } | ||
| 47 | - auto enable_non_client_dpi_scaling = | ||
| 48 | - reinterpret_cast<EnableNonClientDpiScaling*>( | ||
| 49 | - GetProcAddress(user32_module, "EnableNonClientDpiScaling")); | ||
| 50 | - if (enable_non_client_dpi_scaling != nullptr) { | ||
| 51 | - enable_non_client_dpi_scaling(hwnd); | ||
| 52 | - } | ||
| 53 | - FreeLibrary(user32_module); | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -} // namespace | ||
| 57 | - | ||
| 58 | -// Manages the Win32Window's window class registration. | ||
| 59 | -class WindowClassRegistrar { | ||
| 60 | - public: | ||
| 61 | - ~WindowClassRegistrar() = default; | ||
| 62 | - | ||
| 63 | - // Returns the singleton registrar instance. | ||
| 64 | - static WindowClassRegistrar* GetInstance() { | ||
| 65 | - if (!instance_) { | ||
| 66 | - instance_ = new WindowClassRegistrar(); | ||
| 67 | - } | ||
| 68 | - return instance_; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - // Returns the name of the window class, registering the class if it hasn't | ||
| 72 | - // previously been registered. | ||
| 73 | - const wchar_t* GetWindowClass(); | ||
| 74 | - | ||
| 75 | - // Unregisters the window class. Should only be called if there are no | ||
| 76 | - // instances of the window. | ||
| 77 | - void UnregisterWindowClass(); | ||
| 78 | - | ||
| 79 | - private: | ||
| 80 | - WindowClassRegistrar() = default; | ||
| 81 | - | ||
| 82 | - static WindowClassRegistrar* instance_; | ||
| 83 | - | ||
| 84 | - bool class_registered_ = false; | ||
| 85 | -}; | ||
| 86 | - | ||
| 87 | -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; | ||
| 88 | - | ||
| 89 | -const wchar_t* WindowClassRegistrar::GetWindowClass() { | ||
| 90 | - if (!class_registered_) { | ||
| 91 | - WNDCLASS window_class{}; | ||
| 92 | - window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); | ||
| 93 | - window_class.lpszClassName = kWindowClassName; | ||
| 94 | - window_class.style = CS_HREDRAW | CS_VREDRAW; | ||
| 95 | - window_class.cbClsExtra = 0; | ||
| 96 | - window_class.cbWndExtra = 0; | ||
| 97 | - window_class.hInstance = GetModuleHandle(nullptr); | ||
| 98 | - window_class.hIcon = | ||
| 99 | - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); | ||
| 100 | - window_class.hbrBackground = 0; | ||
| 101 | - window_class.lpszMenuName = nullptr; | ||
| 102 | - window_class.lpfnWndProc = Win32Window::WndProc; | ||
| 103 | - RegisterClass(&window_class); | ||
| 104 | - class_registered_ = true; | ||
| 105 | - } | ||
| 106 | - return kWindowClassName; | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | -void WindowClassRegistrar::UnregisterWindowClass() { | ||
| 110 | - UnregisterClass(kWindowClassName, nullptr); | ||
| 111 | - class_registered_ = false; | ||
| 112 | -} | ||
| 113 | - | ||
| 114 | -Win32Window::Win32Window() { | ||
| 115 | - ++g_active_window_count; | ||
| 116 | -} | ||
| 117 | - | ||
| 118 | -Win32Window::~Win32Window() { | ||
| 119 | - --g_active_window_count; | ||
| 120 | - Destroy(); | ||
| 121 | -} | ||
| 122 | - | ||
| 123 | -bool Win32Window::Create(const std::wstring& title, | ||
| 124 | - const Point& origin, | ||
| 125 | - const Size& size) { | ||
| 126 | - Destroy(); | ||
| 127 | - | ||
| 128 | - const wchar_t* window_class = | ||
| 129 | - WindowClassRegistrar::GetInstance()->GetWindowClass(); | ||
| 130 | - | ||
| 131 | - const POINT target_point = {static_cast<LONG>(origin.x), | ||
| 132 | - static_cast<LONG>(origin.y)}; | ||
| 133 | - HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); | ||
| 134 | - UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); | ||
| 135 | - double scale_factor = dpi / 96.0; | ||
| 136 | - | ||
| 137 | - HWND window = CreateWindow( | ||
| 138 | - window_class, title.c_str(), WS_OVERLAPPEDWINDOW, | ||
| 139 | - Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), | ||
| 140 | - Scale(size.width, scale_factor), Scale(size.height, scale_factor), | ||
| 141 | - nullptr, nullptr, GetModuleHandle(nullptr), this); | ||
| 142 | - | ||
| 143 | - if (!window) { | ||
| 144 | - return false; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - UpdateTheme(window); | ||
| 148 | - | ||
| 149 | - return OnCreate(); | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -bool Win32Window::Show() { | ||
| 153 | - return ShowWindow(window_handle_, SW_SHOWNORMAL); | ||
| 154 | -} | ||
| 155 | - | ||
| 156 | -// static | ||
| 157 | -LRESULT CALLBACK Win32Window::WndProc(HWND const window, | ||
| 158 | - UINT const message, | ||
| 159 | - WPARAM const wparam, | ||
| 160 | - LPARAM const lparam) noexcept { | ||
| 161 | - if (message == WM_NCCREATE) { | ||
| 162 | - auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam); | ||
| 163 | - SetWindowLongPtr(window, GWLP_USERDATA, | ||
| 164 | - reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams)); | ||
| 165 | - | ||
| 166 | - auto that = static_cast<Win32Window*>(window_struct->lpCreateParams); | ||
| 167 | - EnableFullDpiSupportIfAvailable(window); | ||
| 168 | - that->window_handle_ = window; | ||
| 169 | - } else if (Win32Window* that = GetThisFromHandle(window)) { | ||
| 170 | - return that->MessageHandler(window, message, wparam, lparam); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - return DefWindowProc(window, message, wparam, lparam); | ||
| 174 | -} | ||
| 175 | - | ||
| 176 | -LRESULT | ||
| 177 | -Win32Window::MessageHandler(HWND hwnd, | ||
| 178 | - UINT const message, | ||
| 179 | - WPARAM const wparam, | ||
| 180 | - LPARAM const lparam) noexcept { | ||
| 181 | - switch (message) { | ||
| 182 | - case WM_DESTROY: | ||
| 183 | - window_handle_ = nullptr; | ||
| 184 | - Destroy(); | ||
| 185 | - if (quit_on_close_) { | ||
| 186 | - PostQuitMessage(0); | ||
| 187 | - } | ||
| 188 | - return 0; | ||
| 189 | - | ||
| 190 | - case WM_DPICHANGED: { | ||
| 191 | - auto newRectSize = reinterpret_cast<RECT*>(lparam); | ||
| 192 | - LONG newWidth = newRectSize->right - newRectSize->left; | ||
| 193 | - LONG newHeight = newRectSize->bottom - newRectSize->top; | ||
| 194 | - | ||
| 195 | - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, | ||
| 196 | - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); | ||
| 197 | - | ||
| 198 | - return 0; | ||
| 199 | - } | ||
| 200 | - case WM_SIZE: { | ||
| 201 | - RECT rect = GetClientArea(); | ||
| 202 | - if (child_content_ != nullptr) { | ||
| 203 | - // Size and position the child window. | ||
| 204 | - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, | ||
| 205 | - rect.bottom - rect.top, TRUE); | ||
| 206 | - } | ||
| 207 | - return 0; | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - case WM_ACTIVATE: | ||
| 211 | - if (child_content_ != nullptr) { | ||
| 212 | - SetFocus(child_content_); | ||
| 213 | - } | ||
| 214 | - return 0; | ||
| 215 | - | ||
| 216 | - case WM_DWMCOLORIZATIONCOLORCHANGED: | ||
| 217 | - UpdateTheme(hwnd); | ||
| 218 | - return 0; | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - return DefWindowProc(window_handle_, message, wparam, lparam); | ||
| 222 | -} | ||
| 223 | - | ||
| 224 | -void Win32Window::Destroy() { | ||
| 225 | - OnDestroy(); | ||
| 226 | - | ||
| 227 | - if (window_handle_) { | ||
| 228 | - DestroyWindow(window_handle_); | ||
| 229 | - window_handle_ = nullptr; | ||
| 230 | - } | ||
| 231 | - if (g_active_window_count == 0) { | ||
| 232 | - WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); | ||
| 233 | - } | ||
| 234 | -} | ||
| 235 | - | ||
| 236 | -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { | ||
| 237 | - return reinterpret_cast<Win32Window*>( | ||
| 238 | - GetWindowLongPtr(window, GWLP_USERDATA)); | ||
| 239 | -} | ||
| 240 | - | ||
| 241 | -void Win32Window::SetChildContent(HWND content) { | ||
| 242 | - child_content_ = content; | ||
| 243 | - SetParent(content, window_handle_); | ||
| 244 | - RECT frame = GetClientArea(); | ||
| 245 | - | ||
| 246 | - MoveWindow(content, frame.left, frame.top, frame.right - frame.left, | ||
| 247 | - frame.bottom - frame.top, true); | ||
| 248 | - | ||
| 249 | - SetFocus(child_content_); | ||
| 250 | -} | ||
| 251 | - | ||
| 252 | -RECT Win32Window::GetClientArea() { | ||
| 253 | - RECT frame; | ||
| 254 | - GetClientRect(window_handle_, &frame); | ||
| 255 | - return frame; | ||
| 256 | -} | ||
| 257 | - | ||
| 258 | -HWND Win32Window::GetHandle() { | ||
| 259 | - return window_handle_; | ||
| 260 | -} | ||
| 261 | - | ||
| 262 | -void Win32Window::SetQuitOnClose(bool quit_on_close) { | ||
| 263 | - quit_on_close_ = quit_on_close; | ||
| 264 | -} | ||
| 265 | - | ||
| 266 | -bool Win32Window::OnCreate() { | ||
| 267 | - // No-op; provided for subclasses. | ||
| 268 | - return true; | ||
| 269 | -} | ||
| 270 | - | ||
| 271 | -void Win32Window::OnDestroy() { | ||
| 272 | - // No-op; provided for subclasses. | ||
| 273 | -} | ||
| 274 | - | ||
| 275 | -void Win32Window::UpdateTheme(HWND const window) { | ||
| 276 | - DWORD light_mode; | ||
| 277 | - DWORD light_mode_size = sizeof(light_mode); | ||
| 278 | - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, | ||
| 279 | - kGetPreferredBrightnessRegValue, | ||
| 280 | - RRF_RT_REG_DWORD, nullptr, &light_mode, | ||
| 281 | - &light_mode_size); | ||
| 282 | - | ||
| 283 | - if (result == ERROR_SUCCESS) { | ||
| 284 | - BOOL enable_dark_mode = light_mode == 0; | ||
| 285 | - DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, | ||
| 286 | - &enable_dark_mode, sizeof(enable_dark_mode)); | ||
| 287 | - } | ||
| 288 | -} |
| 1 | -#ifndef RUNNER_WIN32_WINDOW_H_ | ||
| 2 | -#define RUNNER_WIN32_WINDOW_H_ | ||
| 3 | - | ||
| 4 | -#include <windows.h> | ||
| 5 | - | ||
| 6 | -#include <functional> | ||
| 7 | -#include <memory> | ||
| 8 | -#include <string> | ||
| 9 | - | ||
| 10 | -// A class abstraction for a high DPI-aware Win32 Window. Intended to be | ||
| 11 | -// inherited from by classes that wish to specialize with custom | ||
| 12 | -// rendering and input handling | ||
| 13 | -class Win32Window { | ||
| 14 | - public: | ||
| 15 | - struct Point { | ||
| 16 | - unsigned int x; | ||
| 17 | - unsigned int y; | ||
| 18 | - Point(unsigned int x, unsigned int y) : x(x), y(y) {} | ||
| 19 | - }; | ||
| 20 | - | ||
| 21 | - struct Size { | ||
| 22 | - unsigned int width; | ||
| 23 | - unsigned int height; | ||
| 24 | - Size(unsigned int width, unsigned int height) | ||
| 25 | - : width(width), height(height) {} | ||
| 26 | - }; | ||
| 27 | - | ||
| 28 | - Win32Window(); | ||
| 29 | - virtual ~Win32Window(); | ||
| 30 | - | ||
| 31 | - // Creates a win32 window with |title| that is positioned and sized using | ||
| 32 | - // |origin| and |size|. New windows are created on the default monitor. Window | ||
| 33 | - // sizes are specified to the OS in physical pixels, hence to ensure a | ||
| 34 | - // consistent size this function will scale the inputted width and height as | ||
| 35 | - // as appropriate for the default monitor. The window is invisible until | ||
| 36 | - // |Show| is called. Returns true if the window was created successfully. | ||
| 37 | - bool Create(const std::wstring& title, const Point& origin, const Size& size); | ||
| 38 | - | ||
| 39 | - // Show the current window. Returns true if the window was successfully shown. | ||
| 40 | - bool Show(); | ||
| 41 | - | ||
| 42 | - // Release OS resources associated with window. | ||
| 43 | - void Destroy(); | ||
| 44 | - | ||
| 45 | - // Inserts |content| into the window tree. | ||
| 46 | - void SetChildContent(HWND content); | ||
| 47 | - | ||
| 48 | - // Returns the backing Window handle to enable clients to set icon and other | ||
| 49 | - // window properties. Returns nullptr if the window has been destroyed. | ||
| 50 | - HWND GetHandle(); | ||
| 51 | - | ||
| 52 | - // If true, closing this window will quit the application. | ||
| 53 | - void SetQuitOnClose(bool quit_on_close); | ||
| 54 | - | ||
| 55 | - // Return a RECT representing the bounds of the current client area. | ||
| 56 | - RECT GetClientArea(); | ||
| 57 | - | ||
| 58 | - protected: | ||
| 59 | - // Processes and route salient window messages for mouse handling, | ||
| 60 | - // size change and DPI. Delegates handling of these to member overloads that | ||
| 61 | - // inheriting classes can handle. | ||
| 62 | - virtual LRESULT MessageHandler(HWND window, | ||
| 63 | - UINT const message, | ||
| 64 | - WPARAM const wparam, | ||
| 65 | - LPARAM const lparam) noexcept; | ||
| 66 | - | ||
| 67 | - // Called when CreateAndShow is called, allowing subclass window-related | ||
| 68 | - // setup. Subclasses should return false if setup fails. | ||
| 69 | - virtual bool OnCreate(); | ||
| 70 | - | ||
| 71 | - // Called when Destroy is called. | ||
| 72 | - virtual void OnDestroy(); | ||
| 73 | - | ||
| 74 | - private: | ||
| 75 | - friend class WindowClassRegistrar; | ||
| 76 | - | ||
| 77 | - // OS callback called by message pump. Handles the WM_NCCREATE message which | ||
| 78 | - // is passed when the non-client area is being created and enables automatic | ||
| 79 | - // non-client DPI scaling so that the non-client area automatically | ||
| 80 | - // responds to changes in DPI. All other messages are handled by | ||
| 81 | - // MessageHandler. | ||
| 82 | - static LRESULT CALLBACK WndProc(HWND const window, | ||
| 83 | - UINT const message, | ||
| 84 | - WPARAM const wparam, | ||
| 85 | - LPARAM const lparam) noexcept; | ||
| 86 | - | ||
| 87 | - // Retrieves a class instance pointer for |window| | ||
| 88 | - static Win32Window* GetThisFromHandle(HWND const window) noexcept; | ||
| 89 | - | ||
| 90 | - // Update the window frame's theme to match the system theme. | ||
| 91 | - static void UpdateTheme(HWND const window); | ||
| 92 | - | ||
| 93 | - bool quit_on_close_ = false; | ||
| 94 | - | ||
| 95 | - // window handle for top level window. | ||
| 96 | - HWND window_handle_ = nullptr; | ||
| 97 | - | ||
| 98 | - // window handle for hosted content. | ||
| 99 | - HWND child_content_ = nullptr; | ||
| 100 | -}; | ||
| 101 | - | ||
| 102 | -#endif // RUNNER_WIN32_WINDOW_H_ |
sherpa-onnx/flutter/lib/sherpa_onnx.dart
已删除
100644 → 0
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:io'; | ||
| 3 | -import 'dart:ffi'; | ||
| 4 | - | ||
| 5 | -export 'src/feature_config.dart'; | ||
| 6 | -export 'src/offline_recognizer.dart'; | ||
| 7 | -export 'src/offline_stream.dart'; | ||
| 8 | -export 'src/online_recognizer.dart'; | ||
| 9 | -export 'src/online_stream.dart'; | ||
| 10 | -export 'src/speaker_identification.dart'; | ||
| 11 | -export 'src/tts.dart'; | ||
| 12 | -export 'src/vad.dart'; | ||
| 13 | -export 'src/wave_reader.dart'; | ||
| 14 | -export 'src/wave_writer.dart'; | ||
| 15 | - | ||
| 16 | -import 'src/sherpa_onnx_bindings.dart'; | ||
| 17 | - | ||
| 18 | -String? _path; | ||
| 19 | - | ||
| 20 | -final DynamicLibrary _dylib = () { | ||
| 21 | - if (Platform.isIOS) { | ||
| 22 | - throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); | ||
| 23 | - } | ||
| 24 | - if (Platform.isMacOS) { | ||
| 25 | - if (_path == null) { | ||
| 26 | - return DynamicLibrary.open('libsherpa-onnx-c-api.dylib'); | ||
| 27 | - } else { | ||
| 28 | - return DynamicLibrary.open('$_path/libsherpa-onnx-c-api.dylib'); | ||
| 29 | - } | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - if (Platform.isAndroid || Platform.isLinux) { | ||
| 33 | - if (_path == null) { | ||
| 34 | - return DynamicLibrary.open('libsherpa-onnx-c-api.so'); | ||
| 35 | - } else { | ||
| 36 | - return DynamicLibrary.open('$_path/libsherpa-onnx-c-api.so'); | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - if (Platform.isWindows) { | ||
| 41 | - if (_path == null) { | ||
| 42 | - return DynamicLibrary.open('sherpa-onnx-c-api.dll'); | ||
| 43 | - } else { | ||
| 44 | - return DynamicLibrary.open('$_path\\sherpa-onnx-c-api.dll'); | ||
| 45 | - } | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); | ||
| 49 | -}(); | ||
| 50 | - | ||
| 51 | -void initBindings([String? p]) { | ||
| 52 | - _path ??= p; | ||
| 53 | - SherpaOnnxBindings.init(_dylib); | ||
| 54 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | - | ||
| 3 | -class FeatureConfig { | ||
| 4 | - const FeatureConfig({this.sampleRate = 16000, this.featureDim = 80}); | ||
| 5 | - | ||
| 6 | - @override | ||
| 7 | - String toString() { | ||
| 8 | - return 'FeatureConfig(sampleRate: $sampleRate, featureDim: $featureDim)'; | ||
| 9 | - } | ||
| 10 | - | ||
| 11 | - final int sampleRate; | ||
| 12 | - final int featureDim; | ||
| 13 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:convert'; | ||
| 3 | -import 'dart:ffi'; | ||
| 4 | - | ||
| 5 | -import 'package:ffi/ffi.dart'; | ||
| 6 | - | ||
| 7 | -import './feature_config.dart'; | ||
| 8 | -import './offline_stream.dart'; | ||
| 9 | -import './sherpa_onnx_bindings.dart'; | ||
| 10 | - | ||
| 11 | -class OfflineTransducerModelConfig { | ||
| 12 | - const OfflineTransducerModelConfig({ | ||
| 13 | - this.encoder = '', | ||
| 14 | - this.decoder = '', | ||
| 15 | - this.joiner = '', | ||
| 16 | - }); | ||
| 17 | - | ||
| 18 | - @override | ||
| 19 | - String toString() { | ||
| 20 | - return 'OfflineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)'; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - final String encoder; | ||
| 24 | - final String decoder; | ||
| 25 | - final String joiner; | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -class OfflineParaformerModelConfig { | ||
| 29 | - const OfflineParaformerModelConfig({this.model = ''}); | ||
| 30 | - | ||
| 31 | - @override | ||
| 32 | - String toString() { | ||
| 33 | - return 'OfflineParaformerModelConfig(model: $model)'; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - final String model; | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -class OfflineNemoEncDecCtcModelConfig { | ||
| 40 | - const OfflineNemoEncDecCtcModelConfig({this.model = ''}); | ||
| 41 | - | ||
| 42 | - @override | ||
| 43 | - String toString() { | ||
| 44 | - return 'OfflineNemoEncDecCtcModelConfig(model: $model)'; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - final String model; | ||
| 48 | -} | ||
| 49 | - | ||
| 50 | -class OfflineWhisperModelConfig { | ||
| 51 | - const OfflineWhisperModelConfig( | ||
| 52 | - {this.encoder = '', | ||
| 53 | - this.decoder = '', | ||
| 54 | - this.language = '', | ||
| 55 | - this.task = '', | ||
| 56 | - this.tailPaddings = -1}); | ||
| 57 | - | ||
| 58 | - @override | ||
| 59 | - String toString() { | ||
| 60 | - return 'OfflineWhisperModelConfig(encoder: $encoder, decoder: $decoder, language: $language, task: $task, tailPaddings: $tailPaddings)'; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - final String encoder; | ||
| 64 | - final String decoder; | ||
| 65 | - final String language; | ||
| 66 | - final String task; | ||
| 67 | - final int tailPaddings; | ||
| 68 | -} | ||
| 69 | - | ||
| 70 | -class OfflineTdnnModelConfig { | ||
| 71 | - const OfflineTdnnModelConfig({this.model = ''}); | ||
| 72 | - | ||
| 73 | - @override | ||
| 74 | - String toString() { | ||
| 75 | - return 'OfflineTdnnModelConfig(model: $model)'; | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - final String model; | ||
| 79 | -} | ||
| 80 | - | ||
| 81 | -class OfflineLMConfig { | ||
| 82 | - const OfflineLMConfig({this.model = '', this.scale = 1.0}); | ||
| 83 | - | ||
| 84 | - @override | ||
| 85 | - String toString() { | ||
| 86 | - return 'OfflineLMConfig(model: $model, scale: $scale)'; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - final String model; | ||
| 90 | - final double scale; | ||
| 91 | -} | ||
| 92 | - | ||
| 93 | -class OfflineModelConfig { | ||
| 94 | - const OfflineModelConfig({ | ||
| 95 | - this.transducer = const OfflineTransducerModelConfig(), | ||
| 96 | - this.paraformer = const OfflineParaformerModelConfig(), | ||
| 97 | - this.nemoCtc = const OfflineNemoEncDecCtcModelConfig(), | ||
| 98 | - this.whisper = const OfflineWhisperModelConfig(), | ||
| 99 | - this.tdnn = const OfflineTdnnModelConfig(), | ||
| 100 | - required this.tokens, | ||
| 101 | - this.numThreads = 1, | ||
| 102 | - this.debug = true, | ||
| 103 | - this.provider = 'cpu', | ||
| 104 | - this.modelType = '', | ||
| 105 | - this.modelingUnit = '', | ||
| 106 | - this.bpeVocab = '', | ||
| 107 | - this.telespeechCtc = '', | ||
| 108 | - }); | ||
| 109 | - | ||
| 110 | - @override | ||
| 111 | - String toString() { | ||
| 112 | - return 'OfflineModelConfig(transducer: $transducer, paraformer: $paraformer, nemoCtc: $nemoCtc, whisper: $whisper, tdnn: $tdnn, tokens: $tokens, numThreads: $numThreads, debug: $debug, provider: $provider, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab, telespeechCtc: $telespeechCtc)'; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - final OfflineTransducerModelConfig transducer; | ||
| 116 | - final OfflineParaformerModelConfig paraformer; | ||
| 117 | - final OfflineNemoEncDecCtcModelConfig nemoCtc; | ||
| 118 | - final OfflineWhisperModelConfig whisper; | ||
| 119 | - final OfflineTdnnModelConfig tdnn; | ||
| 120 | - | ||
| 121 | - final String tokens; | ||
| 122 | - final int numThreads; | ||
| 123 | - final bool debug; | ||
| 124 | - final String provider; | ||
| 125 | - final String modelType; | ||
| 126 | - final String modelingUnit; | ||
| 127 | - final String bpeVocab; | ||
| 128 | - final String telespeechCtc; | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -class OfflineRecognizerConfig { | ||
| 132 | - const OfflineRecognizerConfig({ | ||
| 133 | - this.feat = const FeatureConfig(), | ||
| 134 | - required this.model, | ||
| 135 | - this.lm = const OfflineLMConfig(), | ||
| 136 | - this.decodingMethod = 'greedy_search', | ||
| 137 | - this.maxActivePaths = 4, | ||
| 138 | - this.hotwordsFile = '', | ||
| 139 | - this.hotwordsScore = 1.5, | ||
| 140 | - this.ruleFsts = '', | ||
| 141 | - this.ruleFars = '', | ||
| 142 | - }); | ||
| 143 | - | ||
| 144 | - @override | ||
| 145 | - String toString() { | ||
| 146 | - return 'OfflineRecognizerConfig(feat: $feat, model: $model, lm: $lm, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ruleFsts: $ruleFsts, ruleFars: $ruleFars)'; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - final FeatureConfig feat; | ||
| 150 | - final OfflineModelConfig model; | ||
| 151 | - final OfflineLMConfig lm; | ||
| 152 | - final String decodingMethod; | ||
| 153 | - | ||
| 154 | - final int maxActivePaths; | ||
| 155 | - | ||
| 156 | - final String hotwordsFile; | ||
| 157 | - | ||
| 158 | - final double hotwordsScore; | ||
| 159 | - | ||
| 160 | - final String ruleFsts; | ||
| 161 | - final String ruleFars; | ||
| 162 | -} | ||
| 163 | - | ||
| 164 | -class OfflineRecognizerResult { | ||
| 165 | - OfflineRecognizerResult( | ||
| 166 | - {required this.text, required this.tokens, required this.timestamps}); | ||
| 167 | - | ||
| 168 | - @override | ||
| 169 | - String toString() { | ||
| 170 | - return 'OfflineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)'; | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - final String text; | ||
| 174 | - final List<String> tokens; | ||
| 175 | - final List<double> timestamps; | ||
| 176 | -} | ||
| 177 | - | ||
| 178 | -class OfflineRecognizer { | ||
| 179 | - OfflineRecognizer._({required this.ptr, required this.config}); | ||
| 180 | - | ||
| 181 | - void free() { | ||
| 182 | - SherpaOnnxBindings.destroyOfflineRecognizer?.call(ptr); | ||
| 183 | - ptr = nullptr; | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - /// The user is responsible to call the OfflineRecognizer.free() | ||
| 187 | - /// method of the returned instance to avoid memory leak. | ||
| 188 | - factory OfflineRecognizer(OfflineRecognizerConfig config) { | ||
| 189 | - final c = calloc<SherpaOnnxOfflineRecognizerConfig>(); | ||
| 190 | - | ||
| 191 | - c.ref.feat.sampleRate = config.feat.sampleRate; | ||
| 192 | - c.ref.feat.featureDim = config.feat.featureDim; | ||
| 193 | - | ||
| 194 | - // transducer | ||
| 195 | - c.ref.model.transducer.encoder = | ||
| 196 | - config.model.transducer.encoder.toNativeUtf8(); | ||
| 197 | - c.ref.model.transducer.decoder = | ||
| 198 | - config.model.transducer.decoder.toNativeUtf8(); | ||
| 199 | - c.ref.model.transducer.joiner = | ||
| 200 | - config.model.transducer.joiner.toNativeUtf8(); | ||
| 201 | - | ||
| 202 | - // paraformer | ||
| 203 | - c.ref.model.paraformer.model = config.model.paraformer.model.toNativeUtf8(); | ||
| 204 | - | ||
| 205 | - // nemoCtc | ||
| 206 | - c.ref.model.nemoCtc.model = config.model.nemoCtc.model.toNativeUtf8(); | ||
| 207 | - | ||
| 208 | - // whisper | ||
| 209 | - c.ref.model.whisper.encoder = config.model.whisper.encoder.toNativeUtf8(); | ||
| 210 | - | ||
| 211 | - c.ref.model.whisper.decoder = config.model.whisper.decoder.toNativeUtf8(); | ||
| 212 | - | ||
| 213 | - c.ref.model.whisper.language = config.model.whisper.language.toNativeUtf8(); | ||
| 214 | - | ||
| 215 | - c.ref.model.whisper.task = config.model.whisper.task.toNativeUtf8(); | ||
| 216 | - | ||
| 217 | - c.ref.model.whisper.tailPaddings = config.model.whisper.tailPaddings; | ||
| 218 | - | ||
| 219 | - c.ref.model.tdnn.model = config.model.tdnn.model.toNativeUtf8(); | ||
| 220 | - | ||
| 221 | - c.ref.model.tokens = config.model.tokens.toNativeUtf8(); | ||
| 222 | - | ||
| 223 | - c.ref.model.numThreads = config.model.numThreads; | ||
| 224 | - c.ref.model.debug = config.model.debug ? 1 : 0; | ||
| 225 | - c.ref.model.provider = config.model.provider.toNativeUtf8(); | ||
| 226 | - c.ref.model.modelType = config.model.modelType.toNativeUtf8(); | ||
| 227 | - c.ref.model.modelingUnit = config.model.modelingUnit.toNativeUtf8(); | ||
| 228 | - c.ref.model.bpeVocab = config.model.bpeVocab.toNativeUtf8(); | ||
| 229 | - c.ref.model.telespeechCtc = config.model.telespeechCtc.toNativeUtf8(); | ||
| 230 | - | ||
| 231 | - c.ref.lm.model = config.lm.model.toNativeUtf8(); | ||
| 232 | - c.ref.lm.scale = config.lm.scale; | ||
| 233 | - | ||
| 234 | - c.ref.decodingMethod = config.decodingMethod.toNativeUtf8(); | ||
| 235 | - c.ref.maxActivePaths = config.maxActivePaths; | ||
| 236 | - | ||
| 237 | - c.ref.hotwordsFile = config.hotwordsFile.toNativeUtf8(); | ||
| 238 | - c.ref.hotwordsScore = config.hotwordsScore; | ||
| 239 | - | ||
| 240 | - c.ref.ruleFsts = config.ruleFsts.toNativeUtf8(); | ||
| 241 | - c.ref.ruleFars = config.ruleFars.toNativeUtf8(); | ||
| 242 | - | ||
| 243 | - final ptr = SherpaOnnxBindings.createOfflineRecognizer?.call(c) ?? nullptr; | ||
| 244 | - | ||
| 245 | - calloc.free(c.ref.ruleFars); | ||
| 246 | - calloc.free(c.ref.ruleFsts); | ||
| 247 | - calloc.free(c.ref.hotwordsFile); | ||
| 248 | - calloc.free(c.ref.decodingMethod); | ||
| 249 | - calloc.free(c.ref.lm.model); | ||
| 250 | - calloc.free(c.ref.model.telespeechCtc); | ||
| 251 | - calloc.free(c.ref.model.bpeVocab); | ||
| 252 | - calloc.free(c.ref.model.modelingUnit); | ||
| 253 | - calloc.free(c.ref.model.modelType); | ||
| 254 | - calloc.free(c.ref.model.provider); | ||
| 255 | - calloc.free(c.ref.model.tokens); | ||
| 256 | - calloc.free(c.ref.model.tdnn.model); | ||
| 257 | - calloc.free(c.ref.model.whisper.task); | ||
| 258 | - calloc.free(c.ref.model.whisper.language); | ||
| 259 | - calloc.free(c.ref.model.whisper.decoder); | ||
| 260 | - calloc.free(c.ref.model.whisper.encoder); | ||
| 261 | - calloc.free(c.ref.model.nemoCtc.model); | ||
| 262 | - calloc.free(c.ref.model.paraformer.model); | ||
| 263 | - calloc.free(c.ref.model.transducer.encoder); | ||
| 264 | - calloc.free(c.ref.model.transducer.decoder); | ||
| 265 | - calloc.free(c.ref.model.transducer.joiner); | ||
| 266 | - calloc.free(c); | ||
| 267 | - | ||
| 268 | - return OfflineRecognizer._(ptr: ptr, config: config); | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - /// The user has to invoke stream.free() on the returned instance | ||
| 272 | - /// to avoid memory leak | ||
| 273 | - OfflineStream createStream() { | ||
| 274 | - final p = SherpaOnnxBindings.createOfflineStream?.call(ptr) ?? nullptr; | ||
| 275 | - return OfflineStream(ptr: p); | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | - void decode(OfflineStream stream) { | ||
| 279 | - SherpaOnnxBindings.decodeOfflineStream?.call(ptr, stream.ptr); | ||
| 280 | - } | ||
| 281 | - | ||
| 282 | - OfflineRecognizerResult getResult(OfflineStream stream) { | ||
| 283 | - final json = | ||
| 284 | - SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ?? | ||
| 285 | - nullptr; | ||
| 286 | - if (json == nullptr) { | ||
| 287 | - return OfflineRecognizerResult(text: '', tokens: [], timestamps: []); | ||
| 288 | - } | ||
| 289 | - | ||
| 290 | - final parsedJson = jsonDecode(json.toDartString()); | ||
| 291 | - | ||
| 292 | - SherpaOnnxBindings.destroyOfflineStreamResultJson?.call(json); | ||
| 293 | - | ||
| 294 | - return OfflineRecognizerResult( | ||
| 295 | - text: parsedJson['text'], | ||
| 296 | - tokens: List<String>.from(parsedJson['tokens']), | ||
| 297 | - timestamps: List<double>.from(parsedJson['timestamps'])); | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - Pointer<SherpaOnnxOfflineRecognizer> ptr; | ||
| 301 | - OfflineRecognizerConfig config; | ||
| 302 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './sherpa_onnx_bindings.dart'; | ||
| 7 | - | ||
| 8 | -class OfflineStream { | ||
| 9 | - /// The user has to call OfflineStream.free() to avoid memory leak. | ||
| 10 | - OfflineStream({required this.ptr}); | ||
| 11 | - | ||
| 12 | - void free() { | ||
| 13 | - SherpaOnnxBindings.destroyOfflineStream?.call(ptr); | ||
| 14 | - ptr = nullptr; | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - /// If you have List<double> data, then you can use | ||
| 18 | - /// Float32List.fromList(data) to convert data to Float32List | ||
| 19 | - /// | ||
| 20 | - /// See | ||
| 21 | - /// https://api.flutter.dev/flutter/dart-core/List-class.html | ||
| 22 | - /// and | ||
| 23 | - /// https://api.flutter.dev/flutter/dart-typed_data/Float32List-class.html | ||
| 24 | - void acceptWaveform({required Float32List samples, required int sampleRate}) { | ||
| 25 | - final n = samples.length; | ||
| 26 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 27 | - | ||
| 28 | - final pList = p.asTypedList(n); | ||
| 29 | - pList.setAll(0, samples); | ||
| 30 | - | ||
| 31 | - SherpaOnnxBindings.acceptWaveformOffline?.call(ptr, sampleRate, p, n); | ||
| 32 | - | ||
| 33 | - calloc.free(p); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - Pointer<SherpaOnnxOfflineStream> ptr; | ||
| 37 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:convert'; | ||
| 3 | -import 'dart:ffi'; | ||
| 4 | - | ||
| 5 | -import 'package:ffi/ffi.dart'; | ||
| 6 | - | ||
| 7 | -import './feature_config.dart'; | ||
| 8 | -import './online_stream.dart'; | ||
| 9 | -import './sherpa_onnx_bindings.dart'; | ||
| 10 | - | ||
| 11 | -class OnlineTransducerModelConfig { | ||
| 12 | - const OnlineTransducerModelConfig({ | ||
| 13 | - this.encoder = '', | ||
| 14 | - this.decoder = '', | ||
| 15 | - this.joiner = '', | ||
| 16 | - }); | ||
| 17 | - | ||
| 18 | - @override | ||
| 19 | - String toString() { | ||
| 20 | - return 'OnlineTransducerModelConfig(encoder: $encoder, decoder: $decoder, joiner: $joiner)'; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - final String encoder; | ||
| 24 | - final String decoder; | ||
| 25 | - final String joiner; | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -class OnlineParaformerModelConfig { | ||
| 29 | - const OnlineParaformerModelConfig({this.encoder = '', this.decoder = ''}); | ||
| 30 | - | ||
| 31 | - @override | ||
| 32 | - String toString() { | ||
| 33 | - return 'OnlineParaformerModelConfig(encoder: $encoder, decoder: $decoder)'; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - final String encoder; | ||
| 37 | - final String decoder; | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -class OnlineZipformer2CtcModelConfig { | ||
| 41 | - const OnlineZipformer2CtcModelConfig({this.model = ''}); | ||
| 42 | - | ||
| 43 | - @override | ||
| 44 | - String toString() { | ||
| 45 | - return 'OnlineZipformer2CtcModelConfig(model: $model)'; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - final String model; | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -class OnlineModelConfig { | ||
| 52 | - const OnlineModelConfig({ | ||
| 53 | - this.transducer = const OnlineTransducerModelConfig(), | ||
| 54 | - this.paraformer = const OnlineParaformerModelConfig(), | ||
| 55 | - this.zipformer2Ctc = const OnlineZipformer2CtcModelConfig(), | ||
| 56 | - required this.tokens, | ||
| 57 | - this.numThreads = 1, | ||
| 58 | - this.provider = 'cpu', | ||
| 59 | - this.debug = true, | ||
| 60 | - this.modelType = '', | ||
| 61 | - this.modelingUnit = '', | ||
| 62 | - this.bpeVocab = '', | ||
| 63 | - }); | ||
| 64 | - | ||
| 65 | - @override | ||
| 66 | - String toString() { | ||
| 67 | - return 'OnlineModelConfig(transducer: $transducer, paraformer: $paraformer, zipformer2Ctc: $zipformer2Ctc, tokens: $tokens, numThreads: $numThreads, provider: $provider, debug: $debug, modelType: $modelType, modelingUnit: $modelingUnit, bpeVocab: $bpeVocab)'; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - final OnlineTransducerModelConfig transducer; | ||
| 71 | - final OnlineParaformerModelConfig paraformer; | ||
| 72 | - final OnlineZipformer2CtcModelConfig zipformer2Ctc; | ||
| 73 | - | ||
| 74 | - final String tokens; | ||
| 75 | - | ||
| 76 | - final int numThreads; | ||
| 77 | - | ||
| 78 | - final String provider; | ||
| 79 | - | ||
| 80 | - final bool debug; | ||
| 81 | - | ||
| 82 | - final String modelType; | ||
| 83 | - | ||
| 84 | - final String modelingUnit; | ||
| 85 | - | ||
| 86 | - final String bpeVocab; | ||
| 87 | -} | ||
| 88 | - | ||
| 89 | -class OnlineCtcFstDecoderConfig { | ||
| 90 | - const OnlineCtcFstDecoderConfig({this.graph = '', this.maxActive = 3000}); | ||
| 91 | - | ||
| 92 | - @override | ||
| 93 | - String toString() { | ||
| 94 | - return 'OnlineCtcFstDecoderConfig(graph: $graph, maxActive: $maxActive)'; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - final String graph; | ||
| 98 | - final int maxActive; | ||
| 99 | -} | ||
| 100 | - | ||
| 101 | -class OnlineRecognizerConfig { | ||
| 102 | - const OnlineRecognizerConfig({ | ||
| 103 | - this.feat = const FeatureConfig(), | ||
| 104 | - required this.model, | ||
| 105 | - this.decodingMethod = 'greedy_search', | ||
| 106 | - this.maxActivePaths = 4, | ||
| 107 | - this.enableEndpoint = true, | ||
| 108 | - this.rule1MinTrailingSilence = 2.4, | ||
| 109 | - this.rule2MinTrailingSilence = 1.2, | ||
| 110 | - this.rule3MinUtteranceLength = 20, | ||
| 111 | - this.hotwordsFile = '', | ||
| 112 | - this.hotwordsScore = 1.5, | ||
| 113 | - this.ctcFstDecoderConfig = const OnlineCtcFstDecoderConfig(), | ||
| 114 | - this.ruleFsts = '', | ||
| 115 | - this.ruleFars = '', | ||
| 116 | - }); | ||
| 117 | - | ||
| 118 | - @override | ||
| 119 | - String toString() { | ||
| 120 | - return 'OnlineRecognizerConfig(feat: $feat, model: $model, decodingMethod: $decodingMethod, maxActivePaths: $maxActivePaths, enableEndpoint: $enableEndpoint, rule1MinTrailingSilence: $rule1MinTrailingSilence, rule2MinTrailingSilence: $rule2MinTrailingSilence, rule3MinUtteranceLength: $rule3MinUtteranceLength, hotwordsFile: $hotwordsFile, hotwordsScore: $hotwordsScore, ctcFstDecoderConfig: $ctcFstDecoderConfig, ruleFsts: $ruleFsts, ruleFars: $ruleFars)'; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - final FeatureConfig feat; | ||
| 124 | - final OnlineModelConfig model; | ||
| 125 | - final String decodingMethod; | ||
| 126 | - | ||
| 127 | - final int maxActivePaths; | ||
| 128 | - | ||
| 129 | - final bool enableEndpoint; | ||
| 130 | - | ||
| 131 | - final double rule1MinTrailingSilence; | ||
| 132 | - | ||
| 133 | - final double rule2MinTrailingSilence; | ||
| 134 | - | ||
| 135 | - final double rule3MinUtteranceLength; | ||
| 136 | - | ||
| 137 | - final String hotwordsFile; | ||
| 138 | - | ||
| 139 | - final double hotwordsScore; | ||
| 140 | - | ||
| 141 | - final OnlineCtcFstDecoderConfig ctcFstDecoderConfig; | ||
| 142 | - final String ruleFsts; | ||
| 143 | - final String ruleFars; | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | -class OnlineRecognizerResult { | ||
| 147 | - OnlineRecognizerResult( | ||
| 148 | - {required this.text, required this.tokens, required this.timestamps}); | ||
| 149 | - | ||
| 150 | - @override | ||
| 151 | - String toString() { | ||
| 152 | - return 'OnlineRecognizerResult(text: $text, tokens: $tokens, timestamps: $timestamps)'; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - final String text; | ||
| 156 | - final List<String> tokens; | ||
| 157 | - final List<double> timestamps; | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -class OnlineRecognizer { | ||
| 161 | - OnlineRecognizer._({required this.ptr, required this.config}); | ||
| 162 | - | ||
| 163 | - /// The user is responsible to call the OnlineRecognizer.free() | ||
| 164 | - /// method of the returned instance to avoid memory leak. | ||
| 165 | - factory OnlineRecognizer(OnlineRecognizerConfig config) { | ||
| 166 | - final c = calloc<SherpaOnnxOnlineRecognizerConfig>(); | ||
| 167 | - c.ref.feat.sampleRate = config.feat.sampleRate; | ||
| 168 | - c.ref.feat.featureDim = config.feat.featureDim; | ||
| 169 | - | ||
| 170 | - // transducer | ||
| 171 | - c.ref.model.transducer.encoder = | ||
| 172 | - config.model.transducer.encoder.toNativeUtf8(); | ||
| 173 | - c.ref.model.transducer.decoder = | ||
| 174 | - config.model.transducer.decoder.toNativeUtf8(); | ||
| 175 | - c.ref.model.transducer.joiner = | ||
| 176 | - config.model.transducer.joiner.toNativeUtf8(); | ||
| 177 | - | ||
| 178 | - // paraformer | ||
| 179 | - c.ref.model.paraformer.encoder = | ||
| 180 | - config.model.paraformer.encoder.toNativeUtf8(); | ||
| 181 | - c.ref.model.paraformer.decoder = | ||
| 182 | - config.model.paraformer.decoder.toNativeUtf8(); | ||
| 183 | - | ||
| 184 | - // zipformer2Ctc | ||
| 185 | - c.ref.model.zipformer2Ctc.model = | ||
| 186 | - config.model.zipformer2Ctc.model.toNativeUtf8(); | ||
| 187 | - | ||
| 188 | - c.ref.model.tokens = config.model.tokens.toNativeUtf8(); | ||
| 189 | - c.ref.model.numThreads = config.model.numThreads; | ||
| 190 | - c.ref.model.provider = config.model.provider.toNativeUtf8(); | ||
| 191 | - c.ref.model.debug = config.model.debug ? 1 : 0; | ||
| 192 | - c.ref.model.modelType = config.model.modelType.toNativeUtf8(); | ||
| 193 | - c.ref.model.modelingUnit = config.model.modelingUnit.toNativeUtf8(); | ||
| 194 | - c.ref.model.bpeVocab = config.model.bpeVocab.toNativeUtf8(); | ||
| 195 | - | ||
| 196 | - c.ref.decodingMethod = config.decodingMethod.toNativeUtf8(); | ||
| 197 | - c.ref.maxActivePaths = config.maxActivePaths; | ||
| 198 | - c.ref.enableEndpoint = config.enableEndpoint ? 1 : 0; | ||
| 199 | - c.ref.rule1MinTrailingSilence = config.rule1MinTrailingSilence; | ||
| 200 | - c.ref.rule2MinTrailingSilence = config.rule2MinTrailingSilence; | ||
| 201 | - c.ref.rule3MinUtteranceLength = config.rule3MinUtteranceLength; | ||
| 202 | - c.ref.hotwordsFile = config.hotwordsFile.toNativeUtf8(); | ||
| 203 | - c.ref.hotwordsScore = config.hotwordsScore; | ||
| 204 | - | ||
| 205 | - c.ref.ctcFstDecoderConfig.graph = | ||
| 206 | - config.ctcFstDecoderConfig.graph.toNativeUtf8(); | ||
| 207 | - c.ref.ctcFstDecoderConfig.maxActive = config.ctcFstDecoderConfig.maxActive; | ||
| 208 | - c.ref.ruleFsts = config.ruleFsts.toNativeUtf8(); | ||
| 209 | - c.ref.ruleFars = config.ruleFars.toNativeUtf8(); | ||
| 210 | - | ||
| 211 | - final ptr = SherpaOnnxBindings.createOnlineRecognizer?.call(c) ?? nullptr; | ||
| 212 | - | ||
| 213 | - calloc.free(c.ref.ruleFars); | ||
| 214 | - calloc.free(c.ref.ruleFsts); | ||
| 215 | - calloc.free(c.ref.ctcFstDecoderConfig.graph); | ||
| 216 | - calloc.free(c.ref.hotwordsFile); | ||
| 217 | - calloc.free(c.ref.decodingMethod); | ||
| 218 | - calloc.free(c.ref.model.bpeVocab); | ||
| 219 | - calloc.free(c.ref.model.modelingUnit); | ||
| 220 | - calloc.free(c.ref.model.modelType); | ||
| 221 | - calloc.free(c.ref.model.provider); | ||
| 222 | - calloc.free(c.ref.model.tokens); | ||
| 223 | - calloc.free(c.ref.model.zipformer2Ctc.model); | ||
| 224 | - calloc.free(c.ref.model.paraformer.encoder); | ||
| 225 | - calloc.free(c.ref.model.paraformer.decoder); | ||
| 226 | - | ||
| 227 | - calloc.free(c.ref.model.transducer.encoder); | ||
| 228 | - calloc.free(c.ref.model.transducer.decoder); | ||
| 229 | - calloc.free(c.ref.model.transducer.joiner); | ||
| 230 | - calloc.free(c); | ||
| 231 | - | ||
| 232 | - return OnlineRecognizer._(ptr: ptr, config: config); | ||
| 233 | - } | ||
| 234 | - | ||
| 235 | - void free() { | ||
| 236 | - SherpaOnnxBindings.destroyOnlineRecognizer?.call(ptr); | ||
| 237 | - ptr = nullptr; | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | - /// The user has to invoke stream.free() on the returned instance | ||
| 241 | - /// to avoid memory leak | ||
| 242 | - OnlineStream createStream({String hotwords = ''}) { | ||
| 243 | - if (hotwords == '') { | ||
| 244 | - final p = SherpaOnnxBindings.createOnlineStream?.call(ptr) ?? nullptr; | ||
| 245 | - return OnlineStream(ptr: p); | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - final utf8 = hotwords.toNativeUtf8(); | ||
| 249 | - final p = | ||
| 250 | - SherpaOnnxBindings.createOnlineStreamWithHotwords?.call(ptr, utf8) ?? | ||
| 251 | - nullptr; | ||
| 252 | - calloc.free(utf8); | ||
| 253 | - return OnlineStream(ptr: p); | ||
| 254 | - } | ||
| 255 | - | ||
| 256 | - bool isReady(OnlineStream stream) { | ||
| 257 | - int ready = | ||
| 258 | - SherpaOnnxBindings.isOnlineStreamReady?.call(ptr, stream.ptr) ?? 0; | ||
| 259 | - | ||
| 260 | - return ready == 1; | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | - OnlineRecognizerResult getResult(OnlineStream stream) { | ||
| 264 | - final json = | ||
| 265 | - SherpaOnnxBindings.getOnlineStreamResultAsJson?.call(ptr, stream.ptr) ?? | ||
| 266 | - nullptr; | ||
| 267 | - if (json == nullptr) { | ||
| 268 | - return OnlineRecognizerResult(text: '', tokens: [], timestamps: []); | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - final parsedJson = jsonDecode(json.toDartString()); | ||
| 272 | - | ||
| 273 | - SherpaOnnxBindings.destroyOnlineStreamResultJson?.call(json); | ||
| 274 | - | ||
| 275 | - return OnlineRecognizerResult( | ||
| 276 | - text: parsedJson['text'], | ||
| 277 | - tokens: List<String>.from(parsedJson['tokens']), | ||
| 278 | - timestamps: List<double>.from(parsedJson['timestamps'])); | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - void reset(OnlineStream stream) { | ||
| 282 | - SherpaOnnxBindings.reset?.call(ptr, stream.ptr); | ||
| 283 | - } | ||
| 284 | - | ||
| 285 | - void decode(OnlineStream stream) { | ||
| 286 | - SherpaOnnxBindings.decodeOnlineStream?.call(ptr, stream.ptr); | ||
| 287 | - } | ||
| 288 | - | ||
| 289 | - bool isEndpoint(OnlineStream stream) { | ||
| 290 | - int yes = SherpaOnnxBindings.isEndpoint?.call(ptr, stream.ptr) ?? 0; | ||
| 291 | - | ||
| 292 | - return yes == 1; | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - Pointer<SherpaOnnxOnlineRecognizer> ptr; | ||
| 296 | - OnlineRecognizerConfig config; | ||
| 297 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './sherpa_onnx_bindings.dart'; | ||
| 7 | - | ||
| 8 | -class OnlineStream { | ||
| 9 | - /// The user has to call OnlineStream.free() to avoid memory leak. | ||
| 10 | - OnlineStream({required this.ptr}); | ||
| 11 | - | ||
| 12 | - void free() { | ||
| 13 | - SherpaOnnxBindings.destroyOnlineStream?.call(ptr); | ||
| 14 | - ptr = nullptr; | ||
| 15 | - } | ||
| 16 | - | ||
| 17 | - /// If you have List<double> data, then you can use | ||
| 18 | - /// Float32List.fromList(data) to convert data to Float32List | ||
| 19 | - /// | ||
| 20 | - /// See | ||
| 21 | - /// https://api.flutter.dev/flutter/dart-core/List-class.html | ||
| 22 | - /// and | ||
| 23 | - /// https://api.flutter.dev/flutter/dart-typed_data/Float32List-class.html | ||
| 24 | - void acceptWaveform({required Float32List samples, required int sampleRate}) { | ||
| 25 | - final n = samples.length; | ||
| 26 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 27 | - | ||
| 28 | - final pList = p.asTypedList(n); | ||
| 29 | - pList.setAll(0, samples); | ||
| 30 | - | ||
| 31 | - SherpaOnnxBindings.onlineStreamAcceptWaveform?.call(ptr, sampleRate, p, n); | ||
| 32 | - | ||
| 33 | - calloc.free(p); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - void inputFinished() { | ||
| 37 | - SherpaOnnxBindings.onlineStreamInputFinished?.call(ptr); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - Pointer<SherpaOnnxOnlineStream> ptr; | ||
| 41 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'package:ffi/ffi.dart'; | ||
| 4 | - | ||
| 5 | -final class SherpaOnnxOfflineTtsVitsModelConfig extends Struct { | ||
| 6 | - external Pointer<Utf8> model; | ||
| 7 | - external Pointer<Utf8> lexicon; | ||
| 8 | - external Pointer<Utf8> tokens; | ||
| 9 | - external Pointer<Utf8> dataDir; | ||
| 10 | - | ||
| 11 | - @Float() | ||
| 12 | - external double noiseScale; | ||
| 13 | - | ||
| 14 | - @Float() | ||
| 15 | - external double noiseScaleW; | ||
| 16 | - | ||
| 17 | - @Float() | ||
| 18 | - external double lengthScale; | ||
| 19 | - | ||
| 20 | - external Pointer<Utf8> dictDir; | ||
| 21 | -} | ||
| 22 | - | ||
| 23 | -final class SherpaOnnxOfflineTtsModelConfig extends Struct { | ||
| 24 | - external SherpaOnnxOfflineTtsVitsModelConfig vits; | ||
| 25 | - @Int32() | ||
| 26 | - external int numThreads; | ||
| 27 | - | ||
| 28 | - @Int32() | ||
| 29 | - external int debug; | ||
| 30 | - | ||
| 31 | - external Pointer<Utf8> provider; | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -final class SherpaOnnxOfflineTtsConfig extends Struct { | ||
| 35 | - external SherpaOnnxOfflineTtsModelConfig model; | ||
| 36 | - external Pointer<Utf8> ruleFsts; | ||
| 37 | - | ||
| 38 | - @Int32() | ||
| 39 | - external int maxNumSenetences; | ||
| 40 | - | ||
| 41 | - external Pointer<Utf8> ruleFars; | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -final class SherpaOnnxGeneratedAudio extends Struct { | ||
| 45 | - external Pointer<Float> samples; | ||
| 46 | - | ||
| 47 | - @Int32() | ||
| 48 | - external int n; | ||
| 49 | - | ||
| 50 | - @Int32() | ||
| 51 | - external int sampleRate; | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -final class SherpaOnnxFeatureConfig extends Struct { | ||
| 55 | - @Int32() | ||
| 56 | - external int sampleRate; | ||
| 57 | - | ||
| 58 | - @Int32() | ||
| 59 | - external int featureDim; | ||
| 60 | -} | ||
| 61 | - | ||
| 62 | -final class SherpaOnnxOfflineTransducerModelConfig extends Struct { | ||
| 63 | - external Pointer<Utf8> encoder; | ||
| 64 | - external Pointer<Utf8> decoder; | ||
| 65 | - external Pointer<Utf8> joiner; | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -final class SherpaOnnxOfflineParaformerModelConfig extends Struct { | ||
| 69 | - external Pointer<Utf8> model; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -final class SherpaOnnxOfflineNemoEncDecCtcModelConfig extends Struct { | ||
| 73 | - external Pointer<Utf8> model; | ||
| 74 | -} | ||
| 75 | - | ||
| 76 | -final class SherpaOnnxOfflineWhisperModelConfig extends Struct { | ||
| 77 | - external Pointer<Utf8> encoder; | ||
| 78 | - external Pointer<Utf8> decoder; | ||
| 79 | - external Pointer<Utf8> language; | ||
| 80 | - external Pointer<Utf8> task; | ||
| 81 | - | ||
| 82 | - @Int32() | ||
| 83 | - external int tailPaddings; | ||
| 84 | -} | ||
| 85 | - | ||
| 86 | -final class SherpaOnnxOfflineTdnnModelConfig extends Struct { | ||
| 87 | - external Pointer<Utf8> model; | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -final class SherpaOnnxOfflineLMConfig extends Struct { | ||
| 91 | - external Pointer<Utf8> model; | ||
| 92 | - | ||
| 93 | - @Float() | ||
| 94 | - external double scale; | ||
| 95 | -} | ||
| 96 | - | ||
| 97 | -final class SherpaOnnxOfflineModelConfig extends Struct { | ||
| 98 | - external SherpaOnnxOfflineTransducerModelConfig transducer; | ||
| 99 | - external SherpaOnnxOfflineParaformerModelConfig paraformer; | ||
| 100 | - external SherpaOnnxOfflineNemoEncDecCtcModelConfig nemoCtc; | ||
| 101 | - external SherpaOnnxOfflineWhisperModelConfig whisper; | ||
| 102 | - external SherpaOnnxOfflineTdnnModelConfig tdnn; | ||
| 103 | - | ||
| 104 | - external Pointer<Utf8> tokens; | ||
| 105 | - | ||
| 106 | - @Int32() | ||
| 107 | - external int numThreads; | ||
| 108 | - | ||
| 109 | - @Int32() | ||
| 110 | - external int debug; | ||
| 111 | - | ||
| 112 | - external Pointer<Utf8> provider; | ||
| 113 | - | ||
| 114 | - external Pointer<Utf8> modelType; | ||
| 115 | - external Pointer<Utf8> modelingUnit; | ||
| 116 | - external Pointer<Utf8> bpeVocab; | ||
| 117 | - external Pointer<Utf8> telespeechCtc; | ||
| 118 | -} | ||
| 119 | - | ||
| 120 | -final class SherpaOnnxOfflineRecognizerConfig extends Struct { | ||
| 121 | - external SherpaOnnxFeatureConfig feat; | ||
| 122 | - external SherpaOnnxOfflineModelConfig model; | ||
| 123 | - external SherpaOnnxOfflineLMConfig lm; | ||
| 124 | - external Pointer<Utf8> decodingMethod; | ||
| 125 | - | ||
| 126 | - @Int32() | ||
| 127 | - external int maxActivePaths; | ||
| 128 | - | ||
| 129 | - external Pointer<Utf8> hotwordsFile; | ||
| 130 | - | ||
| 131 | - @Float() | ||
| 132 | - external double hotwordsScore; | ||
| 133 | - | ||
| 134 | - external Pointer<Utf8> ruleFsts; | ||
| 135 | - external Pointer<Utf8> ruleFars; | ||
| 136 | -} | ||
| 137 | - | ||
| 138 | -final class SherpaOnnxOnlineTransducerModelConfig extends Struct { | ||
| 139 | - external Pointer<Utf8> encoder; | ||
| 140 | - external Pointer<Utf8> decoder; | ||
| 141 | - external Pointer<Utf8> joiner; | ||
| 142 | -} | ||
| 143 | - | ||
| 144 | -final class SherpaOnnxOnlineParaformerModelConfig extends Struct { | ||
| 145 | - external Pointer<Utf8> encoder; | ||
| 146 | - external Pointer<Utf8> decoder; | ||
| 147 | -} | ||
| 148 | - | ||
| 149 | -final class SherpaOnnxOnlineZipformer2CtcModelConfig extends Struct { | ||
| 150 | - external Pointer<Utf8> model; | ||
| 151 | -} | ||
| 152 | - | ||
| 153 | -final class SherpaOnnxOnlineModelConfig extends Struct { | ||
| 154 | - external SherpaOnnxOnlineTransducerModelConfig transducer; | ||
| 155 | - external SherpaOnnxOnlineParaformerModelConfig paraformer; | ||
| 156 | - external SherpaOnnxOnlineZipformer2CtcModelConfig zipformer2Ctc; | ||
| 157 | - | ||
| 158 | - external Pointer<Utf8> tokens; | ||
| 159 | - | ||
| 160 | - @Int32() | ||
| 161 | - external int numThreads; | ||
| 162 | - | ||
| 163 | - external Pointer<Utf8> provider; | ||
| 164 | - | ||
| 165 | - @Int32() | ||
| 166 | - external int debug; | ||
| 167 | - | ||
| 168 | - external Pointer<Utf8> modelType; | ||
| 169 | - | ||
| 170 | - external Pointer<Utf8> modelingUnit; | ||
| 171 | - | ||
| 172 | - external Pointer<Utf8> bpeVocab; | ||
| 173 | -} | ||
| 174 | - | ||
| 175 | -final class SherpaOnnxOnlineCtcFstDecoderConfig extends Struct { | ||
| 176 | - external Pointer<Utf8> graph; | ||
| 177 | - | ||
| 178 | - @Int32() | ||
| 179 | - external int maxActive; | ||
| 180 | -} | ||
| 181 | - | ||
| 182 | -final class SherpaOnnxOnlineRecognizerConfig extends Struct { | ||
| 183 | - external SherpaOnnxFeatureConfig feat; | ||
| 184 | - external SherpaOnnxOnlineModelConfig model; | ||
| 185 | - external Pointer<Utf8> decodingMethod; | ||
| 186 | - | ||
| 187 | - @Int32() | ||
| 188 | - external int maxActivePaths; | ||
| 189 | - | ||
| 190 | - @Int32() | ||
| 191 | - external int enableEndpoint; | ||
| 192 | - | ||
| 193 | - @Float() | ||
| 194 | - external double rule1MinTrailingSilence; | ||
| 195 | - | ||
| 196 | - @Float() | ||
| 197 | - external double rule2MinTrailingSilence; | ||
| 198 | - | ||
| 199 | - @Float() | ||
| 200 | - external double rule3MinUtteranceLength; | ||
| 201 | - | ||
| 202 | - external Pointer<Utf8> hotwordsFile; | ||
| 203 | - | ||
| 204 | - @Float() | ||
| 205 | - external double hotwordsScore; | ||
| 206 | - | ||
| 207 | - external SherpaOnnxOnlineCtcFstDecoderConfig ctcFstDecoderConfig; | ||
| 208 | - | ||
| 209 | - external Pointer<Utf8> ruleFsts; | ||
| 210 | - external Pointer<Utf8> ruleFars; | ||
| 211 | -} | ||
| 212 | - | ||
| 213 | -final class SherpaOnnxSileroVadModelConfig extends Struct { | ||
| 214 | - external Pointer<Utf8> model; | ||
| 215 | - | ||
| 216 | - @Float() | ||
| 217 | - external double threshold; | ||
| 218 | - | ||
| 219 | - @Float() | ||
| 220 | - external double minSilenceDuration; | ||
| 221 | - | ||
| 222 | - @Float() | ||
| 223 | - external double minSpeechDuration; | ||
| 224 | - | ||
| 225 | - @Int32() | ||
| 226 | - external int windowSize; | ||
| 227 | -} | ||
| 228 | - | ||
| 229 | -final class SherpaOnnxVadModelConfig extends Struct { | ||
| 230 | - external SherpaOnnxSileroVadModelConfig sileroVad; | ||
| 231 | - | ||
| 232 | - @Int32() | ||
| 233 | - external int sampleRate; | ||
| 234 | - | ||
| 235 | - @Int32() | ||
| 236 | - external int numThreads; | ||
| 237 | - | ||
| 238 | - external Pointer<Utf8> provider; | ||
| 239 | - | ||
| 240 | - @Int32() | ||
| 241 | - external int debug; | ||
| 242 | -} | ||
| 243 | - | ||
| 244 | -final class SherpaOnnxSpeechSegment extends Struct { | ||
| 245 | - @Int32() | ||
| 246 | - external int start; | ||
| 247 | - | ||
| 248 | - external Pointer<Float> samples; | ||
| 249 | - | ||
| 250 | - @Int32() | ||
| 251 | - external int n; | ||
| 252 | -} | ||
| 253 | - | ||
| 254 | -final class SherpaOnnxWave extends Struct { | ||
| 255 | - external Pointer<Float> samples; | ||
| 256 | - | ||
| 257 | - @Int32() | ||
| 258 | - external int sampleRate; | ||
| 259 | - | ||
| 260 | - @Int32() | ||
| 261 | - external int numSamples; | ||
| 262 | -} | ||
| 263 | - | ||
| 264 | -final class SherpaOnnxSpeakerEmbeddingExtractorConfig extends Struct { | ||
| 265 | - external Pointer<Utf8> model; | ||
| 266 | - | ||
| 267 | - @Int32() | ||
| 268 | - external int numThreads; | ||
| 269 | - | ||
| 270 | - @Int32() | ||
| 271 | - external int debug; | ||
| 272 | - | ||
| 273 | - external Pointer<Utf8> provider; | ||
| 274 | -} | ||
| 275 | - | ||
| 276 | -final class SherpaOnnxOfflineTts extends Opaque {} | ||
| 277 | - | ||
| 278 | -final class SherpaOnnxCircularBuffer extends Opaque {} | ||
| 279 | - | ||
| 280 | -final class SherpaOnnxVoiceActivityDetector extends Opaque {} | ||
| 281 | - | ||
| 282 | -final class SherpaOnnxOnlineStream extends Opaque {} | ||
| 283 | - | ||
| 284 | -final class SherpaOnnxOnlineRecognizer extends Opaque {} | ||
| 285 | - | ||
| 286 | -final class SherpaOnnxOfflineRecognizer extends Opaque {} | ||
| 287 | - | ||
| 288 | -final class SherpaOnnxOfflineStream extends Opaque {} | ||
| 289 | - | ||
| 290 | -final class SherpaOnnxSpeakerEmbeddingExtractor extends Opaque {} | ||
| 291 | - | ||
| 292 | -final class SherpaOnnxSpeakerEmbeddingManager extends Opaque {} | ||
| 293 | - | ||
| 294 | -typedef SherpaOnnxCreateOfflineTtsNative = Pointer<SherpaOnnxOfflineTts> | ||
| 295 | - Function(Pointer<SherpaOnnxOfflineTtsConfig>); | ||
| 296 | - | ||
| 297 | -typedef SherpaOnnxCreateOfflineTts = SherpaOnnxCreateOfflineTtsNative; | ||
| 298 | - | ||
| 299 | -typedef SherpaOnnxDestroyOfflineTtsNative = Void Function( | ||
| 300 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 301 | - | ||
| 302 | -typedef SherpaOnnxDestroyOfflineTts = void Function( | ||
| 303 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 304 | - | ||
| 305 | -typedef SherpaOnnxOfflineTtsSampleRateNative = Int32 Function( | ||
| 306 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 307 | - | ||
| 308 | -typedef SherpaOnnxOfflineTtsSampleRate = int Function( | ||
| 309 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 310 | - | ||
| 311 | -typedef SherpaOnnxOfflineTtsNumSpeakersNative = Int32 Function( | ||
| 312 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 313 | - | ||
| 314 | -typedef SherpaOnnxOfflineTtsNumSpeakers = int Function( | ||
| 315 | - Pointer<SherpaOnnxOfflineTts>); | ||
| 316 | - | ||
| 317 | -typedef SherpaOnnxOfflineTtsGenerateNative = Pointer<SherpaOnnxGeneratedAudio> | ||
| 318 | - Function(Pointer<SherpaOnnxOfflineTts>, Pointer<Utf8>, Int32, Float); | ||
| 319 | - | ||
| 320 | -typedef SherpaOnnxOfflineTtsGenerate = Pointer<SherpaOnnxGeneratedAudio> | ||
| 321 | - Function(Pointer<SherpaOnnxOfflineTts>, Pointer<Utf8>, int, double); | ||
| 322 | - | ||
| 323 | -typedef SherpaOnnxDestroyOfflineTtsGeneratedAudioNative = Void Function( | ||
| 324 | - Pointer<SherpaOnnxGeneratedAudio>); | ||
| 325 | - | ||
| 326 | -typedef SherpaOnnxDestroyOfflineTtsGeneratedAudio = void Function( | ||
| 327 | - Pointer<SherpaOnnxGeneratedAudio>); | ||
| 328 | - | ||
| 329 | -typedef SherpaOnnxGeneratedAudioCallbackNative = Int Function( | ||
| 330 | - Pointer<Float>, Int32); | ||
| 331 | - | ||
| 332 | -typedef SherpaOnnxOfflineTtsGenerateWithCallbackNative | ||
| 333 | - = Pointer<SherpaOnnxGeneratedAudio> Function( | ||
| 334 | - Pointer<SherpaOnnxOfflineTts>, | ||
| 335 | - Pointer<Utf8>, | ||
| 336 | - Int32, | ||
| 337 | - Float, | ||
| 338 | - Pointer<NativeFunction<SherpaOnnxGeneratedAudioCallbackNative>>); | ||
| 339 | - | ||
| 340 | -typedef SherpaOnnxOfflineTtsGenerateWithCallback | ||
| 341 | - = Pointer<SherpaOnnxGeneratedAudio> Function( | ||
| 342 | - Pointer<SherpaOnnxOfflineTts>, | ||
| 343 | - Pointer<Utf8>, | ||
| 344 | - int, | ||
| 345 | - double, | ||
| 346 | - Pointer<NativeFunction<SherpaOnnxGeneratedAudioCallbackNative>>); | ||
| 347 | - | ||
| 348 | -typedef CreateOfflineRecognizerNative = Pointer<SherpaOnnxOfflineRecognizer> | ||
| 349 | - Function(Pointer<SherpaOnnxOfflineRecognizerConfig>); | ||
| 350 | - | ||
| 351 | -typedef CreateOfflineRecognizer = CreateOfflineRecognizerNative; | ||
| 352 | - | ||
| 353 | -typedef DestroyOfflineRecognizerNative = Void Function( | ||
| 354 | - Pointer<SherpaOnnxOfflineRecognizer>); | ||
| 355 | - | ||
| 356 | -typedef DestroyOfflineRecognizer = void Function( | ||
| 357 | - Pointer<SherpaOnnxOfflineRecognizer>); | ||
| 358 | - | ||
| 359 | -typedef CreateOfflineStreamNative = Pointer<SherpaOnnxOfflineStream> Function( | ||
| 360 | - Pointer<SherpaOnnxOfflineRecognizer>); | ||
| 361 | - | ||
| 362 | -typedef CreateOfflineStream = CreateOfflineStreamNative; | ||
| 363 | - | ||
| 364 | -typedef DestroyOfflineStreamNative = Void Function( | ||
| 365 | - Pointer<SherpaOnnxOfflineStream>); | ||
| 366 | - | ||
| 367 | -typedef DestroyOfflineStream = void Function(Pointer<SherpaOnnxOfflineStream>); | ||
| 368 | - | ||
| 369 | -typedef AcceptWaveformOfflineNative = Void Function( | ||
| 370 | - Pointer<SherpaOnnxOfflineStream>, Int32, Pointer<Float>, Int32); | ||
| 371 | - | ||
| 372 | -typedef AcceptWaveformOffline = void Function( | ||
| 373 | - Pointer<SherpaOnnxOfflineStream>, int, Pointer<Float>, int); | ||
| 374 | - | ||
| 375 | -typedef DecodeOfflineStreamNative = Void Function( | ||
| 376 | - Pointer<SherpaOnnxOfflineRecognizer>, Pointer<SherpaOnnxOfflineStream>); | ||
| 377 | - | ||
| 378 | -typedef DecodeOfflineStream = void Function( | ||
| 379 | - Pointer<SherpaOnnxOfflineRecognizer>, Pointer<SherpaOnnxOfflineStream>); | ||
| 380 | - | ||
| 381 | -typedef GetOfflineStreamResultAsJsonNative = Pointer<Utf8> Function( | ||
| 382 | - Pointer<SherpaOnnxOfflineStream>); | ||
| 383 | - | ||
| 384 | -typedef GetOfflineStreamResultAsJson = GetOfflineStreamResultAsJsonNative; | ||
| 385 | - | ||
| 386 | -typedef DestroyOfflineStreamResultJsonNative = Void Function(Pointer<Utf8>); | ||
| 387 | - | ||
| 388 | -typedef DestroyOfflineStreamResultJson = void Function(Pointer<Utf8>); | ||
| 389 | - | ||
| 390 | -typedef CreateOnlineRecognizerNative = Pointer<SherpaOnnxOnlineRecognizer> | ||
| 391 | - Function(Pointer<SherpaOnnxOnlineRecognizerConfig>); | ||
| 392 | - | ||
| 393 | -typedef CreateOnlineRecognizer = CreateOnlineRecognizerNative; | ||
| 394 | - | ||
| 395 | -typedef DestroyOnlineRecognizerNative = Void Function( | ||
| 396 | - Pointer<SherpaOnnxOnlineRecognizer>); | ||
| 397 | - | ||
| 398 | -typedef DestroyOnlineRecognizer = void Function( | ||
| 399 | - Pointer<SherpaOnnxOnlineRecognizer>); | ||
| 400 | - | ||
| 401 | -typedef CreateOnlineStreamNative = Pointer<SherpaOnnxOnlineStream> Function( | ||
| 402 | - Pointer<SherpaOnnxOnlineRecognizer>); | ||
| 403 | - | ||
| 404 | -typedef CreateOnlineStream = CreateOnlineStreamNative; | ||
| 405 | - | ||
| 406 | -typedef CreateOnlineStreamWithHotwordsNative = Pointer<SherpaOnnxOnlineStream> | ||
| 407 | - Function(Pointer<SherpaOnnxOnlineRecognizer>, Pointer<Utf8>); | ||
| 408 | - | ||
| 409 | -typedef CreateOnlineStreamWithHotwords = CreateOnlineStreamWithHotwordsNative; | ||
| 410 | - | ||
| 411 | -typedef IsOnlineStreamReadyNative = Int32 Function( | ||
| 412 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 413 | - | ||
| 414 | -typedef IsOnlineStreamReady = int Function( | ||
| 415 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 416 | - | ||
| 417 | -typedef DecodeOnlineStreamNative = Void Function( | ||
| 418 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 419 | - | ||
| 420 | -typedef DecodeOnlineStream = void Function( | ||
| 421 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 422 | - | ||
| 423 | -typedef GetOnlineStreamResultAsJsonNative = Pointer<Utf8> Function( | ||
| 424 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 425 | - | ||
| 426 | -typedef GetOnlineStreamResultAsJson = GetOnlineStreamResultAsJsonNative; | ||
| 427 | - | ||
| 428 | -typedef ResetNative = Void Function( | ||
| 429 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 430 | - | ||
| 431 | -typedef Reset = void Function( | ||
| 432 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 433 | - | ||
| 434 | -typedef IsEndpointNative = Int32 Function( | ||
| 435 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 436 | - | ||
| 437 | -typedef IsEndpoint = int Function( | ||
| 438 | - Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); | ||
| 439 | - | ||
| 440 | -typedef DestroyOnlineStreamResultJsonNative = Void Function(Pointer<Utf8>); | ||
| 441 | - | ||
| 442 | -typedef DestroyOnlineStreamResultJson = void Function(Pointer<Utf8>); | ||
| 443 | - | ||
| 444 | -typedef SherpaOnnxCreateVoiceActivityDetectorNative | ||
| 445 | - = Pointer<SherpaOnnxVoiceActivityDetector> Function( | ||
| 446 | - Pointer<SherpaOnnxVadModelConfig>, Float); | ||
| 447 | - | ||
| 448 | -typedef SherpaOnnxCreateVoiceActivityDetector | ||
| 449 | - = Pointer<SherpaOnnxVoiceActivityDetector> Function( | ||
| 450 | - Pointer<SherpaOnnxVadModelConfig>, double); | ||
| 451 | - | ||
| 452 | -typedef SherpaOnnxDestroyVoiceActivityDetectorNative = Void Function( | ||
| 453 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 454 | - | ||
| 455 | -typedef SherpaOnnxDestroyVoiceActivityDetector = void Function( | ||
| 456 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 457 | - | ||
| 458 | -typedef SherpaOnnxVoiceActivityDetectorAcceptWaveformNative = Void Function( | ||
| 459 | - Pointer<SherpaOnnxVoiceActivityDetector>, Pointer<Float>, Int32); | ||
| 460 | - | ||
| 461 | -typedef SherpaOnnxVoiceActivityDetectorAcceptWaveform = void Function( | ||
| 462 | - Pointer<SherpaOnnxVoiceActivityDetector>, Pointer<Float>, int); | ||
| 463 | - | ||
| 464 | -typedef SherpaOnnxVoiceActivityDetectorEmptyNative = Int32 Function( | ||
| 465 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 466 | - | ||
| 467 | -typedef SherpaOnnxVoiceActivityDetectorEmpty = int Function( | ||
| 468 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 469 | - | ||
| 470 | -typedef SherpaOnnxVoiceActivityDetectorDetectedNative = Int32 Function( | ||
| 471 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 472 | - | ||
| 473 | -typedef SherpaOnnxVoiceActivityDetectorDetected = int Function( | ||
| 474 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 475 | - | ||
| 476 | -typedef SherpaOnnxVoiceActivityDetectorPopNative = Void Function( | ||
| 477 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 478 | - | ||
| 479 | -typedef SherpaOnnxVoiceActivityDetectorPop = void Function( | ||
| 480 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 481 | - | ||
| 482 | -typedef SherpaOnnxVoiceActivityDetectorClearNative = Void Function( | ||
| 483 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 484 | - | ||
| 485 | -typedef SherpaOnnxVoiceActivityDetectorClear = void Function( | ||
| 486 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 487 | - | ||
| 488 | -typedef SherpaOnnxVoiceActivityDetectorResetNative = Void Function( | ||
| 489 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 490 | - | ||
| 491 | -typedef SherpaOnnxVoiceActivityDetectorReset = void Function( | ||
| 492 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 493 | - | ||
| 494 | -typedef SherpaOnnxVoiceActivityDetectorFrontNative | ||
| 495 | - = Pointer<SherpaOnnxSpeechSegment> Function( | ||
| 496 | - Pointer<SherpaOnnxVoiceActivityDetector>); | ||
| 497 | - | ||
| 498 | -typedef SherpaOnnxVoiceActivityDetectorFront | ||
| 499 | - = SherpaOnnxVoiceActivityDetectorFrontNative; | ||
| 500 | - | ||
| 501 | -typedef SherpaOnnxDestroySpeechSegmentNative = Void Function( | ||
| 502 | - Pointer<SherpaOnnxSpeechSegment>); | ||
| 503 | - | ||
| 504 | -typedef SherpaOnnxDestroySpeechSegment = void Function( | ||
| 505 | - Pointer<SherpaOnnxSpeechSegment>); | ||
| 506 | - | ||
| 507 | -typedef SherpaOnnxCreateCircularBufferNative = Pointer<SherpaOnnxCircularBuffer> | ||
| 508 | - Function(Int32); | ||
| 509 | - | ||
| 510 | -typedef SherpaOnnxCreateCircularBuffer = Pointer<SherpaOnnxCircularBuffer> | ||
| 511 | - Function(int); | ||
| 512 | - | ||
| 513 | -typedef SherpaOnnxDestroyCircularBufferNative = Void Function( | ||
| 514 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 515 | - | ||
| 516 | -typedef SherpaOnnxDestroyCircularBuffer = void Function( | ||
| 517 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 518 | - | ||
| 519 | -typedef SherpaOnnxCircularBufferPushNative = Void Function( | ||
| 520 | - Pointer<SherpaOnnxCircularBuffer>, Pointer<Float>, Int32); | ||
| 521 | - | ||
| 522 | -typedef SherpaOnnxCircularBufferPush = void Function( | ||
| 523 | - Pointer<SherpaOnnxCircularBuffer>, Pointer<Float>, int); | ||
| 524 | - | ||
| 525 | -typedef SherpaOnnxCircularBufferGetNative = Pointer<Float> Function( | ||
| 526 | - Pointer<SherpaOnnxCircularBuffer>, Int32, Int32); | ||
| 527 | - | ||
| 528 | -typedef SherpaOnnxCircularBufferGet = Pointer<Float> Function( | ||
| 529 | - Pointer<SherpaOnnxCircularBuffer>, int, int); | ||
| 530 | - | ||
| 531 | -typedef SherpaOnnxCircularBufferFreeNative = Void Function(Pointer<Float>); | ||
| 532 | - | ||
| 533 | -typedef SherpaOnnxCircularBufferFree = void Function(Pointer<Float>); | ||
| 534 | - | ||
| 535 | -typedef SherpaOnnxCircularBufferPopNative = Void Function( | ||
| 536 | - Pointer<SherpaOnnxCircularBuffer>, Int32); | ||
| 537 | - | ||
| 538 | -typedef SherpaOnnxCircularBufferPop = void Function( | ||
| 539 | - Pointer<SherpaOnnxCircularBuffer>, int); | ||
| 540 | - | ||
| 541 | -typedef SherpaOnnxCircularBufferSizeNative = Int32 Function( | ||
| 542 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 543 | - | ||
| 544 | -typedef SherpaOnnxCircularBufferSize = int Function( | ||
| 545 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 546 | - | ||
| 547 | -typedef SherpaOnnxCircularBufferHeadNative = Int32 Function( | ||
| 548 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 549 | - | ||
| 550 | -typedef SherpaOnnxCircularBufferHead = int Function( | ||
| 551 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 552 | - | ||
| 553 | -typedef SherpaOnnxCircularBufferResetNative = Void Function( | ||
| 554 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 555 | - | ||
| 556 | -typedef SherpaOnnxCircularBufferReset = void Function( | ||
| 557 | - Pointer<SherpaOnnxCircularBuffer>); | ||
| 558 | - | ||
| 559 | -typedef SherpaOnnxCreateSpeakerEmbeddingManagerNative | ||
| 560 | - = Pointer<SherpaOnnxSpeakerEmbeddingManager> Function(Int32); | ||
| 561 | - | ||
| 562 | -typedef SherpaOnnxCreateSpeakerEmbeddingManager | ||
| 563 | - = Pointer<SherpaOnnxSpeakerEmbeddingManager> Function(int); | ||
| 564 | - | ||
| 565 | -typedef SherpaOnnxDestroySpeakerEmbeddingManagerNative = Void Function( | ||
| 566 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>); | ||
| 567 | - | ||
| 568 | -typedef SherpaOnnxDestroySpeakerEmbeddingManager = void Function( | ||
| 569 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>); | ||
| 570 | - | ||
| 571 | -typedef SherpaOnnxSpeakerEmbeddingManagerAddNative = Int32 Function( | ||
| 572 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>, Pointer<Float>); | ||
| 573 | - | ||
| 574 | -typedef SherpaOnnxSpeakerEmbeddingManagerAdd = int Function( | ||
| 575 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>, Pointer<Float>); | ||
| 576 | - | ||
| 577 | -typedef SherpaOnnxSpeakerEmbeddingManagerAddListFlattenedNative | ||
| 578 | - = Int32 Function(Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>, | ||
| 579 | - Pointer<Float>, Int32); | ||
| 580 | - | ||
| 581 | -typedef SherpaOnnxSpeakerEmbeddingManagerAddListFlattened = int Function( | ||
| 582 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, | ||
| 583 | - Pointer<Utf8>, | ||
| 584 | - Pointer<Float>, | ||
| 585 | - int); | ||
| 586 | - | ||
| 587 | -typedef SherpaOnnxSpeakerEmbeddingManagerRemoveNative = Int32 Function( | ||
| 588 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>); | ||
| 589 | - | ||
| 590 | -typedef SherpaOnnxSpeakerEmbeddingManagerRemove = int Function( | ||
| 591 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>); | ||
| 592 | - | ||
| 593 | -typedef SherpaOnnxSpeakerEmbeddingManagerContainsNative = Int32 Function( | ||
| 594 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>); | ||
| 595 | - | ||
| 596 | -typedef SherpaOnnxSpeakerEmbeddingManagerContains = int Function( | ||
| 597 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Utf8>); | ||
| 598 | - | ||
| 599 | -typedef SherpaOnnxSpeakerEmbeddingManagerSearchNative = Pointer<Utf8> Function( | ||
| 600 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Float>, Float); | ||
| 601 | - | ||
| 602 | -typedef SherpaOnnxSpeakerEmbeddingManagerSearch = Pointer<Utf8> Function( | ||
| 603 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, Pointer<Float>, double); | ||
| 604 | - | ||
| 605 | -typedef SherpaOnnxSpeakerEmbeddingManagerFreeSearchNative = Void Function( | ||
| 606 | - Pointer<Utf8>); | ||
| 607 | - | ||
| 608 | -typedef SherpaOnnxSpeakerEmbeddingManagerFreeSearch = void Function( | ||
| 609 | - Pointer<Utf8>); | ||
| 610 | - | ||
| 611 | -typedef SherpaOnnxSpeakerEmbeddingManagerNumSpeakersNative = Int32 Function( | ||
| 612 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>); | ||
| 613 | - | ||
| 614 | -typedef SherpaOnnxSpeakerEmbeddingManagerNumSpeakers = int Function( | ||
| 615 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>); | ||
| 616 | - | ||
| 617 | -typedef SherpaOnnxSpeakerEmbeddingManagerVerifyNative = Int32 Function( | ||
| 618 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, | ||
| 619 | - Pointer<Utf8>, | ||
| 620 | - Pointer<Float>, | ||
| 621 | - Float); | ||
| 622 | - | ||
| 623 | -typedef SherpaOnnxSpeakerEmbeddingManagerVerify = int Function( | ||
| 624 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>, | ||
| 625 | - Pointer<Utf8>, | ||
| 626 | - Pointer<Float>, | ||
| 627 | - double); | ||
| 628 | - | ||
| 629 | -typedef SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakersNative | ||
| 630 | - = Pointer<Pointer<Utf8>> Function( | ||
| 631 | - Pointer<SherpaOnnxSpeakerEmbeddingManager>); | ||
| 632 | - | ||
| 633 | -typedef SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers | ||
| 634 | - = SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakersNative; | ||
| 635 | - | ||
| 636 | -typedef SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakersNative = Void Function( | ||
| 637 | - Pointer<Pointer<Utf8>>); | ||
| 638 | - | ||
| 639 | -typedef SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers = void Function( | ||
| 640 | - Pointer<Pointer<Utf8>>); | ||
| 641 | - | ||
| 642 | -typedef SherpaOnnxCreateSpeakerEmbeddingExtractorNative | ||
| 643 | - = Pointer<SherpaOnnxSpeakerEmbeddingExtractor> Function( | ||
| 644 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractorConfig>); | ||
| 645 | - | ||
| 646 | -typedef SherpaOnnxCreateSpeakerEmbeddingExtractor | ||
| 647 | - = SherpaOnnxCreateSpeakerEmbeddingExtractorNative; | ||
| 648 | - | ||
| 649 | -typedef SherpaOnnxDestroySpeakerEmbeddingExtractorNative = Void Function( | ||
| 650 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>); | ||
| 651 | - | ||
| 652 | -typedef SherpaOnnxDestroySpeakerEmbeddingExtractor = void Function( | ||
| 653 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>); | ||
| 654 | - | ||
| 655 | -typedef SherpaOnnxSpeakerEmbeddingExtractorDimNative = Int32 Function( | ||
| 656 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>); | ||
| 657 | - | ||
| 658 | -typedef SherpaOnnxSpeakerEmbeddingExtractorDim = int Function( | ||
| 659 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>); | ||
| 660 | - | ||
| 661 | -typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative | ||
| 662 | - = Pointer<SherpaOnnxOnlineStream> Function( | ||
| 663 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>); | ||
| 664 | - | ||
| 665 | -typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStream | ||
| 666 | - = SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative; | ||
| 667 | - | ||
| 668 | -typedef DestroyOnlineStreamNative = Void Function( | ||
| 669 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 670 | - | ||
| 671 | -typedef DestroyOnlineStream = void Function(Pointer<SherpaOnnxOnlineStream>); | ||
| 672 | - | ||
| 673 | -typedef OnlineStreamAcceptWaveformNative = Void Function( | ||
| 674 | - Pointer<SherpaOnnxOnlineStream>, Int32, Pointer<Float>, Int32); | ||
| 675 | - | ||
| 676 | -typedef OnlineStreamAcceptWaveform = void Function( | ||
| 677 | - Pointer<SherpaOnnxOnlineStream>, int, Pointer<Float>, int); | ||
| 678 | - | ||
| 679 | -typedef OnlineStreamInputFinishedNative = Void Function( | ||
| 680 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 681 | - | ||
| 682 | -typedef OnlineStreamInputFinished = void Function( | ||
| 683 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 684 | - | ||
| 685 | -typedef SherpaOnnxSpeakerEmbeddingExtractorIsReadyNative = Int32 Function( | ||
| 686 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>, | ||
| 687 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 688 | - | ||
| 689 | -typedef SherpaOnnxSpeakerEmbeddingExtractorIsReady = int Function( | ||
| 690 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor>, | ||
| 691 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 692 | - | ||
| 693 | -typedef SherpaOnnxSpeakerEmbeddingExtractorComputeEmbeddingNative | ||
| 694 | - = Pointer<Float> Function(Pointer<SherpaOnnxSpeakerEmbeddingExtractor>, | ||
| 695 | - Pointer<SherpaOnnxOnlineStream>); | ||
| 696 | - | ||
| 697 | -typedef SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding | ||
| 698 | - = SherpaOnnxSpeakerEmbeddingExtractorComputeEmbeddingNative; | ||
| 699 | - | ||
| 700 | -typedef SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbeddingNative = Void | ||
| 701 | - Function(Pointer<Float>); | ||
| 702 | - | ||
| 703 | -typedef SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding = void Function( | ||
| 704 | - Pointer<Float>); | ||
| 705 | - | ||
| 706 | -typedef SherpaOnnxReadWaveNative = Pointer<SherpaOnnxWave> Function( | ||
| 707 | - Pointer<Utf8>); | ||
| 708 | - | ||
| 709 | -typedef SherpaOnnxReadWave = SherpaOnnxReadWaveNative; | ||
| 710 | - | ||
| 711 | -typedef SherpaOnnxWriteWaveNative = Int32 Function( | ||
| 712 | - Pointer<Float>, Int32, Int32, Pointer<Utf8>); | ||
| 713 | - | ||
| 714 | -typedef SherpaOnnxWriteWave = int Function( | ||
| 715 | - Pointer<Float>, int, int, Pointer<Utf8>); | ||
| 716 | - | ||
| 717 | -typedef SherpaOnnxFreeWaveNative = Void Function(Pointer<SherpaOnnxWave>); | ||
| 718 | - | ||
| 719 | -typedef SherpaOnnxFreeWave = void Function(Pointer<SherpaOnnxWave>); | ||
| 720 | - | ||
| 721 | -class SherpaOnnxBindings { | ||
| 722 | - static SherpaOnnxCreateOfflineTts? createOfflineTts; | ||
| 723 | - static SherpaOnnxDestroyOfflineTts? destroyOfflineTts; | ||
| 724 | - static SherpaOnnxOfflineTtsSampleRate? offlineTtsSampleRate; | ||
| 725 | - static SherpaOnnxOfflineTtsNumSpeakers? offlineTtsNumSpeakers; | ||
| 726 | - static SherpaOnnxOfflineTtsGenerate? offlineTtsGenerate; | ||
| 727 | - static SherpaOnnxDestroyOfflineTtsGeneratedAudio? | ||
| 728 | - destroyOfflineTtsGeneratedAudio; | ||
| 729 | - static SherpaOnnxOfflineTtsGenerateWithCallback? | ||
| 730 | - offlineTtsGenerateWithCallback; | ||
| 731 | - | ||
| 732 | - static CreateOfflineRecognizer? createOfflineRecognizer; | ||
| 733 | - static DestroyOfflineRecognizer? destroyOfflineRecognizer; | ||
| 734 | - static CreateOfflineStream? createOfflineStream; | ||
| 735 | - static DestroyOfflineStream? destroyOfflineStream; | ||
| 736 | - static AcceptWaveformOffline? acceptWaveformOffline; | ||
| 737 | - static DecodeOfflineStream? decodeOfflineStream; | ||
| 738 | - static GetOfflineStreamResultAsJson? getOfflineStreamResultAsJson; | ||
| 739 | - static DestroyOfflineStreamResultJson? destroyOfflineStreamResultJson; | ||
| 740 | - | ||
| 741 | - static CreateOnlineRecognizer? createOnlineRecognizer; | ||
| 742 | - | ||
| 743 | - static DestroyOnlineRecognizer? destroyOnlineRecognizer; | ||
| 744 | - | ||
| 745 | - static CreateOnlineStream? createOnlineStream; | ||
| 746 | - | ||
| 747 | - static CreateOnlineStreamWithHotwords? createOnlineStreamWithHotwords; | ||
| 748 | - | ||
| 749 | - static IsOnlineStreamReady? isOnlineStreamReady; | ||
| 750 | - | ||
| 751 | - static DecodeOnlineStream? decodeOnlineStream; | ||
| 752 | - | ||
| 753 | - static GetOnlineStreamResultAsJson? getOnlineStreamResultAsJson; | ||
| 754 | - | ||
| 755 | - static Reset? reset; | ||
| 756 | - | ||
| 757 | - static IsEndpoint? isEndpoint; | ||
| 758 | - | ||
| 759 | - static DestroyOnlineStreamResultJson? destroyOnlineStreamResultJson; | ||
| 760 | - | ||
| 761 | - static SherpaOnnxCreateVoiceActivityDetector? createVoiceActivityDetector; | ||
| 762 | - | ||
| 763 | - static SherpaOnnxDestroyVoiceActivityDetector? destroyVoiceActivityDetector; | ||
| 764 | - | ||
| 765 | - static SherpaOnnxVoiceActivityDetectorAcceptWaveform? | ||
| 766 | - voiceActivityDetectorAcceptWaveform; | ||
| 767 | - | ||
| 768 | - static SherpaOnnxVoiceActivityDetectorEmpty? voiceActivityDetectorEmpty; | ||
| 769 | - | ||
| 770 | - static SherpaOnnxVoiceActivityDetectorDetected? voiceActivityDetectorDetected; | ||
| 771 | - | ||
| 772 | - static SherpaOnnxVoiceActivityDetectorPop? voiceActivityDetectorPop; | ||
| 773 | - | ||
| 774 | - static SherpaOnnxVoiceActivityDetectorClear? voiceActivityDetectorClear; | ||
| 775 | - | ||
| 776 | - static SherpaOnnxVoiceActivityDetectorFront? voiceActivityDetectorFront; | ||
| 777 | - | ||
| 778 | - static SherpaOnnxDestroySpeechSegment? destroySpeechSegment; | ||
| 779 | - | ||
| 780 | - static SherpaOnnxVoiceActivityDetectorReset? voiceActivityDetectorReset; | ||
| 781 | - | ||
| 782 | - static SherpaOnnxCreateCircularBuffer? createCircularBuffer; | ||
| 783 | - | ||
| 784 | - static SherpaOnnxDestroyCircularBuffer? destroyCircularBuffer; | ||
| 785 | - | ||
| 786 | - static SherpaOnnxCircularBufferPush? circularBufferPush; | ||
| 787 | - | ||
| 788 | - static SherpaOnnxCircularBufferGet? circularBufferGet; | ||
| 789 | - | ||
| 790 | - static SherpaOnnxCircularBufferFree? circularBufferFree; | ||
| 791 | - | ||
| 792 | - static SherpaOnnxCircularBufferPop? circularBufferPop; | ||
| 793 | - | ||
| 794 | - static SherpaOnnxCircularBufferSize? circularBufferSize; | ||
| 795 | - | ||
| 796 | - static SherpaOnnxCircularBufferHead? circularBufferHead; | ||
| 797 | - | ||
| 798 | - static SherpaOnnxCircularBufferReset? circularBufferReset; | ||
| 799 | - | ||
| 800 | - static SherpaOnnxCreateSpeakerEmbeddingExtractor? | ||
| 801 | - createSpeakerEmbeddingExtractor; | ||
| 802 | - | ||
| 803 | - static SherpaOnnxDestroySpeakerEmbeddingExtractor? | ||
| 804 | - destroySpeakerEmbeddingExtractor; | ||
| 805 | - | ||
| 806 | - static SherpaOnnxSpeakerEmbeddingExtractorDim? speakerEmbeddingExtractorDim; | ||
| 807 | - | ||
| 808 | - static SherpaOnnxSpeakerEmbeddingExtractorCreateStream? | ||
| 809 | - speakerEmbeddingExtractorCreateStream; | ||
| 810 | - | ||
| 811 | - static SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding? | ||
| 812 | - speakerEmbeddingExtractorComputeEmbedding; | ||
| 813 | - | ||
| 814 | - static SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding? | ||
| 815 | - speakerEmbeddingExtractorDestroyEmbedding; | ||
| 816 | - | ||
| 817 | - static DestroyOnlineStream? destroyOnlineStream; | ||
| 818 | - | ||
| 819 | - static OnlineStreamAcceptWaveform? onlineStreamAcceptWaveform; | ||
| 820 | - | ||
| 821 | - static OnlineStreamInputFinished? onlineStreamInputFinished; | ||
| 822 | - | ||
| 823 | - static SherpaOnnxSpeakerEmbeddingExtractorIsReady? | ||
| 824 | - speakerEmbeddingExtractorIsReady; | ||
| 825 | - | ||
| 826 | - static SherpaOnnxCreateSpeakerEmbeddingManager? createSpeakerEmbeddingManager; | ||
| 827 | - | ||
| 828 | - static SherpaOnnxDestroySpeakerEmbeddingManager? | ||
| 829 | - destroySpeakerEmbeddingManager; | ||
| 830 | - | ||
| 831 | - static SherpaOnnxSpeakerEmbeddingManagerAdd? speakerEmbeddingManagerAdd; | ||
| 832 | - | ||
| 833 | - static SherpaOnnxSpeakerEmbeddingManagerAddListFlattened? | ||
| 834 | - speakerEmbeddingManagerAddListFlattened; | ||
| 835 | - | ||
| 836 | - static SherpaOnnxSpeakerEmbeddingManagerRemove? speakerEmbeddingManagerRemove; | ||
| 837 | - | ||
| 838 | - static SherpaOnnxSpeakerEmbeddingManagerContains? | ||
| 839 | - speakerEmbeddingManagerContains; | ||
| 840 | - | ||
| 841 | - static SherpaOnnxSpeakerEmbeddingManagerSearch? speakerEmbeddingManagerSearch; | ||
| 842 | - | ||
| 843 | - static SherpaOnnxSpeakerEmbeddingManagerFreeSearch? | ||
| 844 | - speakerEmbeddingManagerFreeSearch; | ||
| 845 | - | ||
| 846 | - static SherpaOnnxSpeakerEmbeddingManagerNumSpeakers? | ||
| 847 | - speakerEmbeddingManagerNumSpeakers; | ||
| 848 | - | ||
| 849 | - static SherpaOnnxSpeakerEmbeddingManagerVerify? speakerEmbeddingManagerVerify; | ||
| 850 | - | ||
| 851 | - static SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers? | ||
| 852 | - speakerEmbeddingManagerGetAllSpeakers; | ||
| 853 | - | ||
| 854 | - static SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers? | ||
| 855 | - speakerEmbeddingManagerFreeAllSpeakers; | ||
| 856 | - | ||
| 857 | - static SherpaOnnxReadWave? readWave; | ||
| 858 | - | ||
| 859 | - static SherpaOnnxWriteWave? writeWave; | ||
| 860 | - | ||
| 861 | - static SherpaOnnxFreeWave? freeWave; | ||
| 862 | - | ||
| 863 | - static void init(DynamicLibrary dynamicLibrary) { | ||
| 864 | - createOfflineTts ??= dynamicLibrary | ||
| 865 | - .lookup<NativeFunction<SherpaOnnxCreateOfflineTtsNative>>( | ||
| 866 | - 'SherpaOnnxCreateOfflineTts') | ||
| 867 | - .asFunction(); | ||
| 868 | - | ||
| 869 | - destroyOfflineTts ??= dynamicLibrary | ||
| 870 | - .lookup<NativeFunction<SherpaOnnxDestroyOfflineTtsNative>>( | ||
| 871 | - 'SherpaOnnxDestroyOfflineTts') | ||
| 872 | - .asFunction(); | ||
| 873 | - | ||
| 874 | - offlineTtsSampleRate ??= dynamicLibrary | ||
| 875 | - .lookup<NativeFunction<SherpaOnnxOfflineTtsSampleRateNative>>( | ||
| 876 | - 'SherpaOnnxOfflineTtsSampleRate') | ||
| 877 | - .asFunction(); | ||
| 878 | - | ||
| 879 | - offlineTtsNumSpeakers ??= dynamicLibrary | ||
| 880 | - .lookup<NativeFunction<SherpaOnnxOfflineTtsNumSpeakersNative>>( | ||
| 881 | - 'SherpaOnnxOfflineTtsNumSpeakers') | ||
| 882 | - .asFunction(); | ||
| 883 | - | ||
| 884 | - offlineTtsGenerate ??= dynamicLibrary | ||
| 885 | - .lookup<NativeFunction<SherpaOnnxOfflineTtsGenerateNative>>( | ||
| 886 | - 'SherpaOnnxOfflineTtsGenerate') | ||
| 887 | - .asFunction(); | ||
| 888 | - | ||
| 889 | - destroyOfflineTtsGeneratedAudio ??= dynamicLibrary | ||
| 890 | - .lookup< | ||
| 891 | - NativeFunction< | ||
| 892 | - SherpaOnnxDestroyOfflineTtsGeneratedAudioNative>>( | ||
| 893 | - 'SherpaOnnxDestroyOfflineTtsGeneratedAudio') | ||
| 894 | - .asFunction(); | ||
| 895 | - | ||
| 896 | - offlineTtsGenerateWithCallback ??= dynamicLibrary | ||
| 897 | - .lookup<NativeFunction<SherpaOnnxOfflineTtsGenerateWithCallbackNative>>( | ||
| 898 | - 'SherpaOnnxOfflineTtsGenerateWithCallback') | ||
| 899 | - .asFunction(); | ||
| 900 | - | ||
| 901 | - createOfflineRecognizer ??= dynamicLibrary | ||
| 902 | - .lookup<NativeFunction<CreateOfflineRecognizerNative>>( | ||
| 903 | - 'CreateOfflineRecognizer') | ||
| 904 | - .asFunction(); | ||
| 905 | - | ||
| 906 | - destroyOfflineRecognizer ??= dynamicLibrary | ||
| 907 | - .lookup<NativeFunction<DestroyOfflineRecognizerNative>>( | ||
| 908 | - 'DestroyOfflineRecognizer') | ||
| 909 | - .asFunction(); | ||
| 910 | - | ||
| 911 | - createOfflineStream ??= dynamicLibrary | ||
| 912 | - .lookup<NativeFunction<CreateOfflineStreamNative>>( | ||
| 913 | - 'CreateOfflineStream') | ||
| 914 | - .asFunction(); | ||
| 915 | - | ||
| 916 | - destroyOfflineStream ??= dynamicLibrary | ||
| 917 | - .lookup<NativeFunction<DestroyOfflineStreamNative>>( | ||
| 918 | - 'DestroyOfflineStream') | ||
| 919 | - .asFunction(); | ||
| 920 | - | ||
| 921 | - acceptWaveformOffline ??= dynamicLibrary | ||
| 922 | - .lookup<NativeFunction<AcceptWaveformOfflineNative>>( | ||
| 923 | - 'AcceptWaveformOffline') | ||
| 924 | - .asFunction(); | ||
| 925 | - | ||
| 926 | - decodeOfflineStream ??= dynamicLibrary | ||
| 927 | - .lookup<NativeFunction<DecodeOfflineStreamNative>>( | ||
| 928 | - 'DecodeOfflineStream') | ||
| 929 | - .asFunction(); | ||
| 930 | - | ||
| 931 | - getOfflineStreamResultAsJson ??= dynamicLibrary | ||
| 932 | - .lookup<NativeFunction<GetOfflineStreamResultAsJsonNative>>( | ||
| 933 | - 'GetOfflineStreamResultAsJson') | ||
| 934 | - .asFunction(); | ||
| 935 | - | ||
| 936 | - destroyOfflineStreamResultJson ??= dynamicLibrary | ||
| 937 | - .lookup<NativeFunction<DestroyOfflineStreamResultJsonNative>>( | ||
| 938 | - 'DestroyOfflineStreamResultJson') | ||
| 939 | - .asFunction(); | ||
| 940 | - | ||
| 941 | - createOnlineRecognizer ??= dynamicLibrary | ||
| 942 | - .lookup<NativeFunction<CreateOnlineRecognizerNative>>( | ||
| 943 | - 'CreateOnlineRecognizer') | ||
| 944 | - .asFunction(); | ||
| 945 | - | ||
| 946 | - destroyOnlineRecognizer ??= dynamicLibrary | ||
| 947 | - .lookup<NativeFunction<DestroyOnlineRecognizerNative>>( | ||
| 948 | - 'DestroyOnlineRecognizer') | ||
| 949 | - .asFunction(); | ||
| 950 | - | ||
| 951 | - createOnlineStream ??= dynamicLibrary | ||
| 952 | - .lookup<NativeFunction<CreateOnlineStreamNative>>('CreateOnlineStream') | ||
| 953 | - .asFunction(); | ||
| 954 | - | ||
| 955 | - createOnlineStreamWithHotwords ??= dynamicLibrary | ||
| 956 | - .lookup<NativeFunction<CreateOnlineStreamWithHotwordsNative>>( | ||
| 957 | - 'CreateOnlineStreamWithHotwords') | ||
| 958 | - .asFunction(); | ||
| 959 | - | ||
| 960 | - isOnlineStreamReady ??= dynamicLibrary | ||
| 961 | - .lookup<NativeFunction<IsOnlineStreamReadyNative>>( | ||
| 962 | - 'IsOnlineStreamReady') | ||
| 963 | - .asFunction(); | ||
| 964 | - | ||
| 965 | - decodeOnlineStream ??= dynamicLibrary | ||
| 966 | - .lookup<NativeFunction<DecodeOnlineStreamNative>>('DecodeOnlineStream') | ||
| 967 | - .asFunction(); | ||
| 968 | - | ||
| 969 | - getOnlineStreamResultAsJson ??= dynamicLibrary | ||
| 970 | - .lookup<NativeFunction<GetOnlineStreamResultAsJsonNative>>( | ||
| 971 | - 'GetOnlineStreamResultAsJson') | ||
| 972 | - .asFunction(); | ||
| 973 | - | ||
| 974 | - reset ??= dynamicLibrary | ||
| 975 | - .lookup<NativeFunction<ResetNative>>('Reset') | ||
| 976 | - .asFunction(); | ||
| 977 | - | ||
| 978 | - isEndpoint ??= dynamicLibrary | ||
| 979 | - .lookup<NativeFunction<IsEndpointNative>>('IsEndpoint') | ||
| 980 | - .asFunction(); | ||
| 981 | - | ||
| 982 | - destroyOnlineStreamResultJson ??= dynamicLibrary | ||
| 983 | - .lookup<NativeFunction<DestroyOnlineStreamResultJsonNative>>( | ||
| 984 | - 'DestroyOnlineStreamResultJson') | ||
| 985 | - .asFunction(); | ||
| 986 | - | ||
| 987 | - createVoiceActivityDetector ??= dynamicLibrary | ||
| 988 | - .lookup<NativeFunction<SherpaOnnxCreateVoiceActivityDetectorNative>>( | ||
| 989 | - 'SherpaOnnxCreateVoiceActivityDetector') | ||
| 990 | - .asFunction(); | ||
| 991 | - | ||
| 992 | - destroyVoiceActivityDetector ??= dynamicLibrary | ||
| 993 | - .lookup<NativeFunction<SherpaOnnxDestroyVoiceActivityDetectorNative>>( | ||
| 994 | - 'SherpaOnnxDestroyVoiceActivityDetector') | ||
| 995 | - .asFunction(); | ||
| 996 | - | ||
| 997 | - voiceActivityDetectorAcceptWaveform ??= dynamicLibrary | ||
| 998 | - .lookup< | ||
| 999 | - NativeFunction< | ||
| 1000 | - SherpaOnnxVoiceActivityDetectorAcceptWaveformNative>>( | ||
| 1001 | - 'SherpaOnnxVoiceActivityDetectorAcceptWaveform') | ||
| 1002 | - .asFunction(); | ||
| 1003 | - | ||
| 1004 | - voiceActivityDetectorEmpty ??= dynamicLibrary | ||
| 1005 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorEmptyNative>>( | ||
| 1006 | - 'SherpaOnnxVoiceActivityDetectorEmpty') | ||
| 1007 | - .asFunction(); | ||
| 1008 | - | ||
| 1009 | - voiceActivityDetectorDetected ??= dynamicLibrary | ||
| 1010 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorDetectedNative>>( | ||
| 1011 | - 'SherpaOnnxVoiceActivityDetectorDetected') | ||
| 1012 | - .asFunction(); | ||
| 1013 | - | ||
| 1014 | - voiceActivityDetectorPop ??= dynamicLibrary | ||
| 1015 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorPopNative>>( | ||
| 1016 | - 'SherpaOnnxVoiceActivityDetectorPop') | ||
| 1017 | - .asFunction(); | ||
| 1018 | - | ||
| 1019 | - voiceActivityDetectorClear ??= dynamicLibrary | ||
| 1020 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorClearNative>>( | ||
| 1021 | - 'SherpaOnnxVoiceActivityDetectorClear') | ||
| 1022 | - .asFunction(); | ||
| 1023 | - | ||
| 1024 | - voiceActivityDetectorFront ??= dynamicLibrary | ||
| 1025 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorFrontNative>>( | ||
| 1026 | - 'SherpaOnnxVoiceActivityDetectorFront') | ||
| 1027 | - .asFunction(); | ||
| 1028 | - | ||
| 1029 | - destroySpeechSegment ??= dynamicLibrary | ||
| 1030 | - .lookup<NativeFunction<SherpaOnnxDestroySpeechSegmentNative>>( | ||
| 1031 | - 'SherpaOnnxDestroySpeechSegment') | ||
| 1032 | - .asFunction(); | ||
| 1033 | - | ||
| 1034 | - voiceActivityDetectorReset ??= dynamicLibrary | ||
| 1035 | - .lookup<NativeFunction<SherpaOnnxVoiceActivityDetectorResetNative>>( | ||
| 1036 | - 'SherpaOnnxVoiceActivityDetectorReset') | ||
| 1037 | - .asFunction(); | ||
| 1038 | - | ||
| 1039 | - createCircularBuffer ??= dynamicLibrary | ||
| 1040 | - .lookup<NativeFunction<SherpaOnnxCreateCircularBufferNative>>( | ||
| 1041 | - 'SherpaOnnxCreateCircularBuffer') | ||
| 1042 | - .asFunction(); | ||
| 1043 | - | ||
| 1044 | - destroyCircularBuffer ??= dynamicLibrary | ||
| 1045 | - .lookup<NativeFunction<SherpaOnnxDestroyCircularBufferNative>>( | ||
| 1046 | - 'SherpaOnnxDestroyCircularBuffer') | ||
| 1047 | - .asFunction(); | ||
| 1048 | - | ||
| 1049 | - circularBufferPush ??= dynamicLibrary | ||
| 1050 | - .lookup<NativeFunction<SherpaOnnxCircularBufferPushNative>>( | ||
| 1051 | - 'SherpaOnnxCircularBufferPush') | ||
| 1052 | - .asFunction(); | ||
| 1053 | - | ||
| 1054 | - circularBufferGet ??= dynamicLibrary | ||
| 1055 | - .lookup<NativeFunction<SherpaOnnxCircularBufferGetNative>>( | ||
| 1056 | - 'SherpaOnnxCircularBufferGet') | ||
| 1057 | - .asFunction(); | ||
| 1058 | - | ||
| 1059 | - circularBufferFree ??= dynamicLibrary | ||
| 1060 | - .lookup<NativeFunction<SherpaOnnxCircularBufferFreeNative>>( | ||
| 1061 | - 'SherpaOnnxCircularBufferFree') | ||
| 1062 | - .asFunction(); | ||
| 1063 | - | ||
| 1064 | - circularBufferPop ??= dynamicLibrary | ||
| 1065 | - .lookup<NativeFunction<SherpaOnnxCircularBufferPopNative>>( | ||
| 1066 | - 'SherpaOnnxCircularBufferPop') | ||
| 1067 | - .asFunction(); | ||
| 1068 | - | ||
| 1069 | - circularBufferSize ??= dynamicLibrary | ||
| 1070 | - .lookup<NativeFunction<SherpaOnnxCircularBufferSizeNative>>( | ||
| 1071 | - 'SherpaOnnxCircularBufferSize') | ||
| 1072 | - .asFunction(); | ||
| 1073 | - | ||
| 1074 | - circularBufferHead ??= dynamicLibrary | ||
| 1075 | - .lookup<NativeFunction<SherpaOnnxCircularBufferHeadNative>>( | ||
| 1076 | - 'SherpaOnnxCircularBufferHead') | ||
| 1077 | - .asFunction(); | ||
| 1078 | - | ||
| 1079 | - circularBufferReset ??= dynamicLibrary | ||
| 1080 | - .lookup<NativeFunction<SherpaOnnxCircularBufferResetNative>>( | ||
| 1081 | - 'SherpaOnnxCircularBufferReset') | ||
| 1082 | - .asFunction(); | ||
| 1083 | - | ||
| 1084 | - createSpeakerEmbeddingExtractor ??= dynamicLibrary | ||
| 1085 | - .lookup< | ||
| 1086 | - NativeFunction< | ||
| 1087 | - SherpaOnnxCreateSpeakerEmbeddingExtractorNative>>( | ||
| 1088 | - 'SherpaOnnxCreateSpeakerEmbeddingExtractor') | ||
| 1089 | - .asFunction(); | ||
| 1090 | - | ||
| 1091 | - destroySpeakerEmbeddingExtractor ??= dynamicLibrary | ||
| 1092 | - .lookup< | ||
| 1093 | - NativeFunction< | ||
| 1094 | - SherpaOnnxDestroySpeakerEmbeddingExtractorNative>>( | ||
| 1095 | - 'SherpaOnnxDestroySpeakerEmbeddingExtractor') | ||
| 1096 | - .asFunction(); | ||
| 1097 | - | ||
| 1098 | - speakerEmbeddingExtractorDim ??= dynamicLibrary | ||
| 1099 | - .lookup<NativeFunction<SherpaOnnxSpeakerEmbeddingExtractorDimNative>>( | ||
| 1100 | - 'SherpaOnnxSpeakerEmbeddingExtractorDim') | ||
| 1101 | - .asFunction(); | ||
| 1102 | - | ||
| 1103 | - speakerEmbeddingExtractorCreateStream ??= dynamicLibrary | ||
| 1104 | - .lookup< | ||
| 1105 | - NativeFunction< | ||
| 1106 | - SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative>>( | ||
| 1107 | - 'SherpaOnnxSpeakerEmbeddingExtractorCreateStream') | ||
| 1108 | - .asFunction(); | ||
| 1109 | - | ||
| 1110 | - speakerEmbeddingExtractorComputeEmbedding ??= dynamicLibrary | ||
| 1111 | - .lookup< | ||
| 1112 | - NativeFunction< | ||
| 1113 | - SherpaOnnxSpeakerEmbeddingExtractorComputeEmbeddingNative>>( | ||
| 1114 | - 'SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding') | ||
| 1115 | - .asFunction(); | ||
| 1116 | - | ||
| 1117 | - speakerEmbeddingExtractorDestroyEmbedding ??= dynamicLibrary | ||
| 1118 | - .lookup< | ||
| 1119 | - NativeFunction< | ||
| 1120 | - SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbeddingNative>>( | ||
| 1121 | - 'SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding') | ||
| 1122 | - .asFunction(); | ||
| 1123 | - | ||
| 1124 | - destroyOnlineStream ??= dynamicLibrary | ||
| 1125 | - .lookup<NativeFunction<DestroyOnlineStreamNative>>( | ||
| 1126 | - 'DestroyOnlineStream') | ||
| 1127 | - .asFunction(); | ||
| 1128 | - | ||
| 1129 | - onlineStreamAcceptWaveform ??= dynamicLibrary | ||
| 1130 | - .lookup<NativeFunction<OnlineStreamAcceptWaveformNative>>( | ||
| 1131 | - 'AcceptWaveform') | ||
| 1132 | - .asFunction(); | ||
| 1133 | - | ||
| 1134 | - onlineStreamInputFinished ??= dynamicLibrary | ||
| 1135 | - .lookup<NativeFunction<OnlineStreamInputFinishedNative>>( | ||
| 1136 | - 'InputFinished') | ||
| 1137 | - .asFunction(); | ||
| 1138 | - | ||
| 1139 | - speakerEmbeddingExtractorIsReady ??= dynamicLibrary | ||
| 1140 | - .lookup< | ||
| 1141 | - NativeFunction< | ||
| 1142 | - SherpaOnnxSpeakerEmbeddingExtractorIsReadyNative>>( | ||
| 1143 | - 'SherpaOnnxSpeakerEmbeddingExtractorIsReady') | ||
| 1144 | - .asFunction(); | ||
| 1145 | - | ||
| 1146 | - createSpeakerEmbeddingManager ??= dynamicLibrary | ||
| 1147 | - .lookup<NativeFunction<SherpaOnnxCreateSpeakerEmbeddingManagerNative>>( | ||
| 1148 | - 'SherpaOnnxCreateSpeakerEmbeddingManager') | ||
| 1149 | - .asFunction(); | ||
| 1150 | - | ||
| 1151 | - destroySpeakerEmbeddingManager ??= dynamicLibrary | ||
| 1152 | - .lookup<NativeFunction<SherpaOnnxDestroySpeakerEmbeddingManagerNative>>( | ||
| 1153 | - 'SherpaOnnxDestroySpeakerEmbeddingManager') | ||
| 1154 | - .asFunction(); | ||
| 1155 | - | ||
| 1156 | - speakerEmbeddingManagerAdd ??= dynamicLibrary | ||
| 1157 | - .lookup<NativeFunction<SherpaOnnxSpeakerEmbeddingManagerAddNative>>( | ||
| 1158 | - 'SherpaOnnxSpeakerEmbeddingManagerAdd') | ||
| 1159 | - .asFunction(); | ||
| 1160 | - | ||
| 1161 | - speakerEmbeddingManagerAddListFlattened ??= dynamicLibrary | ||
| 1162 | - .lookup< | ||
| 1163 | - NativeFunction< | ||
| 1164 | - SherpaOnnxSpeakerEmbeddingManagerAddListFlattenedNative>>( | ||
| 1165 | - 'SherpaOnnxSpeakerEmbeddingManagerAddListFlattened') | ||
| 1166 | - .asFunction(); | ||
| 1167 | - | ||
| 1168 | - speakerEmbeddingManagerRemove ??= dynamicLibrary | ||
| 1169 | - .lookup<NativeFunction<SherpaOnnxSpeakerEmbeddingManagerRemoveNative>>( | ||
| 1170 | - 'SherpaOnnxSpeakerEmbeddingManagerRemove') | ||
| 1171 | - .asFunction(); | ||
| 1172 | - | ||
| 1173 | - speakerEmbeddingManagerContains ??= dynamicLibrary | ||
| 1174 | - .lookup< | ||
| 1175 | - NativeFunction< | ||
| 1176 | - SherpaOnnxSpeakerEmbeddingManagerContainsNative>>( | ||
| 1177 | - 'SherpaOnnxSpeakerEmbeddingManagerContains') | ||
| 1178 | - .asFunction(); | ||
| 1179 | - | ||
| 1180 | - speakerEmbeddingManagerSearch ??= dynamicLibrary | ||
| 1181 | - .lookup<NativeFunction<SherpaOnnxSpeakerEmbeddingManagerSearchNative>>( | ||
| 1182 | - 'SherpaOnnxSpeakerEmbeddingManagerSearch') | ||
| 1183 | - .asFunction(); | ||
| 1184 | - | ||
| 1185 | - speakerEmbeddingManagerFreeSearch ??= dynamicLibrary | ||
| 1186 | - .lookup< | ||
| 1187 | - NativeFunction< | ||
| 1188 | - SherpaOnnxSpeakerEmbeddingManagerFreeSearchNative>>( | ||
| 1189 | - 'SherpaOnnxSpeakerEmbeddingManagerFreeSearch') | ||
| 1190 | - .asFunction(); | ||
| 1191 | - | ||
| 1192 | - speakerEmbeddingManagerNumSpeakers ??= dynamicLibrary | ||
| 1193 | - .lookup< | ||
| 1194 | - NativeFunction< | ||
| 1195 | - SherpaOnnxSpeakerEmbeddingManagerNumSpeakersNative>>( | ||
| 1196 | - 'SherpaOnnxSpeakerEmbeddingManagerNumSpeakers') | ||
| 1197 | - .asFunction(); | ||
| 1198 | - | ||
| 1199 | - speakerEmbeddingManagerVerify ??= dynamicLibrary | ||
| 1200 | - .lookup<NativeFunction<SherpaOnnxSpeakerEmbeddingManagerVerifyNative>>( | ||
| 1201 | - 'SherpaOnnxSpeakerEmbeddingManagerVerify') | ||
| 1202 | - .asFunction(); | ||
| 1203 | - | ||
| 1204 | - speakerEmbeddingManagerGetAllSpeakers ??= dynamicLibrary | ||
| 1205 | - .lookup< | ||
| 1206 | - NativeFunction< | ||
| 1207 | - SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakersNative>>( | ||
| 1208 | - 'SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers') | ||
| 1209 | - .asFunction(); | ||
| 1210 | - | ||
| 1211 | - speakerEmbeddingManagerFreeAllSpeakers ??= dynamicLibrary | ||
| 1212 | - .lookup< | ||
| 1213 | - NativeFunction< | ||
| 1214 | - SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakersNative>>( | ||
| 1215 | - 'SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers') | ||
| 1216 | - .asFunction(); | ||
| 1217 | - | ||
| 1218 | - readWave ??= dynamicLibrary | ||
| 1219 | - .lookup<NativeFunction<SherpaOnnxReadWaveNative>>('SherpaOnnxReadWave') | ||
| 1220 | - .asFunction(); | ||
| 1221 | - | ||
| 1222 | - writeWave ??= dynamicLibrary | ||
| 1223 | - .lookup<NativeFunction<SherpaOnnxWriteWaveNative>>( | ||
| 1224 | - 'SherpaOnnxWriteWave') | ||
| 1225 | - .asFunction(); | ||
| 1226 | - | ||
| 1227 | - freeWave ??= dynamicLibrary | ||
| 1228 | - .lookup<NativeFunction<SherpaOnnxFreeWaveNative>>('SherpaOnnxFreeWave') | ||
| 1229 | - .asFunction(); | ||
| 1230 | - } | ||
| 1231 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './online_stream.dart'; | ||
| 7 | -import './sherpa_onnx_bindings.dart'; | ||
| 8 | - | ||
| 9 | -class SpeakerEmbeddingExtractorConfig { | ||
| 10 | - const SpeakerEmbeddingExtractorConfig( | ||
| 11 | - {required this.model, | ||
| 12 | - this.numThreads = 1, | ||
| 13 | - this.debug = true, | ||
| 14 | - this.provider = 'cpu'}); | ||
| 15 | - | ||
| 16 | - @override | ||
| 17 | - String toString() { | ||
| 18 | - return 'SpeakerEmbeddingExtractorConfig(model: $model, numThreads: $numThreads, debug: $debug, provider: $provider)'; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - final String model; | ||
| 22 | - final int numThreads; | ||
| 23 | - final bool debug; | ||
| 24 | - final String provider; | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -class SpeakerEmbeddingExtractor { | ||
| 28 | - SpeakerEmbeddingExtractor._({required this.ptr, required this.dim}); | ||
| 29 | - | ||
| 30 | - /// The user is responsible to call the SpeakerEmbeddingExtractor.free() | ||
| 31 | - /// method of the returned instance to avoid memory leak. | ||
| 32 | - factory SpeakerEmbeddingExtractor( | ||
| 33 | - {required SpeakerEmbeddingExtractorConfig config}) { | ||
| 34 | - final c = calloc<SherpaOnnxSpeakerEmbeddingExtractorConfig>(); | ||
| 35 | - | ||
| 36 | - final modelPtr = config.model.toNativeUtf8(); | ||
| 37 | - c.ref.model = modelPtr; | ||
| 38 | - | ||
| 39 | - c.ref.numThreads = config.numThreads; | ||
| 40 | - c.ref.debug = config.debug ? 1 : 0; | ||
| 41 | - | ||
| 42 | - final providerPtr = config.provider.toNativeUtf8(); | ||
| 43 | - c.ref.provider = providerPtr; | ||
| 44 | - | ||
| 45 | - final ptr = | ||
| 46 | - SherpaOnnxBindings.createSpeakerEmbeddingExtractor?.call(c) ?? nullptr; | ||
| 47 | - | ||
| 48 | - calloc.free(providerPtr); | ||
| 49 | - calloc.free(modelPtr); | ||
| 50 | - calloc.free(c); | ||
| 51 | - | ||
| 52 | - final dim = SherpaOnnxBindings.speakerEmbeddingExtractorDim?.call(ptr) ?? 0; | ||
| 53 | - | ||
| 54 | - return SpeakerEmbeddingExtractor._(ptr: ptr, dim: dim); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - void free() { | ||
| 58 | - SherpaOnnxBindings.destroySpeakerEmbeddingExtractor?.call(ptr); | ||
| 59 | - ptr = nullptr; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - /// The user has to invoke stream.free() on the returned instance | ||
| 63 | - /// to avoid memory leak | ||
| 64 | - OnlineStream createStream() { | ||
| 65 | - final p = | ||
| 66 | - SherpaOnnxBindings.speakerEmbeddingExtractorCreateStream?.call(ptr) ?? | ||
| 67 | - nullptr; | ||
| 68 | - | ||
| 69 | - return OnlineStream(ptr: p); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - bool isReady(OnlineStream stream) { | ||
| 73 | - final int ready = SherpaOnnxBindings.speakerEmbeddingExtractorIsReady | ||
| 74 | - ?.call(ptr, stream.ptr) ?? | ||
| 75 | - 0; | ||
| 76 | - return ready == 1; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - Float32List compute(OnlineStream stream) { | ||
| 80 | - final Pointer<Float> embedding = SherpaOnnxBindings | ||
| 81 | - .speakerEmbeddingExtractorComputeEmbedding | ||
| 82 | - ?.call(ptr, stream.ptr) ?? | ||
| 83 | - nullptr; | ||
| 84 | - | ||
| 85 | - if (embedding == nullptr) { | ||
| 86 | - return Float32List(0); | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - final embeddingList = embedding.asTypedList(dim); | ||
| 90 | - final ans = Float32List(dim); | ||
| 91 | - ans.setAll(0, embeddingList); | ||
| 92 | - | ||
| 93 | - SherpaOnnxBindings.speakerEmbeddingExtractorDestroyEmbedding | ||
| 94 | - ?.call(embedding); | ||
| 95 | - | ||
| 96 | - return ans; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - Pointer<SherpaOnnxSpeakerEmbeddingExtractor> ptr; | ||
| 100 | - final int dim; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -class SpeakerEmbeddingManager { | ||
| 104 | - SpeakerEmbeddingManager._({required this.ptr, required this.dim}); | ||
| 105 | - | ||
| 106 | - // The user has to use SpeakerEmbeddingManager.free() to avoid memory leak | ||
| 107 | - factory SpeakerEmbeddingManager(int dim) { | ||
| 108 | - final p = | ||
| 109 | - SherpaOnnxBindings.createSpeakerEmbeddingManager?.call(dim) ?? nullptr; | ||
| 110 | - return SpeakerEmbeddingManager._(ptr: p, dim: dim); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - void free() { | ||
| 114 | - SherpaOnnxBindings.destroySpeakerEmbeddingManager?.call(ptr); | ||
| 115 | - ptr = nullptr; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - /// Return true if added successfully; return false otherwise | ||
| 119 | - bool add({required String name, required Float32List embedding}) { | ||
| 120 | - assert(embedding.length == dim, '${embedding.length} vs $dim'); | ||
| 121 | - | ||
| 122 | - final Pointer<Utf8> namePtr = name.toNativeUtf8(); | ||
| 123 | - final int n = embedding.length; | ||
| 124 | - | ||
| 125 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 126 | - final pList = p.asTypedList(n); | ||
| 127 | - pList.setAll(0, embedding); | ||
| 128 | - | ||
| 129 | - final int ok = | ||
| 130 | - SherpaOnnxBindings.speakerEmbeddingManagerAdd?.call(ptr, namePtr, p) ?? | ||
| 131 | - 0; | ||
| 132 | - | ||
| 133 | - calloc.free(p); | ||
| 134 | - calloc.free(namePtr); | ||
| 135 | - | ||
| 136 | - return ok == 1; | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - bool addMulti( | ||
| 140 | - {required String name, required List<Float32List> embeddingList}) { | ||
| 141 | - final Pointer<Utf8> namePtr = name.toNativeUtf8(); | ||
| 142 | - final int n = embeddingList.length; | ||
| 143 | - | ||
| 144 | - final Pointer<Float> p = calloc<Float>(n * dim); | ||
| 145 | - final pList = p.asTypedList(n * dim); | ||
| 146 | - | ||
| 147 | - int offset = 0; | ||
| 148 | - for (final e in embeddingList) { | ||
| 149 | - assert(e.length == dim, '${e.length} vs $dim'); | ||
| 150 | - | ||
| 151 | - pList.setAll(offset, e); | ||
| 152 | - offset += dim; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - final int ok = SherpaOnnxBindings.speakerEmbeddingManagerAddListFlattened | ||
| 156 | - ?.call(ptr, namePtr, p, n) ?? | ||
| 157 | - 0; | ||
| 158 | - | ||
| 159 | - calloc.free(p); | ||
| 160 | - calloc.free(namePtr); | ||
| 161 | - | ||
| 162 | - return ok == 1; | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - bool contains(String name) { | ||
| 166 | - final Pointer<Utf8> namePtr = name.toNativeUtf8(); | ||
| 167 | - | ||
| 168 | - final int found = SherpaOnnxBindings.speakerEmbeddingManagerContains | ||
| 169 | - ?.call(ptr, namePtr) ?? | ||
| 170 | - 0; | ||
| 171 | - | ||
| 172 | - calloc.free(namePtr); | ||
| 173 | - | ||
| 174 | - return found == 1; | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - bool remove(String name) { | ||
| 178 | - final Pointer<Utf8> namePtr = name.toNativeUtf8(); | ||
| 179 | - | ||
| 180 | - final int ok = | ||
| 181 | - SherpaOnnxBindings.speakerEmbeddingManagerRemove?.call(ptr, namePtr) ?? | ||
| 182 | - 0; | ||
| 183 | - | ||
| 184 | - calloc.free(namePtr); | ||
| 185 | - | ||
| 186 | - return ok == 1; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - /// Return an empty string if no speaker is found | ||
| 190 | - String search({required Float32List embedding, required double threshold}) { | ||
| 191 | - assert(embedding.length == dim); | ||
| 192 | - | ||
| 193 | - final Pointer<Float> p = calloc<Float>(dim); | ||
| 194 | - final pList = p.asTypedList(dim); | ||
| 195 | - pList.setAll(0, embedding); | ||
| 196 | - | ||
| 197 | - final Pointer<Utf8> name = SherpaOnnxBindings.speakerEmbeddingManagerSearch | ||
| 198 | - ?.call(ptr, p, threshold) ?? | ||
| 199 | - nullptr; | ||
| 200 | - | ||
| 201 | - calloc.free(p); | ||
| 202 | - | ||
| 203 | - if (name == nullptr) { | ||
| 204 | - return ''; | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - final String ans = name.toDartString(); | ||
| 208 | - | ||
| 209 | - SherpaOnnxBindings.speakerEmbeddingManagerFreeSearch?.call(name); | ||
| 210 | - | ||
| 211 | - return ans; | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | - bool verify( | ||
| 215 | - {required String name, | ||
| 216 | - required Float32List embedding, | ||
| 217 | - required double threshold}) { | ||
| 218 | - assert(embedding.length == dim); | ||
| 219 | - | ||
| 220 | - final Pointer<Utf8> namePtr = name.toNativeUtf8(); | ||
| 221 | - | ||
| 222 | - final Pointer<Float> p = calloc<Float>(dim); | ||
| 223 | - final pList = p.asTypedList(dim); | ||
| 224 | - pList.setAll(0, embedding); | ||
| 225 | - | ||
| 226 | - final int ok = SherpaOnnxBindings.speakerEmbeddingManagerVerify | ||
| 227 | - ?.call(ptr, namePtr, p, threshold) ?? | ||
| 228 | - 0; | ||
| 229 | - | ||
| 230 | - calloc.free(p); | ||
| 231 | - calloc.free(namePtr); | ||
| 232 | - | ||
| 233 | - return ok == 1; | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - int get numSpeakers => | ||
| 237 | - SherpaOnnxBindings.speakerEmbeddingManagerNumSpeakers?.call(ptr) ?? 0; | ||
| 238 | - | ||
| 239 | - List<String> get allSpeakerNames { | ||
| 240 | - int n = numSpeakers; | ||
| 241 | - if (n == 0) { | ||
| 242 | - return <String>[]; | ||
| 243 | - } | ||
| 244 | - | ||
| 245 | - final Pointer<Pointer<Utf8>> names = | ||
| 246 | - SherpaOnnxBindings.speakerEmbeddingManagerGetAllSpeakers?.call(ptr) ?? | ||
| 247 | - nullptr; | ||
| 248 | - | ||
| 249 | - if (names == nullptr) { | ||
| 250 | - return <String>[]; | ||
| 251 | - } | ||
| 252 | - | ||
| 253 | - final ans = <String>[]; | ||
| 254 | - | ||
| 255 | - // see https://api.flutter.dev/flutter/dart-ffi/PointerPointer.html | ||
| 256 | - for (int i = 0; i != n; ++i) { | ||
| 257 | - String name = names[i].toDartString(); | ||
| 258 | - ans.add(name); | ||
| 259 | - } | ||
| 260 | - | ||
| 261 | - SherpaOnnxBindings.speakerEmbeddingManagerFreeAllSpeakers?.call(names); | ||
| 262 | - | ||
| 263 | - return ans; | ||
| 264 | - } | ||
| 265 | - | ||
| 266 | - Pointer<SherpaOnnxSpeakerEmbeddingManager> ptr; | ||
| 267 | - final int dim; | ||
| 268 | -} |
sherpa-onnx/flutter/lib/src/tts.dart
已删除
100644 → 0
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | - | ||
| 5 | -import 'package:ffi/ffi.dart'; | ||
| 6 | - | ||
| 7 | -import './sherpa_onnx_bindings.dart'; | ||
| 8 | - | ||
| 9 | -class OfflineTtsVitsModelConfig { | ||
| 10 | - const OfflineTtsVitsModelConfig({ | ||
| 11 | - required this.model, | ||
| 12 | - this.lexicon = '', | ||
| 13 | - required this.tokens, | ||
| 14 | - this.dataDir = '', | ||
| 15 | - this.noiseScale = 0.667, | ||
| 16 | - this.noiseScaleW = 0.8, | ||
| 17 | - this.lengthScale = 1.0, | ||
| 18 | - this.dictDir = '', | ||
| 19 | - }); | ||
| 20 | - | ||
| 21 | - @override | ||
| 22 | - String toString() { | ||
| 23 | - return 'OfflineTtsVitsModelConfig(model: $model, lexicon: $lexicon, tokens: $tokens, dataDir: $dataDir, noiseScale: $noiseScale, noiseScaleW: $noiseScaleW, lengthScale: $lengthScale, dictDir: $dictDir)'; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - final String model; | ||
| 27 | - final String lexicon; | ||
| 28 | - final String tokens; | ||
| 29 | - final String dataDir; | ||
| 30 | - final double noiseScale; | ||
| 31 | - final double noiseScaleW; | ||
| 32 | - final double lengthScale; | ||
| 33 | - final String dictDir; | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -class OfflineTtsModelConfig { | ||
| 37 | - const OfflineTtsModelConfig({ | ||
| 38 | - required this.vits, | ||
| 39 | - this.numThreads = 1, | ||
| 40 | - this.debug = true, | ||
| 41 | - this.provider = 'cpu', | ||
| 42 | - }); | ||
| 43 | - | ||
| 44 | - @override | ||
| 45 | - String toString() { | ||
| 46 | - return 'OfflineTtsModelConfig(vits: $vits, numThreads: $numThreads, debug: $debug, provider: $provider)'; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - final OfflineTtsVitsModelConfig vits; | ||
| 50 | - final int numThreads; | ||
| 51 | - final bool debug; | ||
| 52 | - final String provider; | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -class OfflineTtsConfig { | ||
| 56 | - const OfflineTtsConfig({ | ||
| 57 | - required this.model, | ||
| 58 | - this.ruleFsts = '', | ||
| 59 | - this.maxNumSenetences = 1, | ||
| 60 | - this.ruleFars = '', | ||
| 61 | - }); | ||
| 62 | - | ||
| 63 | - @override | ||
| 64 | - String toString() { | ||
| 65 | - return 'OfflineTtsConfig(model: $model, ruleFsts: $ruleFsts, maxNumSenetences: $maxNumSenetences, ruleFars: $ruleFars)'; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - final OfflineTtsModelConfig model; | ||
| 69 | - final String ruleFsts; | ||
| 70 | - final int maxNumSenetences; | ||
| 71 | - final String ruleFars; | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -class GeneratedAudio { | ||
| 75 | - GeneratedAudio({ | ||
| 76 | - required this.samples, | ||
| 77 | - required this.sampleRate, | ||
| 78 | - }); | ||
| 79 | - | ||
| 80 | - final Float32List samples; | ||
| 81 | - final int sampleRate; | ||
| 82 | -} | ||
| 83 | - | ||
| 84 | -class OfflineTts { | ||
| 85 | - OfflineTts._({required this.ptr, required this.config}); | ||
| 86 | - | ||
| 87 | - /// The user is responsible to call the OfflineTts.free() | ||
| 88 | - /// method of the returned instance to avoid memory leak. | ||
| 89 | - factory OfflineTts(OfflineTtsConfig config) { | ||
| 90 | - final c = calloc<SherpaOnnxOfflineTtsConfig>(); | ||
| 91 | - c.ref.model.vits.model = config.model.vits.model.toNativeUtf8(); | ||
| 92 | - c.ref.model.vits.lexicon = config.model.vits.lexicon.toNativeUtf8(); | ||
| 93 | - c.ref.model.vits.tokens = config.model.vits.tokens.toNativeUtf8(); | ||
| 94 | - c.ref.model.vits.dataDir = config.model.vits.dataDir.toNativeUtf8(); | ||
| 95 | - c.ref.model.vits.noiseScale = config.model.vits.noiseScale; | ||
| 96 | - c.ref.model.vits.noiseScaleW = config.model.vits.noiseScaleW; | ||
| 97 | - c.ref.model.vits.lengthScale = config.model.vits.lengthScale; | ||
| 98 | - c.ref.model.vits.dictDir = config.model.vits.dictDir.toNativeUtf8(); | ||
| 99 | - | ||
| 100 | - c.ref.model.numThreads = config.model.numThreads; | ||
| 101 | - c.ref.model.debug = config.model.debug ? 1 : 0; | ||
| 102 | - c.ref.model.provider = config.model.provider.toNativeUtf8(); | ||
| 103 | - | ||
| 104 | - c.ref.ruleFsts = config.ruleFsts.toNativeUtf8(); | ||
| 105 | - c.ref.maxNumSenetences = config.maxNumSenetences; | ||
| 106 | - c.ref.ruleFars = config.ruleFars.toNativeUtf8(); | ||
| 107 | - | ||
| 108 | - final ptr = SherpaOnnxBindings.createOfflineTts?.call(c) ?? nullptr; | ||
| 109 | - | ||
| 110 | - calloc.free(c.ref.ruleFars); | ||
| 111 | - calloc.free(c.ref.ruleFsts); | ||
| 112 | - calloc.free(c.ref.model.provider); | ||
| 113 | - calloc.free(c.ref.model.vits.dictDir); | ||
| 114 | - calloc.free(c.ref.model.vits.dataDir); | ||
| 115 | - calloc.free(c.ref.model.vits.tokens); | ||
| 116 | - calloc.free(c.ref.model.vits.lexicon); | ||
| 117 | - calloc.free(c.ref.model.vits.model); | ||
| 118 | - | ||
| 119 | - return OfflineTts._(ptr: ptr, config: config); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - void free() { | ||
| 123 | - SherpaOnnxBindings.destroyOfflineTts?.call(ptr); | ||
| 124 | - ptr = nullptr; | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - GeneratedAudio generate( | ||
| 128 | - {required String text, int sid = 0, double speed = 1.0}) { | ||
| 129 | - final Pointer<Utf8> textPtr = text.toNativeUtf8(); | ||
| 130 | - final p = | ||
| 131 | - SherpaOnnxBindings.offlineTtsGenerate?.call(ptr, textPtr, sid, speed) ?? | ||
| 132 | - nullptr; | ||
| 133 | - calloc.free(textPtr); | ||
| 134 | - | ||
| 135 | - if (p == nullptr) { | ||
| 136 | - return GeneratedAudio(samples: Float32List(0), sampleRate: 0); | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - final samples = p.ref.samples.asTypedList(p.ref.n); | ||
| 140 | - final sampleRate = p.ref.sampleRate; | ||
| 141 | - final newSamples = Float32List.fromList(samples); | ||
| 142 | - | ||
| 143 | - SherpaOnnxBindings.destroyOfflineTtsGeneratedAudio?.call(p); | ||
| 144 | - | ||
| 145 | - return GeneratedAudio(samples: newSamples, sampleRate: sampleRate); | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | - GeneratedAudio generateWithCallback( | ||
| 149 | - {required String text, | ||
| 150 | - int sid = 0, | ||
| 151 | - double speed = 1.0, | ||
| 152 | - required int Function(Float32List samples) callback}) { | ||
| 153 | - // see | ||
| 154 | - // https://github.com/dart-lang/sdk/issues/54276#issuecomment-1846109285 | ||
| 155 | - // https://stackoverflow.com/questions/69537440/callbacks-in-dart-dartffi-only-supports-calling-static-dart-functions-from-nat | ||
| 156 | - // https://github.com/dart-lang/sdk/blob/main/tests/ffi/isolate_local_function_callbacks_test.dart#L46 | ||
| 157 | - final wrapper = | ||
| 158 | - NativeCallable<SherpaOnnxGeneratedAudioCallbackNative>.isolateLocal( | ||
| 159 | - (Pointer<Float> samples, int n) { | ||
| 160 | - final s = samples.asTypedList(n); | ||
| 161 | - final newSamples = Float32List.fromList(s); | ||
| 162 | - return callback(newSamples); | ||
| 163 | - }, exceptionalReturn: 0); | ||
| 164 | - | ||
| 165 | - final Pointer<Utf8> textPtr = text.toNativeUtf8(); | ||
| 166 | - final p = SherpaOnnxBindings.offlineTtsGenerateWithCallback | ||
| 167 | - ?.call(ptr, textPtr, sid, speed, wrapper.nativeFunction) ?? | ||
| 168 | - nullptr; | ||
| 169 | - | ||
| 170 | - calloc.free(textPtr); | ||
| 171 | - wrapper.close(); | ||
| 172 | - | ||
| 173 | - if (p == nullptr) { | ||
| 174 | - return GeneratedAudio(samples: Float32List(0), sampleRate: 0); | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - final samples = p.ref.samples.asTypedList(p.ref.n); | ||
| 178 | - final sampleRate = p.ref.sampleRate; | ||
| 179 | - final newSamples = Float32List.fromList(samples); | ||
| 180 | - | ||
| 181 | - SherpaOnnxBindings.destroyOfflineTtsGeneratedAudio?.call(p); | ||
| 182 | - | ||
| 183 | - return GeneratedAudio(samples: newSamples, sampleRate: sampleRate); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - int get sampleRate => SherpaOnnxBindings.offlineTtsSampleRate?.call(ptr) ?? 0; | ||
| 187 | - | ||
| 188 | - int get numSpeakers => | ||
| 189 | - SherpaOnnxBindings.offlineTtsNumSpeakers?.call(ptr) ?? 0; | ||
| 190 | - | ||
| 191 | - Pointer<SherpaOnnxOfflineTts> ptr; | ||
| 192 | - OfflineTtsConfig config; | ||
| 193 | -} |
sherpa-onnx/flutter/lib/src/vad.dart
已删除
100644 → 0
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './sherpa_onnx_bindings.dart'; | ||
| 7 | - | ||
| 8 | -class SileroVadModelConfig { | ||
| 9 | - const SileroVadModelConfig( | ||
| 10 | - {this.model = '', | ||
| 11 | - this.threshold = 0.5, | ||
| 12 | - this.minSilenceDuration = 0.5, | ||
| 13 | - this.minSpeechDuration = 0.25, | ||
| 14 | - this.windowSize = 512}); | ||
| 15 | - | ||
| 16 | - @override | ||
| 17 | - String toString() { | ||
| 18 | - return 'SileroVadModelConfig(model: $model, threshold: $threshold, minSilenceDuration: $minSilenceDuration, minSpeechDuration: $minSpeechDuration, windowSize: $windowSize)'; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - final String model; | ||
| 22 | - final double threshold; | ||
| 23 | - final double minSilenceDuration; | ||
| 24 | - final double minSpeechDuration; | ||
| 25 | - final int windowSize; | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -class VadModelConfig { | ||
| 29 | - VadModelConfig( | ||
| 30 | - {this.sileroVad = const SileroVadModelConfig(), | ||
| 31 | - this.sampleRate = 16000, | ||
| 32 | - this.numThreads = 1, | ||
| 33 | - this.provider = 'cpu', | ||
| 34 | - this.debug = true}); | ||
| 35 | - | ||
| 36 | - @override | ||
| 37 | - String toString() { | ||
| 38 | - return 'VadModelConfig(sileroVad: $sileroVad, sampleRate: $sampleRate, numThreads: $numThreads, provider: $provider, debug: $debug)'; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - final SileroVadModelConfig sileroVad; | ||
| 42 | - final int sampleRate; | ||
| 43 | - final int numThreads; | ||
| 44 | - final String provider; | ||
| 45 | - final bool debug; | ||
| 46 | -} | ||
| 47 | - | ||
| 48 | -class SpeechSegment { | ||
| 49 | - SpeechSegment({required this.samples, required this.start}); | ||
| 50 | - final Float32List samples; | ||
| 51 | - final int start; | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -class CircularBuffer { | ||
| 55 | - CircularBuffer._({required this.ptr}); | ||
| 56 | - | ||
| 57 | - /// The user has to invoke CircularBuffer.free() on the returned instance | ||
| 58 | - /// to avoid memory leak. | ||
| 59 | - factory CircularBuffer({required int capacity}) { | ||
| 60 | - assert(capacity > 0, 'capacity is $capacity'); | ||
| 61 | - final p = | ||
| 62 | - SherpaOnnxBindings.createCircularBuffer?.call(capacity) ?? nullptr; | ||
| 63 | - | ||
| 64 | - return CircularBuffer._(ptr: p); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - void free() { | ||
| 68 | - SherpaOnnxBindings.destroyCircularBuffer?.call(ptr); | ||
| 69 | - ptr = nullptr; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - void push(Float32List data) { | ||
| 73 | - final n = data.length; | ||
| 74 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 75 | - | ||
| 76 | - final pList = p.asTypedList(n); | ||
| 77 | - pList.setAll(0, data); | ||
| 78 | - | ||
| 79 | - SherpaOnnxBindings.circularBufferPush?.call(ptr, p, n); | ||
| 80 | - | ||
| 81 | - calloc.free(p); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - Float32List get({required int startIndex, required int n}) { | ||
| 85 | - final Pointer<Float> p = | ||
| 86 | - SherpaOnnxBindings.circularBufferGet?.call(ptr, startIndex, n) ?? | ||
| 87 | - nullptr; | ||
| 88 | - | ||
| 89 | - if (p == nullptr) { | ||
| 90 | - return Float32List(0); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - final pList = p.asTypedList(n); | ||
| 94 | - final Float32List ans = Float32List.fromList(pList); | ||
| 95 | - | ||
| 96 | - SherpaOnnxBindings.circularBufferFree?.call(p); | ||
| 97 | - | ||
| 98 | - return ans; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - void pop(int n) { | ||
| 102 | - SherpaOnnxBindings.circularBufferPop?.call(ptr, n); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - void reset() { | ||
| 106 | - SherpaOnnxBindings.circularBufferReset?.call(ptr); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - int get size => SherpaOnnxBindings.circularBufferSize?.call(ptr) ?? 0; | ||
| 110 | - int get head => SherpaOnnxBindings.circularBufferHead?.call(ptr) ?? 0; | ||
| 111 | - | ||
| 112 | - Pointer<SherpaOnnxCircularBuffer> ptr; | ||
| 113 | -} | ||
| 114 | - | ||
| 115 | -class VoiceActivityDetector { | ||
| 116 | - VoiceActivityDetector._({required this.ptr, required this.config}); | ||
| 117 | - | ||
| 118 | - // The user has to invoke VoiceActivityDetector.free() to avoid memory leak. | ||
| 119 | - factory VoiceActivityDetector( | ||
| 120 | - {required VadModelConfig config, required double bufferSizeInSeconds}) { | ||
| 121 | - final c = calloc<SherpaOnnxVadModelConfig>(); | ||
| 122 | - | ||
| 123 | - final modelPtr = config.sileroVad.model.toNativeUtf8(); | ||
| 124 | - c.ref.sileroVad.model = modelPtr; | ||
| 125 | - | ||
| 126 | - c.ref.sileroVad.threshold = config.sileroVad.threshold; | ||
| 127 | - c.ref.sileroVad.minSilenceDuration = config.sileroVad.minSilenceDuration; | ||
| 128 | - c.ref.sileroVad.minSpeechDuration = config.sileroVad.minSpeechDuration; | ||
| 129 | - c.ref.sileroVad.windowSize = config.sileroVad.windowSize; | ||
| 130 | - | ||
| 131 | - c.ref.sampleRate = config.sampleRate; | ||
| 132 | - c.ref.numThreads = config.numThreads; | ||
| 133 | - | ||
| 134 | - final providerPtr = config.provider.toNativeUtf8(); | ||
| 135 | - c.ref.provider = providerPtr; | ||
| 136 | - | ||
| 137 | - c.ref.debug = config.debug ? 1 : 0; | ||
| 138 | - | ||
| 139 | - final ptr = SherpaOnnxBindings.createVoiceActivityDetector | ||
| 140 | - ?.call(c, bufferSizeInSeconds) ?? | ||
| 141 | - nullptr; | ||
| 142 | - | ||
| 143 | - calloc.free(providerPtr); | ||
| 144 | - calloc.free(modelPtr); | ||
| 145 | - calloc.free(c); | ||
| 146 | - | ||
| 147 | - return VoiceActivityDetector._(ptr: ptr, config: config); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - void free() { | ||
| 151 | - SherpaOnnxBindings.destroyVoiceActivityDetector?.call(ptr); | ||
| 152 | - ptr = nullptr; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - void acceptWaveform(Float32List samples) { | ||
| 156 | - final n = samples.length; | ||
| 157 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 158 | - | ||
| 159 | - final pList = p.asTypedList(n); | ||
| 160 | - pList.setAll(0, samples); | ||
| 161 | - | ||
| 162 | - SherpaOnnxBindings.voiceActivityDetectorAcceptWaveform?.call(ptr, p, n); | ||
| 163 | - | ||
| 164 | - calloc.free(p); | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - bool isEmpty() { | ||
| 168 | - final int empty = | ||
| 169 | - SherpaOnnxBindings.voiceActivityDetectorEmpty?.call(ptr) ?? 0; | ||
| 170 | - | ||
| 171 | - return empty == 1; | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - bool isDetected() { | ||
| 175 | - final int detected = | ||
| 176 | - SherpaOnnxBindings.voiceActivityDetectorDetected?.call(ptr) ?? 0; | ||
| 177 | - | ||
| 178 | - return detected == 1; | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - void pop() { | ||
| 182 | - SherpaOnnxBindings.voiceActivityDetectorPop?.call(ptr); | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - void clear() { | ||
| 186 | - SherpaOnnxBindings.voiceActivityDetectorClear?.call(ptr); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - SpeechSegment front() { | ||
| 190 | - final Pointer<SherpaOnnxSpeechSegment> segment = | ||
| 191 | - SherpaOnnxBindings.voiceActivityDetectorFront?.call(ptr) ?? nullptr; | ||
| 192 | - if (segment == nullptr) { | ||
| 193 | - return SpeechSegment(samples: Float32List(0), start: 0); | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - final sampleList = segment.ref.samples.asTypedList(segment.ref.n); | ||
| 197 | - final start = segment.ref.start; | ||
| 198 | - | ||
| 199 | - final samples = Float32List.fromList(sampleList); | ||
| 200 | - | ||
| 201 | - SherpaOnnxBindings.destroySpeechSegment?.call(segment); | ||
| 202 | - | ||
| 203 | - return SpeechSegment(samples: samples, start: start); | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - void reset() { | ||
| 207 | - SherpaOnnxBindings.voiceActivityDetectorReset?.call(ptr); | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - Pointer<SherpaOnnxVoiceActivityDetector> ptr; | ||
| 211 | - final VadModelConfig config; | ||
| 212 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './sherpa_onnx_bindings.dart'; | ||
| 7 | - | ||
| 8 | -class WaveData { | ||
| 9 | - WaveData({required this.samples, required this.sampleRate}); | ||
| 10 | - | ||
| 11 | - /// normalized to [-1, 1] | ||
| 12 | - Float32List samples; | ||
| 13 | - int sampleRate; | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -WaveData readWave(String filename) { | ||
| 17 | - final Pointer<Utf8> str = filename.toNativeUtf8(); | ||
| 18 | - Pointer<SherpaOnnxWave> wave = | ||
| 19 | - SherpaOnnxBindings.readWave?.call(str) ?? nullptr; | ||
| 20 | - calloc.free(str); | ||
| 21 | - | ||
| 22 | - if (wave == nullptr) { | ||
| 23 | - return WaveData(samples: Float32List(0), sampleRate: 0); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - final samples = wave.ref.samples.asTypedList(wave.ref.numSamples); | ||
| 27 | - | ||
| 28 | - final newSamples = Float32List.fromList(samples); | ||
| 29 | - int sampleRate = wave.ref.sampleRate; | ||
| 30 | - SherpaOnnxBindings.freeWave?.call(wave); | ||
| 31 | - | ||
| 32 | - return WaveData(samples: newSamples, sampleRate: sampleRate); | ||
| 33 | -} |
| 1 | -// Copyright (c) 2024 Xiaomi Corporation | ||
| 2 | -import 'dart:ffi'; | ||
| 3 | -import 'dart:typed_data'; | ||
| 4 | -import 'package:ffi/ffi.dart'; | ||
| 5 | - | ||
| 6 | -import './sherpa_onnx_bindings.dart'; | ||
| 7 | - | ||
| 8 | -bool writeWave( | ||
| 9 | - {required String filename, | ||
| 10 | - required Float32List samples, | ||
| 11 | - required int sampleRate}) { | ||
| 12 | - final Pointer<Utf8> filenamePtr = filename.toNativeUtf8(); | ||
| 13 | - | ||
| 14 | - final n = samples.length; | ||
| 15 | - final Pointer<Float> p = calloc<Float>(n); | ||
| 16 | - | ||
| 17 | - final pList = p.asTypedList(n); | ||
| 18 | - pList.setAll(0, samples); | ||
| 19 | - | ||
| 20 | - int ok = | ||
| 21 | - SherpaOnnxBindings.writeWave?.call(p, n, sampleRate, filenamePtr) ?? 0; | ||
| 22 | - | ||
| 23 | - calloc.free(p); | ||
| 24 | - calloc.free(filenamePtr); | ||
| 25 | - | ||
| 26 | - return ok == 1; | ||
| 27 | -} |
sherpa-onnx/flutter/linux/CMakeLists.txt
已删除
100644 → 0
| 1 | -# The Flutter tooling requires that developers have CMake 3.10 or later | ||
| 2 | -# installed. You should not increase this version, as doing so will cause | ||
| 3 | -# the plugin to fail to compile for some customers of the plugin. | ||
| 4 | -cmake_minimum_required(VERSION 3.10) | ||
| 5 | - | ||
| 6 | -# Project-level configuration. | ||
| 7 | -set(PROJECT_NAME "sherpa_onnx") | ||
| 8 | -project(${PROJECT_NAME} LANGUAGES CXX) | ||
| 9 | - | ||
| 10 | -# Invoke the build for native code shared with the other target platforms. | ||
| 11 | -# This can be changed to accommodate different builds. | ||
| 12 | -# add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") | ||
| 13 | - | ||
| 14 | -# List of absolute paths to libraries that should be bundled with the plugin. | ||
| 15 | -# This list could contain prebuilt libraries, or libraries created by an | ||
| 16 | -# external build triggered from this build file. | ||
| 17 | -set(sherpa_onnx_bundled_libraries | ||
| 18 | - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so" | ||
| 19 | - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-core.so" | ||
| 20 | - "${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-decoder-core.so" | ||
| 21 | - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-kaldifst-core.so" | ||
| 22 | - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fstfar.so" | ||
| 23 | - "${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-fst.so" | ||
| 24 | - "${CMAKE_CURRENT_SOURCE_DIR}/libkaldi-native-fbank-core.so" | ||
| 25 | - "${CMAKE_CURRENT_SOURCE_DIR}/libpiper_phonemize.so" | ||
| 26 | - "${CMAKE_CURRENT_SOURCE_DIR}/libespeak-ng.so" | ||
| 27 | - "${CMAKE_CURRENT_SOURCE_DIR}/libucd.so" | ||
| 28 | - "${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so" | ||
| 29 | - "${CMAKE_CURRENT_SOURCE_DIR}/libssentencepiece_core.so" | ||
| 30 | - PARENT_SCOPE | ||
| 31 | -) |
| 1 | -# | ||
| 2 | -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. | ||
| 3 | -# Run `pod lib lint hello.podspec` to validate before publishing. | ||
| 4 | -# | ||
| 5 | -Pod::Spec.new do |s| | ||
| 6 | - s.name = 'sherpa_onnx' | ||
| 7 | - s.version = '0.0.1' | ||
| 8 | - s.summary = 'sherpa-onnx Flutter FFI plugin project.' | ||
| 9 | - s.description = <<-DESC | ||
| 10 | -sherpa-onnx Flutter FFI plugin project. | ||
| 11 | - DESC | ||
| 12 | - s.homepage = 'https://github.com/k2-fsa/sherpa-onnx' | ||
| 13 | - s.license = { :file => '../LICENSE' } | ||
| 14 | - s.author = { 'Your Company' => 'email@example.com' } | ||
| 15 | - | ||
| 16 | - # This will ensure the source files in Classes/ are included in the native | ||
| 17 | - # builds of apps using this FFI plugin. Podspec does not support relative | ||
| 18 | - # paths, so Classes contains a forwarder C file that relatively imports | ||
| 19 | - # `../src/*` so that the C sources can be shared among all target platforms. | ||
| 20 | - s.source = { :path => '.' } | ||
| 21 | - s.dependency 'FlutterMacOS' | ||
| 22 | - s.vendored_libraries = '*.dylib' | ||
| 23 | - | ||
| 24 | - s.platform = :osx, '10.11' | ||
| 25 | - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } | ||
| 26 | - s.swift_version = '5.0' | ||
| 27 | -end |
sherpa-onnx/flutter/pubspec.yaml
已删除
100644 → 0
| 1 | -name: sherpa_onnx | ||
| 2 | - | ||
| 3 | -description: > | ||
| 4 | - Speech recognition, speech synthesis, and speaker recognition using next-gen Kaldi | ||
| 5 | - with onnxruntime without Internet connection. | ||
| 6 | - | ||
| 7 | -repository: https://github.com/k2-fsa/sherpa-onnx/tree/master/sherpa-onnx/flutter | ||
| 8 | - | ||
| 9 | -issue_tracker: https://github.com/k2-fsa/sherpa-onnx/issues | ||
| 10 | -documentation: https://k2-fsa.github.io/sherpa/onnx/ | ||
| 11 | - | ||
| 12 | -topics: | ||
| 13 | - - speech-recognition | ||
| 14 | - - speech-synthesis | ||
| 15 | - - speaker-identification | ||
| 16 | - - audio-tagging | ||
| 17 | - - voice-activity-detection | ||
| 18 | - | ||
| 19 | -# remember to change the version in macos/sherpa_onnx.podspec | ||
| 20 | -version: 1.9.29 | ||
| 21 | - | ||
| 22 | -homepage: https://github.com/k2-fsa/sherpa-onnx | ||
| 23 | - | ||
| 24 | -environment: | ||
| 25 | - sdk: '>=3.4.0 <4.0.0' | ||
| 26 | - flutter: '>=3.3.0' | ||
| 27 | - | ||
| 28 | -dependencies: | ||
| 29 | - ffi: ^2.1.0 | ||
| 30 | - flutter: | ||
| 31 | - sdk: flutter | ||
| 32 | - | ||
| 33 | - | ||
| 34 | -# The following section is specific to Flutter packages. | ||
| 35 | -flutter: | ||
| 36 | - plugin: | ||
| 37 | - platforms: | ||
| 38 | - macos: | ||
| 39 | - ffiPlugin: true | ||
| 40 | - windows: | ||
| 41 | - ffiPlugin: true | ||
| 42 | - linux: | ||
| 43 | - ffiPlugin: true |
| 1 | -# The Flutter tooling requires that developers have a version of Visual Studio | ||
| 2 | -# installed that includes CMake 3.14 or later. You should not increase this | ||
| 3 | -# version, as doing so will cause the plugin to fail to compile for some | ||
| 4 | -# customers of the plugin. | ||
| 5 | -cmake_minimum_required(VERSION 3.14) | ||
| 6 | - | ||
| 7 | -# Project-level configuration. | ||
| 8 | -set(PROJECT_NAME "sherpa_onnx") | ||
| 9 | -project(${PROJECT_NAME} LANGUAGES CXX) | ||
| 10 | - | ||
| 11 | -# Invoke the build for native code shared with the other target platforms. | ||
| 12 | -# This can be changed to accommodate different builds. | ||
| 13 | -# add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") | ||
| 14 | - | ||
| 15 | -# List of absolute paths to libraries that should be bundled with the plugin. | ||
| 16 | -# This list could contain prebuilt libraries, or libraries created by an | ||
| 17 | -# external build triggered from this build file. | ||
| 18 | -set(sherpa_onnx_bundled_libraries | ||
| 19 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll" | ||
| 20 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-core.dll" | ||
| 21 | - "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-decoder-core.dll" | ||
| 22 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-kaldifst-core.dll" | ||
| 23 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fstfar.dll" | ||
| 24 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fst.dll" | ||
| 25 | - "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-native-fbank-core.dll" | ||
| 26 | - "${CMAKE_CURRENT_SOURCE_DIR}/piper_phonemize.dll" | ||
| 27 | - "${CMAKE_CURRENT_SOURCE_DIR}/espeak-ng.dll" | ||
| 28 | - "${CMAKE_CURRENT_SOURCE_DIR}/ucd.dll" | ||
| 29 | - "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime.dll" | ||
| 30 | - "${CMAKE_CURRENT_SOURCE_DIR}/ssentencepiece_core.dll" | ||
| 31 | - PARENT_SCOPE | ||
| 32 | -) |
-
请 注册 或 登录 后发表评论