正在显示
33 个修改的文件
包含
880 行增加
和
139 行删除
| @@ -48,7 +48,7 @@ jobs: | @@ -48,7 +48,7 @@ jobs: | ||
| 48 | path: ./wheelhouse/*.whl | 48 | path: ./wheelhouse/*.whl |
| 49 | 49 | ||
| 50 | - name: Publish to huggingface | 50 | - name: Publish to huggingface |
| 51 | - if: matrix.python-version == 'cp38' | 51 | + if: matrix.python-version == 'cp39' |
| 52 | env: | 52 | env: |
| 53 | HF_TOKEN: ${{ secrets.HF_TOKEN }} | 53 | HF_TOKEN: ${{ secrets.HF_TOKEN }} |
| 54 | uses: nick-fields/retry@v3 | 54 | uses: nick-fields/retry@v3 |
| @@ -82,7 +82,13 @@ jobs: | @@ -82,7 +82,13 @@ jobs: | ||
| 82 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | 82 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 83 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | 83 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 84 | run: | | 84 | run: | |
| 85 | - python3 -m pip install --break-system-packages --upgrade pip | ||
| 86 | - python3 -m pip install --break-system-packages wheel twine setuptools | 85 | + opts='--break-system-packages' |
| 86 | + v=${{ matrix.python-version }} | ||
| 87 | + if [[ $v == cp38 || $v == cp39 ]]; then | ||
| 88 | + opts='' | ||
| 89 | + fi | ||
| 90 | + | ||
| 91 | + python3 -m pip install $opts --upgrade pip | ||
| 92 | + python3 -m pip install $opts wheel twine setuptools | ||
| 87 | 93 | ||
| 88 | twine upload ./wheelhouse/*.whl | 94 | twine upload ./wheelhouse/*.whl |
| @@ -50,7 +50,7 @@ jobs: | @@ -50,7 +50,7 @@ jobs: | ||
| 50 | path: ./wheelhouse/*.whl | 50 | path: ./wheelhouse/*.whl |
| 51 | 51 | ||
| 52 | - name: Publish to huggingface | 52 | - name: Publish to huggingface |
| 53 | - if: matrix.python-version == 'cp38' | 53 | + if: matrix.python-version == 'cp39' |
| 54 | env: | 54 | env: |
| 55 | HF_TOKEN: ${{ secrets.HF_TOKEN }} | 55 | HF_TOKEN: ${{ secrets.HF_TOKEN }} |
| 56 | uses: nick-fields/retry@v3 | 56 | uses: nick-fields/retry@v3 |
| @@ -65,7 +65,7 @@ jobs: | @@ -65,7 +65,7 @@ jobs: | ||
| 65 | path: ./wheelhouse/*.whl | 65 | path: ./wheelhouse/*.whl |
| 66 | 66 | ||
| 67 | - name: Publish to huggingface | 67 | - name: Publish to huggingface |
| 68 | - if: matrix.python-version == 'cp38' | 68 | + if: matrix.python-version == 'cp39' |
| 69 | env: | 69 | env: |
| 70 | HF_TOKEN: ${{ secrets.HF_TOKEN }} | 70 | HF_TOKEN: ${{ secrets.HF_TOKEN }} |
| 71 | uses: nick-fields/retry@v3 | 71 | uses: nick-fields/retry@v3 |
| @@ -99,7 +99,13 @@ jobs: | @@ -99,7 +99,13 @@ jobs: | ||
| 99 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | 99 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 100 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | 100 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 101 | run: | | 101 | run: | |
| 102 | - python3 -m pip install --break-system-packages --upgrade pip | ||
| 103 | - python3 -m pip install --break-system-packages wheel twine setuptools | 102 | + opts='--break-system-packages' |
| 103 | + v=${{ matrix.python-version }} | ||
| 104 | + if [[ $v == cp38 || $v == cp39 ]]; then | ||
| 105 | + opts='' | ||
| 106 | + fi | ||
| 107 | + | ||
| 108 | + python3 -m pip install $opts --upgrade pip | ||
| 109 | + python3 -m pip install $opts wheel twine setuptools | ||
| 104 | 110 | ||
| 105 | twine upload ./wheelhouse/*.whl | 111 | twine upload ./wheelhouse/*.whl |
| @@ -152,6 +152,8 @@ jobs: | @@ -152,6 +152,8 @@ jobs: | ||
| 152 | - name: Build flutter | 152 | - name: Build flutter |
| 153 | shell: bash | 153 | shell: bash |
| 154 | run: | | 154 | run: | |
| 155 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 156 | + | ||
| 155 | d=$PWD | 157 | d=$PWD |
| 156 | 158 | ||
| 157 | pushd sherpa-onnx/flutter | 159 | pushd sherpa-onnx/flutter |
| @@ -166,7 +168,7 @@ jobs: | @@ -166,7 +168,7 @@ jobs: | ||
| 166 | 168 | ||
| 167 | tree ./sherpa_onnx.app | 169 | tree ./sherpa_onnx.app |
| 168 | 170 | ||
| 169 | - app=flutter_sherpa_onnx_macos_${{ matrix.arch }}.app | 171 | + app=sherpa-onnx-osx-${{ matrix.arch }}-$SHERPA_ONNX_VERSION.app |
| 170 | mv sherpa_onnx.app $app | 172 | mv sherpa_onnx.app $app |
| 171 | tar cjfv $app.tar.bz2 $app | 173 | tar cjfv $app.tar.bz2 $app |
| 172 | ls -lh | 174 | ls -lh |
| @@ -178,13 +180,43 @@ jobs: | @@ -178,13 +180,43 @@ jobs: | ||
| 178 | 180 | ||
| 179 | - uses: actions/upload-artifact@v4 | 181 | - uses: actions/upload-artifact@v4 |
| 180 | with: | 182 | with: |
| 181 | - name: flutter-sherpa-onnx-app-macos-${{ matrix.arch }} | 183 | + name: sherpa-onnx-osx-${{ matrix.arch }} |
| 182 | path: ./*.tar.bz2 | 184 | path: ./*.tar.bz2 |
| 183 | 185 | ||
| 184 | - - name: Release android libs | ||
| 185 | - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 186 | - uses: svenstaro/upload-release-action@v2 | 186 | + - name: Publish to huggingface |
| 187 | + env: | ||
| 188 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 189 | + uses: nick-fields/retry@v3 | ||
| 187 | with: | 190 | with: |
| 188 | - file_glob: true | ||
| 189 | - overwrite: true | ||
| 190 | - file: flutter*.tar.bz2 | 191 | + max_attempts: 20 |
| 192 | + timeout_seconds: 200 | ||
| 193 | + shell: bash | ||
| 194 | + command: | | ||
| 195 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 196 | + git config --global user.name "Fangjun Kuang" | ||
| 197 | + | ||
| 198 | + rm -rf huggingface | ||
| 199 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 200 | + export GIT_CLONE_PROTECTION_ACTIVE=false | ||
| 201 | + | ||
| 202 | + git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface | ||
| 203 | + cd huggingface | ||
| 204 | + git fetch | ||
| 205 | + git pull | ||
| 206 | + git merge -m "merge remote" --ff origin main | ||
| 207 | + mkdir -p flutter | ||
| 208 | + cp -v ../*.tar.bz2 ./flutter | ||
| 209 | + | ||
| 210 | + git status | ||
| 211 | + git lfs track "*.bz2" | ||
| 212 | + git add . | ||
| 213 | + git commit -m "add more files" | ||
| 214 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter main | ||
| 215 | + | ||
| 216 | + # - name: Release android libs | ||
| 217 | + # if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 218 | + # uses: svenstaro/upload-release-action@v2 | ||
| 219 | + # with: | ||
| 220 | + # file_glob: true | ||
| 221 | + # overwrite: true | ||
| 222 | + # file: sherpa*.tar.bz2 |
| @@ -142,7 +142,7 @@ jobs: | @@ -142,7 +142,7 @@ jobs: | ||
| 142 | 142 | ||
| 143 | cd build/windows/x64/runner/ | 143 | cd build/windows/x64/runner/ |
| 144 | 144 | ||
| 145 | - dst=flutter_sherpa_onnx_windows_x64 | 145 | + dst=sherpa-onnx-win-x64-$SHERPA_ONNX_VERSION |
| 146 | mv Release $dst | 146 | mv Release $dst |
| 147 | 147 | ||
| 148 | tar cjfv $dst.tar.bz2 ./$dst | 148 | tar cjfv $dst.tar.bz2 ./$dst |
| @@ -155,13 +155,43 @@ jobs: | @@ -155,13 +155,43 @@ jobs: | ||
| 155 | 155 | ||
| 156 | - uses: actions/upload-artifact@v4 | 156 | - uses: actions/upload-artifact@v4 |
| 157 | with: | 157 | with: |
| 158 | - name: flutter-sherpa-onnx-windows-x64 | 158 | + name: sherpa-onnx-win-x64 |
| 159 | path: ./*.tar.bz2 | 159 | path: ./*.tar.bz2 |
| 160 | 160 | ||
| 161 | - - name: Release android libs | ||
| 162 | - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 163 | - uses: svenstaro/upload-release-action@v2 | 161 | + - name: Publish to huggingface |
| 162 | + env: | ||
| 163 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 164 | + uses: nick-fields/retry@v3 | ||
| 164 | with: | 165 | with: |
| 165 | - file_glob: true | ||
| 166 | - overwrite: true | ||
| 167 | - file: flutter*.tar.bz2 | 166 | + max_attempts: 20 |
| 167 | + timeout_seconds: 200 | ||
| 168 | + shell: bash | ||
| 169 | + command: | | ||
| 170 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 171 | + git config --global user.name "Fangjun Kuang" | ||
| 172 | + | ||
| 173 | + rm -rf huggingface | ||
| 174 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 175 | + export GIT_CLONE_PROTECTION_ACTIVE=false | ||
| 176 | + | ||
| 177 | + git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface | ||
| 178 | + cd huggingface | ||
| 179 | + git fetch | ||
| 180 | + git pull | ||
| 181 | + git merge -m "merge remote" --ff origin main | ||
| 182 | + mkdir -p flutter | ||
| 183 | + cp -v ../*.tar.bz2 ./flutter | ||
| 184 | + | ||
| 185 | + git status | ||
| 186 | + git lfs track "*.bz2" | ||
| 187 | + git add . | ||
| 188 | + git commit -m "add more files" | ||
| 189 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter main | ||
| 190 | + | ||
| 191 | + # - name: Release android libs | ||
| 192 | + # if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||
| 193 | + # uses: svenstaro/upload-release-action@v2 | ||
| 194 | + # with: | ||
| 195 | + # file_glob: true | ||
| 196 | + # overwrite: true | ||
| 197 | + # file: sherpa*.tar.bz2 |
.github/workflows/test-dart.yaml
0 → 100644
| 1 | +name: test-dart | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + branches: | ||
| 6 | + - master | ||
| 7 | + paths: | ||
| 8 | + - '.github/workflows/test-dart.yaml' | ||
| 9 | + - 'dart-api-examples/**' | ||
| 10 | + pull_request: | ||
| 11 | + branches: | ||
| 12 | + - master | ||
| 13 | + paths: | ||
| 14 | + - '.github/workflows/test-dart.yaml' | ||
| 15 | + - 'dart-api-examples/**' | ||
| 16 | + | ||
| 17 | + workflow_dispatch: | ||
| 18 | + | ||
| 19 | +concurrency: | ||
| 20 | + group: test-dart-${{ github.ref }} | ||
| 21 | + cancel-in-progress: true | ||
| 22 | + | ||
| 23 | +jobs: | ||
| 24 | + dart: | ||
| 25 | + name: ${{ matrix.os }} | ||
| 26 | + runs-on: ${{ matrix.os }} | ||
| 27 | + strategy: | ||
| 28 | + fail-fast: false | ||
| 29 | + matrix: | ||
| 30 | + os: [macos-latest, ubuntu-latest] #, windows-latest] | ||
| 31 | + | ||
| 32 | + steps: | ||
| 33 | + - uses: actions/checkout@v4 | ||
| 34 | + with: | ||
| 35 | + fetch-depth: 0 | ||
| 36 | + | ||
| 37 | + - name: Setup Flutter SDK | ||
| 38 | + uses: flutter-actions/setup-flutter@v3 | ||
| 39 | + with: | ||
| 40 | + channel: stable | ||
| 41 | + version: latest | ||
| 42 | + | ||
| 43 | + - name: Display flutter info | ||
| 44 | + shell: bash | ||
| 45 | + run: | | ||
| 46 | + which flutter | ||
| 47 | + which dart | ||
| 48 | + | ||
| 49 | + flutter --version | ||
| 50 | + dart --version | ||
| 51 | + flutter doctor | ||
| 52 | + | ||
| 53 | + - name: Run tests | ||
| 54 | + shell: bash | ||
| 55 | + run: | | ||
| 56 | + cd dart-api-examples | ||
| 57 | + | ||
| 58 | + pushd vad | ||
| 59 | + ./run.sh | ||
| 60 | + popd |
| @@ -4,7 +4,10 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment ve | @@ -4,7 +4,10 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment ve | ||
| 4 | 4 | ||
| 5 | project(sherpa-onnx) | 5 | project(sherpa-onnx) |
| 6 | 6 | ||
| 7 | -set(SHERPA_ONNX_VERSION "1.9.28") | 7 | +# Remember to update |
| 8 | +# ./nodejs-addon-examples | ||
| 9 | +# ./dart-api-examples/ | ||
| 10 | +set(SHERPA_ONNX_VERSION "1.9.29") | ||
| 8 | 11 | ||
| 9 | # Disable warning about | 12 | # Disable warning about |
| 10 | # | 13 | # |
| @@ -84,9 +84,9 @@ def get_binaries(): | @@ -84,9 +84,9 @@ def get_binaries(): | ||
| 84 | "piper_phonemize.dll", | 84 | "piper_phonemize.dll", |
| 85 | "sherpa-onnx-c-api.dll", | 85 | "sherpa-onnx-c-api.dll", |
| 86 | "sherpa-onnx-core.dll", | 86 | "sherpa-onnx-core.dll", |
| 87 | - "sherpa-onnx-fstfar.lib", | ||
| 88 | - "sherpa-onnx-fst.lib", | ||
| 89 | - "sherpa-onnx-kaldifst-core.lib", | 87 | + "sherpa-onnx-fstfar.dll", |
| 88 | + "sherpa-onnx-fst.dll", | ||
| 89 | + "sherpa-onnx-kaldifst-core.dll", | ||
| 90 | "sherpa-onnx-portaudio.dll", | 90 | "sherpa-onnx-portaudio.dll", |
| 91 | "ucd.dll", | 91 | "ucd.dll", |
| 92 | ] | 92 | ] |
| @@ -211,7 +211,7 @@ class BuildExtension(build_ext): | @@ -211,7 +211,7 @@ class BuildExtension(build_ext): | ||
| 211 | binaries = get_binaries() | 211 | binaries = get_binaries() |
| 212 | 212 | ||
| 213 | for f in binaries: | 213 | for f in binaries: |
| 214 | - suffix = "" if (".dll" in f or ".lib" in f) else suffix | 214 | + suffix = "" if ".dll" in f else suffix |
| 215 | src_file = install_dir / "bin" / (f + suffix) | 215 | src_file = install_dir / "bin" / (f + suffix) |
| 216 | if not src_file.is_file(): | 216 | if not src_file.is_file(): |
| 217 | src_file = install_dir / "lib" / (f + suffix) | 217 | src_file = install_dir / "lib" / (f + suffix) |
| 1 | function(download_kaldi_decoder) | 1 | function(download_kaldi_decoder) |
| 2 | include(FetchContent) | 2 | include(FetchContent) |
| 3 | 3 | ||
| 4 | - set(kaldi_decoder_URL "https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.5.tar.gz") | ||
| 5 | - set(kaldi_decoder_URL2 "https://hub.nuaa.cf/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.5.tar.gz") | ||
| 6 | - set(kaldi_decoder_HASH "SHA256=f663e58aef31b33cd8086eaa09ff1383628039845f31300b5abef817d8cc2fff") | 4 | + set(kaldi_decoder_URL "https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.6.tar.gz") |
| 5 | + set(kaldi_decoder_URL2 "https://hub.nuaa.cf/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.6.tar.gz") | ||
| 6 | + set(kaldi_decoder_HASH "SHA256=b13c78b37495cafc6ef3f8a7b661b349c55a51abbd7f7f42f389408dcf86a463") | ||
| 7 | 7 | ||
| 8 | set(KALDI_DECODER_BUILD_PYTHON OFF CACHE BOOL "" FORCE) | 8 | set(KALDI_DECODER_BUILD_PYTHON OFF CACHE BOOL "" FORCE) |
| 9 | set(KALDI_DECODER_ENABLE_TESTS OFF CACHE BOOL "" FORCE) | 9 | set(KALDI_DECODER_ENABLE_TESTS OFF CACHE BOOL "" FORCE) |
| @@ -12,11 +12,11 @@ function(download_kaldi_decoder) | @@ -12,11 +12,11 @@ function(download_kaldi_decoder) | ||
| 12 | # If you don't have access to the Internet, | 12 | # If you don't have access to the Internet, |
| 13 | # please pre-download kaldi-decoder | 13 | # please pre-download kaldi-decoder |
| 14 | set(possible_file_locations | 14 | set(possible_file_locations |
| 15 | - $ENV{HOME}/Downloads/kaldi-decoder-0.2.5.tar.gz | ||
| 16 | - ${CMAKE_SOURCE_DIR}/kaldi-decoder-0.2.5.tar.gz | ||
| 17 | - ${CMAKE_BINARY_DIR}/kaldi-decoder-0.2.5.tar.gz | ||
| 18 | - /tmp/kaldi-decoder-0.2.5.tar.gz | ||
| 19 | - /star-fj/fangjun/download/github/kaldi-decoder-0.2.5.tar.gz | 15 | + $ENV{HOME}/Downloads/kaldi-decoder-0.2.6.tar.gz |
| 16 | + ${CMAKE_SOURCE_DIR}/kaldi-decoder-0.2.6.tar.gz | ||
| 17 | + ${CMAKE_BINARY_DIR}/kaldi-decoder-0.2.6.tar.gz | ||
| 18 | + /tmp/kaldi-decoder-0.2.6.tar.gz | ||
| 19 | + /star-fj/fangjun/download/github/kaldi-decoder-0.2.6.tar.gz | ||
| 20 | ) | 20 | ) |
| 21 | 21 | ||
| 22 | foreach(f IN LISTS possible_file_locations) | 22 | foreach(f IN LISTS possible_file_locations) |
| 1 | function(download_kaldifst) | 1 | function(download_kaldifst) |
| 2 | include(FetchContent) | 2 | include(FetchContent) |
| 3 | 3 | ||
| 4 | - set(kaldifst_URL "https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.7.10.tar.gz") | ||
| 5 | - set(kaldifst_URL2 "https://hub.nuaa.cf/k2-fsa/kaldifst/archive/refs/tags/v1.7.10.tar.gz") | ||
| 6 | - set(kaldifst_HASH "SHA256=7f7b3173a6584a6b1987f65ae7af2ac453d66b845f875a9d31074b8d2cd0de54") | 4 | + set(kaldifst_URL "https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.7.11.tar.gz") |
| 5 | + set(kaldifst_URL2 "https://hub.nuaa.cf/k2-fsa/kaldifst/archive/refs/tags/v1.7.11.tar.gz") | ||
| 6 | + set(kaldifst_HASH "SHA256=b43b3332faa2961edc730e47995a58cd4e22ead21905d55b0c4a41375b4a525f") | ||
| 7 | 7 | ||
| 8 | # If you don't have access to the Internet, | 8 | # If you don't have access to the Internet, |
| 9 | # please pre-download kaldifst | 9 | # please pre-download kaldifst |
| 10 | set(possible_file_locations | 10 | set(possible_file_locations |
| 11 | - $ENV{HOME}/Downloads/kaldifst-1.7.10.tar.gz | ||
| 12 | - ${CMAKE_SOURCE_DIR}/kaldifst-1.7.10.tar.gz | ||
| 13 | - ${CMAKE_BINARY_DIR}/kaldifst-1.7.10.tar.gz | ||
| 14 | - /tmp/kaldifst-1.7.10.tar.gz | ||
| 15 | - /star-fj/fangjun/download/github/kaldifst-1.7.10.tar.gz | 11 | + $ENV{HOME}/Downloads/kaldifst-1.7.11.tar.gz |
| 12 | + ${CMAKE_SOURCE_DIR}/kaldifst-1.7.11.tar.gz | ||
| 13 | + ${CMAKE_BINARY_DIR}/kaldifst-1.7.11.tar.gz | ||
| 14 | + /tmp/kaldifst-1.7.11.tar.gz | ||
| 15 | + /star-fj/fangjun/download/github/kaldifst-1.7.11.tar.gz | ||
| 16 | ) | 16 | ) |
| 17 | 17 | ||
| 18 | foreach(f IN LISTS possible_file_locations) | 18 | foreach(f IN LISTS possible_file_locations) |
| @@ -51,6 +51,7 @@ function(download_kaldifst) | @@ -51,6 +51,7 @@ function(download_kaldifst) | ||
| 51 | ) | 51 | ) |
| 52 | 52 | ||
| 53 | set_target_properties(kaldifst_core PROPERTIES OUTPUT_NAME "sherpa-onnx-kaldifst-core") | 53 | set_target_properties(kaldifst_core PROPERTIES OUTPUT_NAME "sherpa-onnx-kaldifst-core") |
| 54 | + # installed in ./kaldi-decoder.cmake | ||
| 54 | endfunction() | 55 | endfunction() |
| 55 | 56 | ||
| 56 | download_kaldifst() | 57 | download_kaldifst() |
| @@ -3,18 +3,18 @@ | @@ -3,18 +3,18 @@ | ||
| 3 | function(download_openfst) | 3 | function(download_openfst) |
| 4 | include(FetchContent) | 4 | include(FetchContent) |
| 5 | 5 | ||
| 6 | - set(openfst_URL "https://github.com/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-05-22-2.tar.gz") | ||
| 7 | - set(openfst_URL2 "https://hub.nuaa.cf/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-05-22-2.tar.gz") | ||
| 8 | - set(openfst_HASH "SHA256=ec52d32ab46ac884d77c87918155ca9d0cae424095ce3bd7e3cc7eaab8235a39") | 6 | + set(openfst_URL "https://github.com/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-13.tar.gz") |
| 7 | + set(openfst_URL2 "https://hub.nuaa.cf/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-13.tar.gz") | ||
| 8 | + set(openfst_HASH "SHA256=f10a71c6b64d89eabdc316d372b956c30c825c7c298e2f20c780320e8181ffb6") | ||
| 9 | 9 | ||
| 10 | # If you don't have access to the Internet, | 10 | # If you don't have access to the Internet, |
| 11 | # please pre-download it | 11 | # please pre-download it |
| 12 | set(possible_file_locations | 12 | set(possible_file_locations |
| 13 | - $ENV{HOME}/Downloads/openfst-sherpa-onnx-2024-05-22-2.tar.gz | ||
| 14 | - ${CMAKE_SOURCE_DIR}/openfst-sherpa-onnx-2024-05-22-2.tar.gz | ||
| 15 | - ${CMAKE_BINARY_DIR}/openfst-sherpa-onnx-2024-05-22-2.tar.gz | ||
| 16 | - /tmp/openfst-sherpa-onnx-2024-05-22-2.tar.gz | ||
| 17 | - /star-fj/fangjun/download/github/openfst-sherpa-onnx-2024-05-22-2.tar.gz | 13 | + $ENV{HOME}/Downloads/openfst-sherpa-onnx-2024-06-13.tar.gz |
| 14 | + ${CMAKE_SOURCE_DIR}/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
| 15 | + ${CMAKE_BINARY_DIR}/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
| 16 | + /tmp/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
| 17 | + /star-fj/fangjun/download/github/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
| 18 | ) | 18 | ) |
| 19 | 19 | ||
| 20 | foreach(f IN LISTS possible_file_locations) | 20 | foreach(f IN LISTS possible_file_locations) |
| @@ -27,7 +27,7 @@ function(download_openfst) | @@ -27,7 +27,7 @@ function(download_openfst) | ||
| 27 | endforeach() | 27 | endforeach() |
| 28 | 28 | ||
| 29 | set(HAVE_BIN OFF CACHE BOOL "" FORCE) | 29 | set(HAVE_BIN OFF CACHE BOOL "" FORCE) |
| 30 | - set(HAVE_SCRIPT ON CACHE BOOL "" FORCE) | 30 | + set(HAVE_SCRIPT OFF CACHE BOOL "" FORCE) |
| 31 | set(HAVE_COMPACT OFF CACHE BOOL "" FORCE) | 31 | set(HAVE_COMPACT OFF CACHE BOOL "" FORCE) |
| 32 | set(HAVE_COMPRESS OFF CACHE BOOL "" FORCE) | 32 | set(HAVE_COMPRESS OFF CACHE BOOL "" FORCE) |
| 33 | set(HAVE_CONST OFF CACHE BOOL "" FORCE) | 33 | set(HAVE_CONST OFF CACHE BOOL "" FORCE) |
| @@ -70,8 +70,6 @@ function(download_openfst) | @@ -70,8 +70,6 @@ function(download_openfst) | ||
| 70 | add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL) | 70 | add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL) |
| 71 | set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE) | 71 | set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE) |
| 72 | 72 | ||
| 73 | - # Rename libfst.so.6 to libsherpa-onnx-fst.so.6 to avoid potential conflicts | ||
| 74 | - # when sherpa-onnx is installed. | ||
| 75 | set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst") | 73 | set_target_properties(fst PROPERTIES OUTPUT_NAME "sherpa-onnx-fst") |
| 76 | set_target_properties(fstfar PROPERTIES OUTPUT_NAME "sherpa-onnx-fstfar") | 74 | set_target_properties(fstfar PROPERTIES OUTPUT_NAME "sherpa-onnx-fstfar") |
| 77 | 75 |
dart-api-examples/README.md
0 → 100644
| 1 | +# Introduction | ||
| 2 | + | ||
| 3 | +This directory contains examples for Dart API. | ||
| 4 | + | ||
| 5 | +You can find the package at | ||
| 6 | +https://pub.dev/packages/sherpa_onnx | ||
| 7 | + | ||
| 8 | +## How to create an example in this folder | ||
| 9 | + | ||
| 10 | +```bash | ||
| 11 | +dart create vad | ||
| 12 | +cd vad | ||
| 13 | + | ||
| 14 | +# Edit pubspec.yaml and add sherpa_onnx to dependencies | ||
| 15 | + | ||
| 16 | +dart pub get | ||
| 17 | +dart run | ||
| 18 | +``` |
dart-api-examples/vad/.gitignore
0 → 100644
dart-api-examples/vad/CHANGELOG.md
0 → 100644
dart-api-examples/vad/README.md
0 → 100644
| 1 | +# Introduction | ||
| 2 | + | ||
| 3 | +This example shows how to use the Dart API from sherpa-onnx for voice activity detection (VAD). | ||
| 4 | +Specifically, we use VAD to remove silences from a wave file. | ||
| 5 | + | ||
| 6 | +# Usage | ||
| 7 | + | ||
| 8 | +```bash | ||
| 9 | +dart pub get | ||
| 10 | + | ||
| 11 | +wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx | ||
| 12 | +wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/lei-jun-test.wav | ||
| 13 | + | ||
| 14 | +dart run \ | ||
| 15 | + ./bin/vad.dart \ | ||
| 16 | + --silero-vad ./silero_vad.onnx \ | ||
| 17 | + --input-wav ./lei-jun-test.wav \ | ||
| 18 | + --output-wav ./lei-jun-test-no-silence.wav | ||
| 19 | +``` | ||
| 20 | + | ||
| 21 | +It should generate a file `lei-jun-test-no-silence.wav`, where silences are removed. |
dart-api-examples/vad/analysis_options.yaml
0 → 100644
| 1 | +# This file configures the static analysis results for your project (errors, | ||
| 2 | +# warnings, and lints). | ||
| 3 | +# | ||
| 4 | +# This enables the 'recommended' set of lints from `package:lints`. | ||
| 5 | +# This set helps identify many issues that may lead to problems when running | ||
| 6 | +# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
| 7 | +# style and format. | ||
| 8 | +# | ||
| 9 | +# If you want a smaller set of lints you can change this to specify | ||
| 10 | +# 'package:lints/core.yaml'. These are just the most critical lints | ||
| 11 | +# (the recommended set includes the core lints). | ||
| 12 | +# The core lints are also what is used by pub.dev for scoring packages. | ||
| 13 | + | ||
| 14 | +include: package:lints/recommended.yaml | ||
| 15 | + | ||
| 16 | +# Uncomment the following section to specify additional rules. | ||
| 17 | + | ||
| 18 | +# linter: | ||
| 19 | +# rules: | ||
| 20 | +# - camel_case_types | ||
| 21 | + | ||
| 22 | +# analyzer: | ||
| 23 | +# exclude: | ||
| 24 | +# - path/to/excluded/files/** | ||
| 25 | + | ||
| 26 | +# For more information about the core and recommended set of lints, see | ||
| 27 | +# https://dart.dev/go/core-lints | ||
| 28 | + | ||
| 29 | +# For additional information about configuring this file, see | ||
| 30 | +# https://dart.dev/guides/language/analysis-options |
dart-api-examples/vad/bin/vad.dart
0 → 100644
| 1 | +import 'dart:io'; | ||
| 2 | +import 'dart:isolate'; | ||
| 3 | +import 'dart:typed_data'; | ||
| 4 | + | ||
| 5 | +import 'package:args/args.dart'; | ||
| 6 | +import 'package:path/path.dart' as p; | ||
| 7 | +import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx; | ||
| 8 | + | ||
| 9 | +Future<void> initSherpaOnnx() async { | ||
| 10 | + var uri = await Isolate.resolvePackageUri( | ||
| 11 | + Uri.parse('package:sherpa_onnx/sherpa_onnx.dart')); | ||
| 12 | + | ||
| 13 | + if (uri == null) { | ||
| 14 | + print('File not found'); | ||
| 15 | + exit(1); | ||
| 16 | + } | ||
| 17 | + String platform = ''; | ||
| 18 | + if (Platform.isMacOS) { | ||
| 19 | + platform = 'macos'; | ||
| 20 | + } else if (Platform.isLinux) { | ||
| 21 | + platform = 'linux'; | ||
| 22 | + } else if (Platform.isWindows) { | ||
| 23 | + platform = 'windows'; | ||
| 24 | + } else { | ||
| 25 | + throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + final libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform); | ||
| 29 | + sherpa_onnx.initBindings(libPath); | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +void main(List<String> arguments) async { | ||
| 33 | + await initSherpaOnnx(); | ||
| 34 | + | ||
| 35 | + final parser = ArgParser() | ||
| 36 | + ..addOption('silero-vad', help: 'Path to silero_vad.onnx') | ||
| 37 | + ..addOption('input-wav', help: 'Path to input.wav') | ||
| 38 | + ..addOption('output-wav', help: 'Path to output.wav'); | ||
| 39 | + final res = parser.parse(arguments); | ||
| 40 | + if (res['silero-vad'] == null || | ||
| 41 | + res['input-wav'] == null || | ||
| 42 | + res['output-wav'] == null) { | ||
| 43 | + print(parser.usage); | ||
| 44 | + exit(1); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + final sileroVad = res['silero-vad'] as String; | ||
| 48 | + final inputWav = res['input-wav'] as String; | ||
| 49 | + final outputWav = res['output-wav'] as String; | ||
| 50 | + | ||
| 51 | + final sileroVadConfig = sherpa_onnx.SileroVadModelConfig( | ||
| 52 | + model: sileroVad, | ||
| 53 | + minSilenceDuration: 0.25, | ||
| 54 | + minSpeechDuration: 0.5, | ||
| 55 | + ); | ||
| 56 | + final config = sherpa_onnx.VadModelConfig( | ||
| 57 | + sileroVad: sileroVadConfig, | ||
| 58 | + numThreads: 1, | ||
| 59 | + debug: true, | ||
| 60 | + ); | ||
| 61 | + | ||
| 62 | + final vad = sherpa_onnx.VoiceActivityDetector( | ||
| 63 | + config: config, bufferSizeInSeconds: 10); | ||
| 64 | + | ||
| 65 | + final waveData = sherpa_onnx.readWave(inputWav); | ||
| 66 | + if (waveData.sampleRate != 16000) { | ||
| 67 | + print('Only 16000 Hz is supported. Given: ${waveData.sampleRate}'); | ||
| 68 | + exit(1); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + int numSamples = waveData.samples.length; | ||
| 72 | + int numIter = numSamples ~/ config.sileroVad.windowSize; | ||
| 73 | + | ||
| 74 | + List<List<double>> allSamples = []; | ||
| 75 | + | ||
| 76 | + for (int i = 0; i != numIter; ++i) { | ||
| 77 | + int start = i * config.sileroVad.windowSize; | ||
| 78 | + vad.acceptWaveform(Float32List.sublistView( | ||
| 79 | + waveData.samples, start, start + config.sileroVad.windowSize)); | ||
| 80 | + | ||
| 81 | + if (vad.isDetected()) { | ||
| 82 | + while (!vad.isEmpty()) { | ||
| 83 | + allSamples.add(vad.front().samples); | ||
| 84 | + vad.pop(); | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + final s = Float32List.fromList(allSamples.expand((x) => x).toList()); | ||
| 90 | + sherpa_onnx.writeWave( | ||
| 91 | + filename: outputWav, samples: s, sampleRate: waveData.sampleRate); | ||
| 92 | + print('Saved to ${outputWav}'); | ||
| 93 | +} |
dart-api-examples/vad/pubspec.lock
0 → 100644
| 1 | +# Generated by pub | ||
| 2 | +# See https://dart.dev/tools/pub/glossary#lockfile | ||
| 3 | +packages: | ||
| 4 | + _fe_analyzer_shared: | ||
| 5 | + dependency: transitive | ||
| 6 | + description: | ||
| 7 | + name: _fe_analyzer_shared | ||
| 8 | + sha256: "5aaf60d96c4cd00fe7f21594b5ad6a1b699c80a27420f8a837f4d68473ef09e3" | ||
| 9 | + url: "https://pub.dev" | ||
| 10 | + source: hosted | ||
| 11 | + version: "68.0.0" | ||
| 12 | + _macros: | ||
| 13 | + dependency: transitive | ||
| 14 | + description: dart | ||
| 15 | + source: sdk | ||
| 16 | + version: "0.1.0" | ||
| 17 | + analyzer: | ||
| 18 | + dependency: transitive | ||
| 19 | + description: | ||
| 20 | + name: analyzer | ||
| 21 | + sha256: "21f1d3720fd1c70316399d5e2bccaebb415c434592d778cce8acb967b8578808" | ||
| 22 | + url: "https://pub.dev" | ||
| 23 | + source: hosted | ||
| 24 | + version: "6.5.0" | ||
| 25 | + args: | ||
| 26 | + dependency: transitive | ||
| 27 | + description: | ||
| 28 | + name: args | ||
| 29 | + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" | ||
| 30 | + url: "https://pub.dev" | ||
| 31 | + source: hosted | ||
| 32 | + version: "2.5.0" | ||
| 33 | + async: | ||
| 34 | + dependency: transitive | ||
| 35 | + description: | ||
| 36 | + name: async | ||
| 37 | + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" | ||
| 38 | + url: "https://pub.dev" | ||
| 39 | + source: hosted | ||
| 40 | + version: "2.11.0" | ||
| 41 | + boolean_selector: | ||
| 42 | + dependency: transitive | ||
| 43 | + description: | ||
| 44 | + name: boolean_selector | ||
| 45 | + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" | ||
| 46 | + url: "https://pub.dev" | ||
| 47 | + source: hosted | ||
| 48 | + version: "2.1.1" | ||
| 49 | + collection: | ||
| 50 | + dependency: transitive | ||
| 51 | + description: | ||
| 52 | + name: collection | ||
| 53 | + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a | ||
| 54 | + url: "https://pub.dev" | ||
| 55 | + source: hosted | ||
| 56 | + version: "1.18.0" | ||
| 57 | + convert: | ||
| 58 | + dependency: transitive | ||
| 59 | + description: | ||
| 60 | + name: convert | ||
| 61 | + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" | ||
| 62 | + url: "https://pub.dev" | ||
| 63 | + source: hosted | ||
| 64 | + version: "3.1.1" | ||
| 65 | + coverage: | ||
| 66 | + dependency: transitive | ||
| 67 | + description: | ||
| 68 | + name: coverage | ||
| 69 | + sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e" | ||
| 70 | + url: "https://pub.dev" | ||
| 71 | + source: hosted | ||
| 72 | + version: "1.8.0" | ||
| 73 | + crypto: | ||
| 74 | + dependency: transitive | ||
| 75 | + description: | ||
| 76 | + name: crypto | ||
| 77 | + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab | ||
| 78 | + url: "https://pub.dev" | ||
| 79 | + source: hosted | ||
| 80 | + version: "3.0.3" | ||
| 81 | + file: | ||
| 82 | + dependency: transitive | ||
| 83 | + description: | ||
| 84 | + name: file | ||
| 85 | + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" | ||
| 86 | + url: "https://pub.dev" | ||
| 87 | + source: hosted | ||
| 88 | + version: "7.0.0" | ||
| 89 | + frontend_server_client: | ||
| 90 | + dependency: transitive | ||
| 91 | + description: | ||
| 92 | + name: frontend_server_client | ||
| 93 | + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 | ||
| 94 | + url: "https://pub.dev" | ||
| 95 | + source: hosted | ||
| 96 | + version: "4.0.0" | ||
| 97 | + glob: | ||
| 98 | + dependency: transitive | ||
| 99 | + description: | ||
| 100 | + name: glob | ||
| 101 | + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" | ||
| 102 | + url: "https://pub.dev" | ||
| 103 | + source: hosted | ||
| 104 | + version: "2.1.2" | ||
| 105 | + http_multi_server: | ||
| 106 | + dependency: transitive | ||
| 107 | + description: | ||
| 108 | + name: http_multi_server | ||
| 109 | + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" | ||
| 110 | + url: "https://pub.dev" | ||
| 111 | + source: hosted | ||
| 112 | + version: "3.2.1" | ||
| 113 | + http_parser: | ||
| 114 | + dependency: transitive | ||
| 115 | + description: | ||
| 116 | + name: http_parser | ||
| 117 | + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" | ||
| 118 | + url: "https://pub.dev" | ||
| 119 | + source: hosted | ||
| 120 | + version: "4.0.2" | ||
| 121 | + io: | ||
| 122 | + dependency: transitive | ||
| 123 | + description: | ||
| 124 | + name: io | ||
| 125 | + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" | ||
| 126 | + url: "https://pub.dev" | ||
| 127 | + source: hosted | ||
| 128 | + version: "1.0.4" | ||
| 129 | + js: | ||
| 130 | + dependency: transitive | ||
| 131 | + description: | ||
| 132 | + name: js | ||
| 133 | + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf | ||
| 134 | + url: "https://pub.dev" | ||
| 135 | + source: hosted | ||
| 136 | + version: "0.7.1" | ||
| 137 | + lints: | ||
| 138 | + dependency: "direct dev" | ||
| 139 | + description: | ||
| 140 | + name: lints | ||
| 141 | + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 | ||
| 142 | + url: "https://pub.dev" | ||
| 143 | + source: hosted | ||
| 144 | + version: "3.0.0" | ||
| 145 | + logging: | ||
| 146 | + dependency: transitive | ||
| 147 | + description: | ||
| 148 | + name: logging | ||
| 149 | + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" | ||
| 150 | + url: "https://pub.dev" | ||
| 151 | + source: hosted | ||
| 152 | + version: "1.2.0" | ||
| 153 | + macros: | ||
| 154 | + dependency: transitive | ||
| 155 | + description: | ||
| 156 | + name: macros | ||
| 157 | + sha256: "12e8a9842b5a7390de7a781ec63d793527582398d16ea26c60fed58833c9ae79" | ||
| 158 | + url: "https://pub.dev" | ||
| 159 | + source: hosted | ||
| 160 | + version: "0.1.0-main.0" | ||
| 161 | + matcher: | ||
| 162 | + dependency: transitive | ||
| 163 | + description: | ||
| 164 | + name: matcher | ||
| 165 | + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb | ||
| 166 | + url: "https://pub.dev" | ||
| 167 | + source: hosted | ||
| 168 | + version: "0.12.16+1" | ||
| 169 | + meta: | ||
| 170 | + dependency: transitive | ||
| 171 | + description: | ||
| 172 | + name: meta | ||
| 173 | + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 | ||
| 174 | + url: "https://pub.dev" | ||
| 175 | + source: hosted | ||
| 176 | + version: "1.15.0" | ||
| 177 | + mime: | ||
| 178 | + dependency: transitive | ||
| 179 | + description: | ||
| 180 | + name: mime | ||
| 181 | + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" | ||
| 182 | + url: "https://pub.dev" | ||
| 183 | + source: hosted | ||
| 184 | + version: "1.0.5" | ||
| 185 | + node_preamble: | ||
| 186 | + dependency: transitive | ||
| 187 | + description: | ||
| 188 | + name: node_preamble | ||
| 189 | + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" | ||
| 190 | + url: "https://pub.dev" | ||
| 191 | + source: hosted | ||
| 192 | + version: "2.0.2" | ||
| 193 | + package_config: | ||
| 194 | + dependency: transitive | ||
| 195 | + description: | ||
| 196 | + name: package_config | ||
| 197 | + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" | ||
| 198 | + url: "https://pub.dev" | ||
| 199 | + source: hosted | ||
| 200 | + version: "2.1.0" | ||
| 201 | + path: | ||
| 202 | + dependency: transitive | ||
| 203 | + description: | ||
| 204 | + name: path | ||
| 205 | + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" | ||
| 206 | + url: "https://pub.dev" | ||
| 207 | + source: hosted | ||
| 208 | + version: "1.9.0" | ||
| 209 | + pool: | ||
| 210 | + dependency: transitive | ||
| 211 | + description: | ||
| 212 | + name: pool | ||
| 213 | + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" | ||
| 214 | + url: "https://pub.dev" | ||
| 215 | + source: hosted | ||
| 216 | + version: "1.5.1" | ||
| 217 | + pub_semver: | ||
| 218 | + dependency: transitive | ||
| 219 | + description: | ||
| 220 | + name: pub_semver | ||
| 221 | + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" | ||
| 222 | + url: "https://pub.dev" | ||
| 223 | + source: hosted | ||
| 224 | + version: "2.1.4" | ||
| 225 | + shelf: | ||
| 226 | + dependency: transitive | ||
| 227 | + description: | ||
| 228 | + name: shelf | ||
| 229 | + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 | ||
| 230 | + url: "https://pub.dev" | ||
| 231 | + source: hosted | ||
| 232 | + version: "1.4.1" | ||
| 233 | + shelf_packages_handler: | ||
| 234 | + dependency: transitive | ||
| 235 | + description: | ||
| 236 | + name: shelf_packages_handler | ||
| 237 | + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" | ||
| 238 | + url: "https://pub.dev" | ||
| 239 | + source: hosted | ||
| 240 | + version: "3.0.2" | ||
| 241 | + shelf_static: | ||
| 242 | + dependency: transitive | ||
| 243 | + description: | ||
| 244 | + name: shelf_static | ||
| 245 | + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e | ||
| 246 | + url: "https://pub.dev" | ||
| 247 | + source: hosted | ||
| 248 | + version: "1.1.2" | ||
| 249 | + shelf_web_socket: | ||
| 250 | + dependency: transitive | ||
| 251 | + description: | ||
| 252 | + name: shelf_web_socket | ||
| 253 | + sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" | ||
| 254 | + url: "https://pub.dev" | ||
| 255 | + source: hosted | ||
| 256 | + version: "2.0.0" | ||
| 257 | + source_map_stack_trace: | ||
| 258 | + dependency: transitive | ||
| 259 | + description: | ||
| 260 | + name: source_map_stack_trace | ||
| 261 | + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" | ||
| 262 | + url: "https://pub.dev" | ||
| 263 | + source: hosted | ||
| 264 | + version: "2.1.1" | ||
| 265 | + source_maps: | ||
| 266 | + dependency: transitive | ||
| 267 | + description: | ||
| 268 | + name: source_maps | ||
| 269 | + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" | ||
| 270 | + url: "https://pub.dev" | ||
| 271 | + source: hosted | ||
| 272 | + version: "0.10.12" | ||
| 273 | + source_span: | ||
| 274 | + dependency: transitive | ||
| 275 | + description: | ||
| 276 | + name: source_span | ||
| 277 | + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" | ||
| 278 | + url: "https://pub.dev" | ||
| 279 | + source: hosted | ||
| 280 | + version: "1.10.0" | ||
| 281 | + stack_trace: | ||
| 282 | + dependency: transitive | ||
| 283 | + description: | ||
| 284 | + name: stack_trace | ||
| 285 | + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" | ||
| 286 | + url: "https://pub.dev" | ||
| 287 | + source: hosted | ||
| 288 | + version: "1.11.1" | ||
| 289 | + stream_channel: | ||
| 290 | + dependency: transitive | ||
| 291 | + description: | ||
| 292 | + name: stream_channel | ||
| 293 | + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 | ||
| 294 | + url: "https://pub.dev" | ||
| 295 | + source: hosted | ||
| 296 | + version: "2.1.2" | ||
| 297 | + string_scanner: | ||
| 298 | + dependency: transitive | ||
| 299 | + description: | ||
| 300 | + name: string_scanner | ||
| 301 | + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" | ||
| 302 | + url: "https://pub.dev" | ||
| 303 | + source: hosted | ||
| 304 | + version: "1.2.0" | ||
| 305 | + term_glyph: | ||
| 306 | + dependency: transitive | ||
| 307 | + description: | ||
| 308 | + name: term_glyph | ||
| 309 | + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 | ||
| 310 | + url: "https://pub.dev" | ||
| 311 | + source: hosted | ||
| 312 | + version: "1.2.1" | ||
| 313 | + test: | ||
| 314 | + dependency: "direct dev" | ||
| 315 | + description: | ||
| 316 | + name: test | ||
| 317 | + sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" | ||
| 318 | + url: "https://pub.dev" | ||
| 319 | + source: hosted | ||
| 320 | + version: "1.25.7" | ||
| 321 | + test_api: | ||
| 322 | + dependency: transitive | ||
| 323 | + description: | ||
| 324 | + name: test_api | ||
| 325 | + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" | ||
| 326 | + url: "https://pub.dev" | ||
| 327 | + source: hosted | ||
| 328 | + version: "0.7.2" | ||
| 329 | + test_core: | ||
| 330 | + dependency: transitive | ||
| 331 | + description: | ||
| 332 | + name: test_core | ||
| 333 | + sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" | ||
| 334 | + url: "https://pub.dev" | ||
| 335 | + source: hosted | ||
| 336 | + version: "0.6.4" | ||
| 337 | + typed_data: | ||
| 338 | + dependency: transitive | ||
| 339 | + description: | ||
| 340 | + name: typed_data | ||
| 341 | + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c | ||
| 342 | + url: "https://pub.dev" | ||
| 343 | + source: hosted | ||
| 344 | + version: "1.3.2" | ||
| 345 | + vm_service: | ||
| 346 | + dependency: transitive | ||
| 347 | + description: | ||
| 348 | + name: vm_service | ||
| 349 | + sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a" | ||
| 350 | + url: "https://pub.dev" | ||
| 351 | + source: hosted | ||
| 352 | + version: "14.2.3" | ||
| 353 | + watcher: | ||
| 354 | + dependency: transitive | ||
| 355 | + description: | ||
| 356 | + name: watcher | ||
| 357 | + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" | ||
| 358 | + url: "https://pub.dev" | ||
| 359 | + source: hosted | ||
| 360 | + version: "1.1.0" | ||
| 361 | + web: | ||
| 362 | + dependency: transitive | ||
| 363 | + description: | ||
| 364 | + name: web | ||
| 365 | + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" | ||
| 366 | + url: "https://pub.dev" | ||
| 367 | + source: hosted | ||
| 368 | + version: "0.5.1" | ||
| 369 | + web_socket: | ||
| 370 | + dependency: transitive | ||
| 371 | + description: | ||
| 372 | + name: web_socket | ||
| 373 | + sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078" | ||
| 374 | + url: "https://pub.dev" | ||
| 375 | + source: hosted | ||
| 376 | + version: "0.1.5" | ||
| 377 | + web_socket_channel: | ||
| 378 | + dependency: transitive | ||
| 379 | + description: | ||
| 380 | + name: web_socket_channel | ||
| 381 | + sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276 | ||
| 382 | + url: "https://pub.dev" | ||
| 383 | + source: hosted | ||
| 384 | + version: "3.0.0" | ||
| 385 | + webkit_inspection_protocol: | ||
| 386 | + dependency: transitive | ||
| 387 | + description: | ||
| 388 | + name: webkit_inspection_protocol | ||
| 389 | + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" | ||
| 390 | + url: "https://pub.dev" | ||
| 391 | + source: hosted | ||
| 392 | + version: "1.2.1" | ||
| 393 | + yaml: | ||
| 394 | + dependency: transitive | ||
| 395 | + description: | ||
| 396 | + name: yaml | ||
| 397 | + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" | ||
| 398 | + url: "https://pub.dev" | ||
| 399 | + source: hosted | ||
| 400 | + version: "3.1.2" | ||
| 401 | +sdks: | ||
| 402 | + dart: ">=3.4.0 <4.0.0" |
dart-api-examples/vad/pubspec.yaml
0 → 100644
| 1 | +name: vad | ||
| 2 | + | ||
| 3 | +description: > | ||
| 4 | + This example demonstrates how to use the Dart API for VAD (voice activity detection). | ||
| 5 | + | ||
| 6 | +version: 1.0.0 | ||
| 7 | + | ||
| 8 | +environment: | ||
| 9 | + sdk: ^3.4.0 | ||
| 10 | + | ||
| 11 | +dependencies: | ||
| 12 | + sherpa_onnx: ^0.0.3 | ||
| 13 | + path: ^1.9.0 | ||
| 14 | + args: ^2.5.0 | ||
| 15 | + | ||
| 16 | +dev_dependencies: | ||
| 17 | + lints: ^3.0.0 |
dart-api-examples/vad/run.sh
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -ex | ||
| 4 | + | ||
| 5 | +dart pub get | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +if [[ ! -f ./silero_vad.onnx ]]; then | ||
| 9 | + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx | ||
| 10 | +fi | ||
| 11 | + | ||
| 12 | +if [[ ! -f ./lei-jun-test.wav ]]; then | ||
| 13 | + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/lei-jun-test.wav | ||
| 14 | +fi | ||
| 15 | + | ||
| 16 | +dart run \ | ||
| 17 | + ./bin/vad.dart \ | ||
| 18 | + --silero-vad ./silero_vad.onnx \ | ||
| 19 | + --input-wav ./lei-jun-test.wav \ | ||
| 20 | + --output-wav ./lei-jun-test-no-silence.wav | ||
| 21 | + | ||
| 22 | +ls -lh *.wav |
| @@ -104,9 +104,9 @@ def process_windows(s, rid): | @@ -104,9 +104,9 @@ def process_windows(s, rid): | ||
| 104 | "piper_phonemize.dll", | 104 | "piper_phonemize.dll", |
| 105 | "sherpa-onnx-c-api.dll", | 105 | "sherpa-onnx-c-api.dll", |
| 106 | "sherpa-onnx-core.dll", | 106 | "sherpa-onnx-core.dll", |
| 107 | - "sherpa-onnx-fstfar.lib", | ||
| 108 | - "sherpa-onnx-fst.lib", | ||
| 109 | - "sherpa-onnx-kaldifst-core.lib", | 107 | + "sherpa-onnx-fstfar.dll", |
| 108 | + "sherpa-onnx-fst.dll", | ||
| 109 | + "sherpa-onnx-kaldifst-core.dll", | ||
| 110 | "ucd.dll", | 110 | "ucd.dll", |
| 111 | ] | 111 | ] |
| 112 | 112 |
| @@ -30,7 +30,7 @@ mkdir -p linux macos windows-x64 windows-x86 | @@ -30,7 +30,7 @@ mkdir -p linux macos windows-x64 windows-x86 | ||
| 30 | linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | 30 | linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| 31 | linux_wheel=$src_dir/$linux_wheel_filename | 31 | linux_wheel=$src_dir/$linux_wheel_filename |
| 32 | 32 | ||
| 33 | -macos_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-macosx_11_0_universal2.whl | 33 | +macos_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_universal2.whl |
| 34 | macos_wheel=$src_dir/$macos_wheel_filename | 34 | macos_wheel=$src_dir/$macos_wheel_filename |
| 35 | 35 | ||
| 36 | windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl | 36 | windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl |
sherpa-onnx/flutter/CHANGELOG.md
0 → 100644
| @@ -14,24 +14,40 @@ export 'src/wave_writer.dart'; | @@ -14,24 +14,40 @@ export 'src/wave_writer.dart'; | ||
| 14 | 14 | ||
| 15 | import 'src/sherpa_onnx_bindings.dart'; | 15 | import 'src/sherpa_onnx_bindings.dart'; |
| 16 | 16 | ||
| 17 | +String? _path; | ||
| 18 | + | ||
| 17 | final DynamicLibrary _dylib = () { | 19 | final DynamicLibrary _dylib = () { |
| 18 | if (Platform.isIOS) { | 20 | if (Platform.isIOS) { |
| 19 | throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); | 21 | throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); |
| 20 | } | 22 | } |
| 21 | if (Platform.isMacOS) { | 23 | if (Platform.isMacOS) { |
| 24 | + if (_path == null) { | ||
| 22 | return DynamicLibrary.open('libsherpa-onnx-c-api.dylib'); | 25 | return DynamicLibrary.open('libsherpa-onnx-c-api.dylib'); |
| 26 | + } else { | ||
| 27 | + return DynamicLibrary.open('${_path}/libsherpa-onnx-c-api.dylib'); | ||
| 28 | + } | ||
| 23 | } | 29 | } |
| 30 | + | ||
| 24 | if (Platform.isAndroid || Platform.isLinux) { | 31 | if (Platform.isAndroid || Platform.isLinux) { |
| 32 | + if (_path == null) { | ||
| 25 | return DynamicLibrary.open('libsherpa-onnx-c-api.so'); | 33 | return DynamicLibrary.open('libsherpa-onnx-c-api.so'); |
| 34 | + } else { | ||
| 35 | + return DynamicLibrary.open('${_path}/libsherpa-onnx-c-api.so'); | ||
| 36 | + } | ||
| 26 | } | 37 | } |
| 27 | 38 | ||
| 28 | if (Platform.isWindows) { | 39 | if (Platform.isWindows) { |
| 40 | + if (_path == null) { | ||
| 29 | return DynamicLibrary.open('sherpa-onnx-c-api.dll'); | 41 | return DynamicLibrary.open('sherpa-onnx-c-api.dll'); |
| 42 | + } else { | ||
| 43 | + return DynamicLibrary.open('${_path}\\sherpa-onnx-c-api.dll'); | ||
| 44 | + } | ||
| 30 | } | 45 | } |
| 31 | 46 | ||
| 32 | throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); | 47 | throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); |
| 33 | }(); | 48 | }(); |
| 34 | 49 | ||
| 35 | -void initBindings() { | 50 | +void initBindings([String? p]) { |
| 51 | + _path ??= p; | ||
| 36 | SherpaOnnxBindings.init(_dylib); | 52 | SherpaOnnxBindings.init(_dylib); |
| 37 | } | 53 | } |
| 1 | // Copyright (c) 2024 Xiaomi Corporation | 1 | // Copyright (c) 2024 Xiaomi Corporation |
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; |
| 3 | import 'dart:ffi'; | 3 | import 'dart:ffi'; |
| 4 | -import 'dart:typed_data'; | ||
| 5 | 4 | ||
| 6 | import 'package:ffi/ffi.dart'; | 5 | import 'package:ffi/ffi.dart'; |
| 7 | 6 | ||
| @@ -262,7 +261,7 @@ class OfflineRecognizer { | @@ -262,7 +261,7 @@ class OfflineRecognizer { | ||
| 262 | final json = | 261 | final json = |
| 263 | SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ?? | 262 | SherpaOnnxBindings.getOfflineStreamResultAsJson?.call(stream.ptr) ?? |
| 264 | nullptr; | 263 | nullptr; |
| 265 | - if (json == null) { | 264 | + if (json == nullptr) { |
| 266 | return OfflineRecognizerResult(text: '', tokens: [], timestamps: []); | 265 | return OfflineRecognizerResult(text: '', tokens: [], timestamps: []); |
| 267 | } | 266 | } |
| 268 | 267 |
| @@ -28,7 +28,7 @@ class OfflineStream { | @@ -28,7 +28,7 @@ class OfflineStream { | ||
| 28 | final pList = p.asTypedList(n); | 28 | final pList = p.asTypedList(n); |
| 29 | pList.setAll(0, samples); | 29 | pList.setAll(0, samples); |
| 30 | 30 | ||
| 31 | - SherpaOnnxBindings.acceptWaveformOffline?.call(this.ptr, sampleRate, p, n); | 31 | + SherpaOnnxBindings.acceptWaveformOffline?.call(ptr, sampleRate, p, n); |
| 32 | 32 | ||
| 33 | calloc.free(p); | 33 | calloc.free(p); |
| 34 | } | 34 | } |
| 1 | // Copyright (c) 2024 Xiaomi Corporation | 1 | // Copyright (c) 2024 Xiaomi Corporation |
| 2 | import 'dart:convert'; | 2 | import 'dart:convert'; |
| 3 | import 'dart:ffi'; | 3 | import 'dart:ffi'; |
| 4 | -import 'dart:typed_data'; | ||
| 5 | 4 | ||
| 6 | import 'package:ffi/ffi.dart'; | 5 | import 'package:ffi/ffi.dart'; |
| 7 | 6 | ||
| @@ -247,7 +246,7 @@ class OnlineRecognizer { | @@ -247,7 +246,7 @@ class OnlineRecognizer { | ||
| 247 | final json = | 246 | final json = |
| 248 | SherpaOnnxBindings.getOnlineStreamResultAsJson?.call(ptr, stream.ptr) ?? | 247 | SherpaOnnxBindings.getOnlineStreamResultAsJson?.call(ptr, stream.ptr) ?? |
| 249 | nullptr; | 248 | nullptr; |
| 250 | - if (json == null) { | 249 | + if (json == nullptr) { |
| 251 | return OnlineRecognizerResult(text: '', tokens: [], timestamps: []); | 250 | return OnlineRecognizerResult(text: '', tokens: [], timestamps: []); |
| 252 | } | 251 | } |
| 253 | 252 |
| @@ -28,8 +28,7 @@ class OnlineStream { | @@ -28,8 +28,7 @@ class OnlineStream { | ||
| 28 | final pList = p.asTypedList(n); | 28 | final pList = p.asTypedList(n); |
| 29 | pList.setAll(0, samples); | 29 | pList.setAll(0, samples); |
| 30 | 30 | ||
| 31 | - SherpaOnnxBindings.onlineStreamAcceptWaveform | ||
| 32 | - ?.call(this.ptr, sampleRate, p, n); | 31 | + SherpaOnnxBindings.onlineStreamAcceptWaveform?.call(ptr, sampleRate, p, n); |
| 33 | 32 | ||
| 34 | calloc.free(p); | 33 | calloc.free(p); |
| 35 | } | 34 | } |
| @@ -553,13 +553,10 @@ typedef DestroyOnlineStreamNative = Void Function( | @@ -553,13 +553,10 @@ typedef DestroyOnlineStreamNative = Void Function( | ||
| 553 | typedef DestroyOnlineStream = void Function(Pointer<SherpaOnnxOnlineStream>); | 553 | typedef DestroyOnlineStream = void Function(Pointer<SherpaOnnxOnlineStream>); |
| 554 | 554 | ||
| 555 | typedef OnlineStreamAcceptWaveformNative = Void Function( | 555 | typedef OnlineStreamAcceptWaveformNative = Void Function( |
| 556 | - Pointer<SherpaOnnxOnlineStream>, | ||
| 557 | - Int32 sample_rate, | ||
| 558 | - Pointer<Float>, | ||
| 559 | - Int32 n); | 556 | + Pointer<SherpaOnnxOnlineStream>, Int32, Pointer<Float>, Int32); |
| 560 | 557 | ||
| 561 | typedef OnlineStreamAcceptWaveform = void Function( | 558 | typedef OnlineStreamAcceptWaveform = void Function( |
| 562 | - Pointer<SherpaOnnxOnlineStream>, int sample_rate, Pointer<Float>, int n); | 559 | + Pointer<SherpaOnnxOnlineStream>, int, Pointer<Float>, int); |
| 563 | 560 | ||
| 564 | typedef OnlineStreamInputFinishedNative = Void Function( | 561 | typedef OnlineStreamInputFinishedNative = Void Function( |
| 565 | Pointer<SherpaOnnxOnlineStream>); | 562 | Pointer<SherpaOnnxOnlineStream>); |
| @@ -106,8 +106,8 @@ class CircularBuffer { | @@ -106,8 +106,8 @@ class CircularBuffer { | ||
| 106 | SherpaOnnxBindings.circularBufferReset?.call(this.ptr); | 106 | SherpaOnnxBindings.circularBufferReset?.call(this.ptr); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | - int get size => SherpaOnnxBindings.circularBufferSize?.call(this.ptr) ?? 0; | ||
| 110 | - int get head => SherpaOnnxBindings.circularBufferHead?.call(this.ptr) ?? 0; | 109 | + int get size => SherpaOnnxBindings.circularBufferSize?.call(ptr) ?? 0; |
| 110 | + int get head => SherpaOnnxBindings.circularBufferHead?.call(ptr) ?? 0; | ||
| 111 | 111 | ||
| 112 | Pointer<SherpaOnnxCircularBuffer> ptr; | 112 | Pointer<SherpaOnnxCircularBuffer> ptr; |
| 113 | } | 113 | } |
| @@ -159,38 +159,36 @@ class VoiceActivityDetector { | @@ -159,38 +159,36 @@ class VoiceActivityDetector { | ||
| 159 | final pList = p.asTypedList(n); | 159 | final pList = p.asTypedList(n); |
| 160 | pList.setAll(0, samples); | 160 | pList.setAll(0, samples); |
| 161 | 161 | ||
| 162 | - SherpaOnnxBindings.voiceActivityDetectorAcceptWaveform | ||
| 163 | - ?.call(this.ptr, p, n); | 162 | + SherpaOnnxBindings.voiceActivityDetectorAcceptWaveform?.call(ptr, p, n); |
| 164 | 163 | ||
| 165 | calloc.free(p); | 164 | calloc.free(p); |
| 166 | } | 165 | } |
| 167 | 166 | ||
| 168 | bool isEmpty() { | 167 | bool isEmpty() { |
| 169 | final int empty = | 168 | final int empty = |
| 170 | - SherpaOnnxBindings.voiceActivityDetectorEmpty?.call(this.ptr) ?? 0; | 169 | + SherpaOnnxBindings.voiceActivityDetectorEmpty?.call(ptr) ?? 0; |
| 171 | 170 | ||
| 172 | return empty == 1; | 171 | return empty == 1; |
| 173 | } | 172 | } |
| 174 | 173 | ||
| 175 | bool isDetected() { | 174 | bool isDetected() { |
| 176 | final int detected = | 175 | final int detected = |
| 177 | - SherpaOnnxBindings.voiceActivityDetectorDetected?.call(this.ptr) ?? 0; | 176 | + SherpaOnnxBindings.voiceActivityDetectorDetected?.call(ptr) ?? 0; |
| 178 | 177 | ||
| 179 | return detected == 1; | 178 | return detected == 1; |
| 180 | } | 179 | } |
| 181 | 180 | ||
| 182 | void pop() { | 181 | void pop() { |
| 183 | - SherpaOnnxBindings.voiceActivityDetectorPop?.call(this.ptr); | 182 | + SherpaOnnxBindings.voiceActivityDetectorPop?.call(ptr); |
| 184 | } | 183 | } |
| 185 | 184 | ||
| 186 | void clear() { | 185 | void clear() { |
| 187 | - SherpaOnnxBindings.voiceActivityDetectorClear?.call(this.ptr); | 186 | + SherpaOnnxBindings.voiceActivityDetectorClear?.call(ptr); |
| 188 | } | 187 | } |
| 189 | 188 | ||
| 190 | SpeechSegment front() { | 189 | SpeechSegment front() { |
| 191 | final Pointer<SherpaOnnxSpeechSegment> segment = | 190 | final Pointer<SherpaOnnxSpeechSegment> segment = |
| 192 | - SherpaOnnxBindings.voiceActivityDetectorFront?.call(this.ptr) ?? | ||
| 193 | - nullptr; | 191 | + SherpaOnnxBindings.voiceActivityDetectorFront?.call(ptr) ?? nullptr; |
| 194 | if (segment == nullptr) { | 192 | if (segment == nullptr) { |
| 195 | return SpeechSegment(samples: Float32List(0), start: 0); | 193 | return SpeechSegment(samples: Float32List(0), start: 0); |
| 196 | } | 194 | } |
| @@ -206,7 +204,7 @@ class VoiceActivityDetector { | @@ -206,7 +204,7 @@ class VoiceActivityDetector { | ||
| 206 | } | 204 | } |
| 207 | 205 | ||
| 208 | void reset() { | 206 | void reset() { |
| 209 | - SherpaOnnxBindings.voiceActivityDetectorReset?.call(this.ptr); | 207 | + SherpaOnnxBindings.voiceActivityDetectorReset?.call(ptr); |
| 210 | } | 208 | } |
| 211 | 209 | ||
| 212 | Pointer<SherpaOnnxVoiceActivityDetector> ptr; | 210 | Pointer<SherpaOnnxVoiceActivityDetector> ptr; |
| @@ -43,3 +43,20 @@ dart analyze | @@ -43,3 +43,20 @@ dart analyze | ||
| 43 | FLUTTER_XCODE_ARCHS=arm64 | 43 | FLUTTER_XCODE_ARCHS=arm64 |
| 44 | FLUTTER_XCODE_ARCHS=x86_64 | 44 | FLUTTER_XCODE_ARCHS=x86_64 |
| 45 | ``` | 45 | ``` |
| 46 | + | ||
| 47 | +## Examples | ||
| 48 | + | ||
| 49 | + - https://dart.dev/tools/pub/automated-publishing | ||
| 50 | + | ||
| 51 | + Use GitHub actions to publish | ||
| 52 | + | ||
| 53 | + - https://dart.dev/tools/pub/pubspec | ||
| 54 | + | ||
| 55 | + It describes the format of ./pubspec.yaml | ||
| 56 | + | ||
| 57 | + - https://github.com/folksable/blurhash_ffi/ | ||
| 58 | + | ||
| 59 | + It supports ios, android, linux, macos, and windows. | ||
| 60 | + | ||
| 61 | + - https://github.com/alexmercerind/dart_vlc | ||
| 62 | + - https://github.com/dart-lang/native/tree/main/pkgs/jni |
| 1 | name: sherpa_onnx | 1 | name: sherpa_onnx |
| 2 | + | ||
| 2 | description: > | 3 | description: > |
| 3 | - Dart bindings for sherpa-onnx. | ||
| 4 | -repository: https://github.com/k2-fsa/sherpa-onnx/tree/main/sherpa-onnx/flutter | 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 | + | ||
| 5 | topics: | 12 | topics: |
| 6 | - - speech-to-text | ||
| 7 | - - text-to-speech | 13 | + - speech-recognition |
| 14 | + - speech-synthesis | ||
| 8 | - speaker-identification | 15 | - speaker-identification |
| 9 | - - spoken-language-identification | ||
| 10 | - audio-tagging | 16 | - audio-tagging |
| 11 | - voice-activity-detection | 17 | - voice-activity-detection |
| 12 | 18 | ||
| 13 | # remember to change the version in macos/sherpa_onnx.podspec | 19 | # remember to change the version in macos/sherpa_onnx.podspec |
| 14 | -version: 0.0.1 | 20 | +version: 0.0.2 |
| 21 | + | ||
| 15 | homepage: https://github.com/k2-fsa/sherpa-onnx | 22 | homepage: https://github.com/k2-fsa/sherpa-onnx |
| 16 | 23 | ||
| 17 | environment: | 24 | environment: |
| @@ -22,30 +29,14 @@ dependencies: | @@ -22,30 +29,14 @@ dependencies: | ||
| 22 | ffi: ^2.1.0 | 29 | ffi: ^2.1.0 |
| 23 | flutter: | 30 | flutter: |
| 24 | sdk: flutter | 31 | sdk: flutter |
| 25 | - plugin_platform_interface: ^2.0.2 | ||
| 26 | 32 | ||
| 27 | dev_dependencies: | 33 | dev_dependencies: |
| 28 | flutter_test: | 34 | flutter_test: |
| 29 | sdk: flutter | 35 | sdk: flutter |
| 30 | flutter_lints: ^3.0.0 | 36 | flutter_lints: ^3.0.0 |
| 31 | 37 | ||
| 32 | -# For information on the generic Dart part of this file, see the | ||
| 33 | -# following page: https://dart.dev/tools/pub/pubspec | ||
| 34 | - | ||
| 35 | # The following section is specific to Flutter packages. | 38 | # The following section is specific to Flutter packages. |
| 36 | flutter: | 39 | flutter: |
| 37 | - # This section identifies this Flutter project as a plugin project. | ||
| 38 | - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) | ||
| 39 | - # which should be registered in the plugin registry. This is required for | ||
| 40 | - # using method channels. | ||
| 41 | - # The Android 'package' specifies package in which the registered class is. | ||
| 42 | - # This is required for using method channels on Android. | ||
| 43 | - # The 'ffiPlugin' specifies that native code should be built and bundled. | ||
| 44 | - # This is required for using `dart:ffi`. | ||
| 45 | - # All these are used by the tooling to maintain consistency when | ||
| 46 | - # adding or updating assets for this project. | ||
| 47 | - # | ||
| 48 | - # Please refer to README.md for a detailed explanation. | ||
| 49 | plugin: | 40 | plugin: |
| 50 | platforms: | 41 | platforms: |
| 51 | macos: | 42 | macos: |
| @@ -54,34 +45,3 @@ flutter: | @@ -54,34 +45,3 @@ flutter: | ||
| 54 | ffiPlugin: true | 45 | ffiPlugin: true |
| 55 | linux: | 46 | linux: |
| 56 | ffiPlugin: true | 47 | ffiPlugin: true |
| 57 | - | ||
| 58 | - # To add assets to your plugin package, add an assets section, like this: | ||
| 59 | - # assets: | ||
| 60 | - # - images/a_dot_burr.jpeg | ||
| 61 | - # - images/a_dot_ham.jpeg | ||
| 62 | - # | ||
| 63 | - # For details regarding assets in packages, see | ||
| 64 | - # https://flutter.dev/assets-and-images/#from-packages | ||
| 65 | - # | ||
| 66 | - # An image asset can refer to one or more resolution-specific "variants", see | ||
| 67 | - # https://flutter.dev/assets-and-images/#resolution-aware | ||
| 68 | - | ||
| 69 | - # To add custom fonts to your plugin package, add a fonts section here, | ||
| 70 | - # in this "flutter" section. Each entry in this list should have a | ||
| 71 | - # "family" key with the font family name, and a "fonts" key with a | ||
| 72 | - # list giving the asset and other descriptors for the font. For | ||
| 73 | - # example: | ||
| 74 | - # fonts: | ||
| 75 | - # - family: Schyler | ||
| 76 | - # fonts: | ||
| 77 | - # - asset: fonts/Schyler-Regular.ttf | ||
| 78 | - # - asset: fonts/Schyler-Italic.ttf | ||
| 79 | - # style: italic | ||
| 80 | - # - family: Trajan Pro | ||
| 81 | - # fonts: | ||
| 82 | - # - asset: fonts/TrajanPro.ttf | ||
| 83 | - # - asset: fonts/TrajanPro_Bold.ttf | ||
| 84 | - # weight: 700 | ||
| 85 | - # | ||
| 86 | - # For details regarding fonts in packages, see | ||
| 87 | - # https://flutter.dev/custom-fonts/#from-packages |
| @@ -19,9 +19,9 @@ set(sherpa_onnx_bundled_libraries | @@ -19,9 +19,9 @@ set(sherpa_onnx_bundled_libraries | ||
| 19 | "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll" | 19 | "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-c-api.dll" |
| 20 | "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-core.dll" | 20 | "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-core.dll" |
| 21 | "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-decoder-core.dll" | 21 | "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-decoder-core.dll" |
| 22 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-kaldifst-core.lib" | ||
| 23 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fstfar.lib" | ||
| 24 | - "${CMAKE_CURRENT_SOURCE_DIR}/sherpa-onnx-fst.lib" | 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" | 25 | "${CMAKE_CURRENT_SOURCE_DIR}/kaldi-native-fbank-core.dll" |
| 26 | "${CMAKE_CURRENT_SOURCE_DIR}/piper_phonemize.dll" | 26 | "${CMAKE_CURRENT_SOURCE_DIR}/piper_phonemize.dll" |
| 27 | "${CMAKE_CURRENT_SOURCE_DIR}/espeak-ng.dll" | 27 | "${CMAKE_CURRENT_SOURCE_DIR}/espeak-ng.dll" |
-
请 注册 或 登录 后发表评论