Committed by
GitHub
Add non-streaming ONNX models for Russian ASR (#1358)
正在显示
6 个修改的文件
包含
228 行增加
和
15 行删除
| @@ -16,6 +16,46 @@ echo "PATH: $PATH" | @@ -16,6 +16,46 @@ echo "PATH: $PATH" | ||
| 16 | which $EXE | 16 | which $EXE |
| 17 | 17 | ||
| 18 | log "------------------------------------------------------------------------" | 18 | log "------------------------------------------------------------------------" |
| 19 | +log "Run zipformer transducer models (Russian) " | ||
| 20 | +log "------------------------------------------------------------------------" | ||
| 21 | +for type in small-zipformer zipformer; do | ||
| 22 | + url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-$type-ru-2024-09-18.tar.bz2 | ||
| 23 | + name=$(basename $url) | ||
| 24 | + curl -SL -O $url | ||
| 25 | + tar xvf $name | ||
| 26 | + rm $name | ||
| 27 | + repo=$(basename -s .tar.bz2 $name) | ||
| 28 | + ls -lh $repo | ||
| 29 | + | ||
| 30 | + log "test $repo" | ||
| 31 | + test_wavs=( | ||
| 32 | + 0.wav | ||
| 33 | + 1.wav | ||
| 34 | + ) | ||
| 35 | + | ||
| 36 | + for w in ${test_wavs[@]}; do | ||
| 37 | + time $EXE \ | ||
| 38 | + --tokens=$repo/tokens.txt \ | ||
| 39 | + --encoder=$repo/encoder.onnx \ | ||
| 40 | + --decoder=$repo/decoder.onnx \ | ||
| 41 | + --joiner=$repo/joiner.onnx \ | ||
| 42 | + --debug=1 \ | ||
| 43 | + $repo/test_wavs/$w | ||
| 44 | + done | ||
| 45 | + | ||
| 46 | + for w in ${test_wavs[@]}; do | ||
| 47 | + time $EXE \ | ||
| 48 | + --tokens=$repo/tokens.txt \ | ||
| 49 | + --encoder=$repo/encoder.int8.onnx \ | ||
| 50 | + --decoder=$repo/decoder.onnx \ | ||
| 51 | + --joiner=$repo/joiner.int8.onnx \ | ||
| 52 | + --debug=1 \ | ||
| 53 | + $repo/test_wavs/$w | ||
| 54 | + done | ||
| 55 | + rm -rf $repo | ||
| 56 | +done | ||
| 57 | + | ||
| 58 | +log "------------------------------------------------------------------------" | ||
| 19 | log "Run zipformer transducer models (Japanese from ReazonSpeech) " | 59 | log "Run zipformer transducer models (Japanese from ReazonSpeech) " |
| 20 | log "------------------------------------------------------------------------" | 60 | log "------------------------------------------------------------------------" |
| 21 | url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-ja-reazonspeech-2024-08-01.tar.bz2 | 61 | url=https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-ja-reazonspeech-2024-08-01.tar.bz2 |
| 1 | +name: export-russian-onnx-models | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + workflow_dispatch: | ||
| 5 | + | ||
| 6 | +concurrency: | ||
| 7 | + group: export-russian-onnx-models-${{ github.ref }} | ||
| 8 | + cancel-in-progress: true | ||
| 9 | + | ||
| 10 | +jobs: | ||
| 11 | + export-russian-onnx-models: | ||
| 12 | + if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj' | ||
| 13 | + name: export Russian onnx models | ||
| 14 | + runs-on: ${{ matrix.os }} | ||
| 15 | + strategy: | ||
| 16 | + fail-fast: false | ||
| 17 | + matrix: | ||
| 18 | + os: [macos-latest] | ||
| 19 | + python-version: ["3.8"] | ||
| 20 | + | ||
| 21 | + steps: | ||
| 22 | + - uses: actions/checkout@v4 | ||
| 23 | + | ||
| 24 | + - name: vosk-model-ru (zipformer v1) | ||
| 25 | + shell: bash | ||
| 26 | + run: | | ||
| 27 | + cat >README.md <<EOF | ||
| 28 | + # Introduction | ||
| 29 | + Models in this directory are from | ||
| 30 | + https://huggingface.co/alphacep/vosk-model-ru/tree/main | ||
| 31 | + EOF | ||
| 32 | + | ||
| 33 | + cat README.md | ||
| 34 | + | ||
| 35 | + d=sherpa-onnx-zipformer-ru-2024-09-18 | ||
| 36 | + mkdir $d | ||
| 37 | + pushd $d | ||
| 38 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/lang/bpe.model | ||
| 39 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/lang/tokens.txt | ||
| 40 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/encoder.int8.onnx | ||
| 41 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/decoder.int8.onnx | ||
| 42 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/joiner.int8.onnx | ||
| 43 | + | ||
| 44 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/encoder.onnx | ||
| 45 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/decoder.onnx | ||
| 46 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-ru/resolve/main/am-onnx/joiner.onnx | ||
| 47 | + | ||
| 48 | + mkdir test_wavs | ||
| 49 | + cd test_wavs | ||
| 50 | + curl -SL -O https://huggingface.co/spaces/k2-fsa/automatic-speech-recognition/resolve/main/test_wavs/russian/russian-i-love-you.wav | ||
| 51 | + curl -SL -O https://huggingface.co/spaces/k2-fsa/automatic-speech-recognition/resolve/main/test_wavs/russian/test.wav | ||
| 52 | + | ||
| 53 | + mv russian-i-love-you.wav 0.wav | ||
| 54 | + mv test.wav 1.wav | ||
| 55 | + popd | ||
| 56 | + | ||
| 57 | + ls -lh $d | ||
| 58 | + | ||
| 59 | + tar cjvf $d.tar.bz2 $d | ||
| 60 | + rm -rf $d | ||
| 61 | + | ||
| 62 | + - name: vosk-model-ru-small (zipformer v1) | ||
| 63 | + shell: bash | ||
| 64 | + run: | | ||
| 65 | + cat >README.md <<EOF | ||
| 66 | + # Introduction | ||
| 67 | + Models in this directory are from | ||
| 68 | + https://huggingface.co/alphacep/vosk-model-small-ru/tree/main | ||
| 69 | + EOF | ||
| 70 | + | ||
| 71 | + cat README.md | ||
| 72 | + | ||
| 73 | + d=sherpa-onnx-small-zipformer-ru-2024-09-18 | ||
| 74 | + mkdir $d | ||
| 75 | + pushd $d | ||
| 76 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/lang/bpe.model | ||
| 77 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/lang/tokens.txt | ||
| 78 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/encoder.int8.onnx | ||
| 79 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/decoder.int8.onnx | ||
| 80 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/joiner.int8.onnx | ||
| 81 | + | ||
| 82 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/encoder.onnx | ||
| 83 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/decoder.onnx | ||
| 84 | + curl -SL -O https://huggingface.co/alphacep/vosk-model-small-ru/resolve/main/am/joiner.onnx | ||
| 85 | + | ||
| 86 | + mkdir test_wavs | ||
| 87 | + cd test_wavs | ||
| 88 | + curl -SL -O https://huggingface.co/spaces/k2-fsa/automatic-speech-recognition/resolve/main/test_wavs/russian/russian-i-love-you.wav | ||
| 89 | + curl -SL -O https://huggingface.co/spaces/k2-fsa/automatic-speech-recognition/resolve/main/test_wavs/russian/test.wav | ||
| 90 | + | ||
| 91 | + mv russian-i-love-you.wav 0.wav | ||
| 92 | + mv test.wav 1.wav | ||
| 93 | + popd | ||
| 94 | + | ||
| 95 | + ls -lh $d | ||
| 96 | + | ||
| 97 | + tar cjvf $d.tar.bz2 $d | ||
| 98 | + rm -rf $d | ||
| 99 | + | ||
| 100 | + - name: Release | ||
| 101 | + uses: svenstaro/upload-release-action@v2 | ||
| 102 | + with: | ||
| 103 | + file_glob: true | ||
| 104 | + file: ./*.tar.bz2 | ||
| 105 | + overwrite: true | ||
| 106 | + repo_name: k2-fsa/sherpa-onnx | ||
| 107 | + repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} | ||
| 108 | + tag: asr-models |
| @@ -143,34 +143,34 @@ jobs: | @@ -143,34 +143,34 @@ jobs: | ||
| 143 | name: release-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }} | 143 | name: release-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }} |
| 144 | path: install/* | 144 | path: install/* |
| 145 | 145 | ||
| 146 | - - name: Test offline CTC | 146 | + - name: Test offline transducer |
| 147 | shell: bash | 147 | shell: bash |
| 148 | run: | | 148 | run: | |
| 149 | du -h -d1 . | 149 | du -h -d1 . |
| 150 | export PATH=$PWD/build/bin:$PATH | 150 | export PATH=$PWD/build/bin:$PATH |
| 151 | export EXE=sherpa-onnx-offline | 151 | export EXE=sherpa-onnx-offline |
| 152 | 152 | ||
| 153 | - .github/scripts/test-offline-ctc.sh | 153 | + .github/scripts/test-offline-transducer.sh |
| 154 | du -h -d1 . | 154 | du -h -d1 . |
| 155 | 155 | ||
| 156 | - - name: Test online punctuation | 156 | + - name: Test offline CTC |
| 157 | shell: bash | 157 | shell: bash |
| 158 | run: | | 158 | run: | |
| 159 | du -h -d1 . | 159 | du -h -d1 . |
| 160 | export PATH=$PWD/build/bin:$PATH | 160 | export PATH=$PWD/build/bin:$PATH |
| 161 | - export EXE=sherpa-onnx-online-punctuation | 161 | + export EXE=sherpa-onnx-offline |
| 162 | 162 | ||
| 163 | - .github/scripts/test-online-punctuation.sh | 163 | + .github/scripts/test-offline-ctc.sh |
| 164 | du -h -d1 . | 164 | du -h -d1 . |
| 165 | 165 | ||
| 166 | - - name: Test offline transducer | 166 | + - name: Test online punctuation |
| 167 | shell: bash | 167 | shell: bash |
| 168 | run: | | 168 | run: | |
| 169 | du -h -d1 . | 169 | du -h -d1 . |
| 170 | export PATH=$PWD/build/bin:$PATH | 170 | export PATH=$PWD/build/bin:$PATH |
| 171 | - export EXE=sherpa-onnx-offline | 171 | + export EXE=sherpa-onnx-online-punctuation |
| 172 | 172 | ||
| 173 | - .github/scripts/test-offline-transducer.sh | 173 | + .github/scripts/test-online-punctuation.sh |
| 174 | du -h -d1 . | 174 | du -h -d1 . |
| 175 | 175 | ||
| 176 | - name: Test online transducer | 176 | - name: Test online transducer |
| @@ -115,22 +115,21 @@ jobs: | @@ -115,22 +115,21 @@ jobs: | ||
| 115 | otool -L build/bin/sherpa-onnx | 115 | otool -L build/bin/sherpa-onnx |
| 116 | otool -l build/bin/sherpa-onnx | 116 | otool -l build/bin/sherpa-onnx |
| 117 | 117 | ||
| 118 | - - name: Test online punctuation | 118 | + - name: Test offline transducer |
| 119 | shell: bash | 119 | shell: bash |
| 120 | run: | | 120 | run: | |
| 121 | export PATH=$PWD/build/bin:$PATH | 121 | export PATH=$PWD/build/bin:$PATH |
| 122 | - export EXE=sherpa-onnx-online-punctuation | 122 | + export EXE=sherpa-onnx-offline |
| 123 | 123 | ||
| 124 | - .github/scripts/test-online-punctuation.sh | 124 | + .github/scripts/test-offline-transducer.sh |
| 125 | 125 | ||
| 126 | - - name: Test offline transducer | 126 | + - name: Test online punctuation |
| 127 | shell: bash | 127 | shell: bash |
| 128 | run: | | 128 | run: | |
| 129 | export PATH=$PWD/build/bin:$PATH | 129 | export PATH=$PWD/build/bin:$PATH |
| 130 | - export EXE=sherpa-onnx-offline | ||
| 131 | - | ||
| 132 | - .github/scripts/test-offline-transducer.sh | 130 | + export EXE=sherpa-onnx-online-punctuation |
| 133 | 131 | ||
| 132 | + .github/scripts/test-online-punctuation.sh | ||
| 134 | 133 | ||
| 135 | - name: Test offline CTC | 134 | - name: Test offline CTC |
| 136 | shell: bash | 135 | shell: bash |
| @@ -296,6 +296,46 @@ def get_models(): | @@ -296,6 +296,46 @@ def get_models(): | ||
| 296 | popd | 296 | popd |
| 297 | """, | 297 | """, |
| 298 | ), | 298 | ), |
| 299 | + Model( | ||
| 300 | + model_name="sherpa-onnx-zipformer-ru-2024-09-18", | ||
| 301 | + idx=17, | ||
| 302 | + lang="ru", | ||
| 303 | + short_name="zipformer", | ||
| 304 | + cmd=""" | ||
| 305 | + pushd $model_name | ||
| 306 | + | ||
| 307 | + rm -rfv test_wavs | ||
| 308 | + | ||
| 309 | + rm -fv encoder.onnx | ||
| 310 | + rm -fv decoder.int8.onnx | ||
| 311 | + rm -fv joiner.onnx | ||
| 312 | + rm -fv bpe.model | ||
| 313 | + | ||
| 314 | + ls -lh | ||
| 315 | + | ||
| 316 | + popd | ||
| 317 | + """, | ||
| 318 | + ), | ||
| 319 | + Model( | ||
| 320 | + model_name="sherpa-onnx-small-zipformer-ru-2024-09-18", | ||
| 321 | + idx=18, | ||
| 322 | + lang="ru", | ||
| 323 | + short_name="small_zipformer", | ||
| 324 | + cmd=""" | ||
| 325 | + pushd $model_name | ||
| 326 | + | ||
| 327 | + rm -rfv test_wavs | ||
| 328 | + | ||
| 329 | + rm -fv encoder.onnx | ||
| 330 | + rm -fv decoder.int8.onnx | ||
| 331 | + rm -fv joiner.onnx | ||
| 332 | + rm -fv bpe.model | ||
| 333 | + | ||
| 334 | + ls -lh | ||
| 335 | + | ||
| 336 | + popd | ||
| 337 | + """, | ||
| 338 | + ), | ||
| 299 | ] | 339 | ] |
| 300 | return models | 340 | return models |
| 301 | 341 |
| @@ -368,6 +368,32 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -368,6 +368,32 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 368 | modelType = "transducer", | 368 | modelType = "transducer", |
| 369 | ) | 369 | ) |
| 370 | } | 370 | } |
| 371 | + | ||
| 372 | + 17 -> { | ||
| 373 | + val modelDir = "sherpa-onnx-zipformer-ru-2024-09-18" | ||
| 374 | + return OfflineModelConfig( | ||
| 375 | + transducer = OfflineTransducerModelConfig( | ||
| 376 | + encoder = "$modelDir/encoder.int8.onnx", | ||
| 377 | + decoder = "$modelDir/decoder.onnx", | ||
| 378 | + joiner = "$modelDir/joiner.int8.onnx", | ||
| 379 | + ), | ||
| 380 | + tokens = "$modelDir/tokens.txt", | ||
| 381 | + modelType = "transducer", | ||
| 382 | + ) | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + 18 -> { | ||
| 386 | + val modelDir = "sherpa-onnx-small-zipformer-ru-2024-09-18" | ||
| 387 | + return OfflineModelConfig( | ||
| 388 | + transducer = OfflineTransducerModelConfig( | ||
| 389 | + encoder = "$modelDir/encoder.int8.onnx", | ||
| 390 | + decoder = "$modelDir/decoder.onnx", | ||
| 391 | + joiner = "$modelDir/joiner.int8.onnx", | ||
| 392 | + ), | ||
| 393 | + tokens = "$modelDir/tokens.txt", | ||
| 394 | + modelType = "transducer", | ||
| 395 | + ) | ||
| 396 | + } | ||
| 371 | } | 397 | } |
| 372 | return null | 398 | return null |
| 373 | } | 399 | } |
-
请 注册 或 登录 后发表评论