Committed by
GitHub
Add WebAssembly demo for streaming trilingual Paraformer (Chinese+Cantonese+English) (#618)
正在显示
6 个修改的文件
包含
157 行增加
和
0 行删除
| @@ -72,6 +72,7 @@ jobs: | @@ -72,6 +72,7 @@ jobs: | ||
| 72 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | 72 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 |
| 73 | 73 | ||
| 74 | - name: Publish to ModelScope | 74 | - name: Publish to ModelScope |
| 75 | + if: false | ||
| 75 | env: | 76 | env: |
| 76 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | 77 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} |
| 77 | uses: nick-fields/retry@v2 | 78 | uses: nick-fields/retry@v2 |
| @@ -74,6 +74,7 @@ jobs: | @@ -74,6 +74,7 @@ jobs: | ||
| 74 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | 74 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 |
| 75 | 75 | ||
| 76 | - name: Publish to ModelScope | 76 | - name: Publish to ModelScope |
| 77 | + if: false | ||
| 77 | env: | 78 | env: |
| 78 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | 79 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} |
| 79 | uses: nick-fields/retry@v2 | 80 | uses: nick-fields/retry@v2 |
| @@ -70,6 +70,7 @@ jobs: | @@ -70,6 +70,7 @@ jobs: | ||
| 70 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | 70 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 |
| 71 | 71 | ||
| 72 | - name: Publish to ModelScope | 72 | - name: Publish to ModelScope |
| 73 | + if: false | ||
| 73 | env: | 74 | env: |
| 74 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | 75 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} |
| 75 | uses: nick-fields/retry@v2 | 76 | uses: nick-fields/retry@v2 |
| 1 | +name: wasm-simd-hf-space-zh-cantonese-en-asr-paraformer | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + release: | ||
| 5 | + types: | ||
| 6 | + - published | ||
| 7 | + | ||
| 8 | + workflow_dispatch: | ||
| 9 | + | ||
| 10 | +concurrency: | ||
| 11 | + group: wasm-simd-hf-space-zh-cantonese-en-asr-paraformer-${{ github.ref }} | ||
| 12 | + cancel-in-progress: true | ||
| 13 | + | ||
| 14 | +jobs: | ||
| 15 | + wasm-simd-hf-space-zh-cantonese-en-asr-paraformer: | ||
| 16 | + runs-on: ${{ matrix.os }} | ||
| 17 | + strategy: | ||
| 18 | + fail-fast: false | ||
| 19 | + matrix: | ||
| 20 | + os: [ubuntu-latest] | ||
| 21 | + | ||
| 22 | + steps: | ||
| 23 | + - uses: actions/checkout@v4 | ||
| 24 | + with: | ||
| 25 | + fetch-depth: 0 | ||
| 26 | + - name: Install emsdk | ||
| 27 | + uses: mymindstorm/setup-emsdk@v14 | ||
| 28 | + | ||
| 29 | + - name: View emsdk version | ||
| 30 | + shell: bash | ||
| 31 | + run: | | ||
| 32 | + emcc -v | ||
| 33 | + echo "--------------------" | ||
| 34 | + emcc --check | ||
| 35 | + | ||
| 36 | + - name: Download model files | ||
| 37 | + shell: bash | ||
| 38 | + run: | | ||
| 39 | + cd wasm/asr/assets | ||
| 40 | + ls -lh | ||
| 41 | + echo "----------" | ||
| 42 | + | ||
| 43 | + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en.tar.bz2 | ||
| 44 | + tar xvf sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en.tar.bz2 | ||
| 45 | + rm sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en.tar.bz2 | ||
| 46 | + | ||
| 47 | + mv sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en/encoder.int8.onnx encoder.onnx | ||
| 48 | + mv sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en/decoder.int8.onnx decoder.onnx | ||
| 49 | + mv sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en/tokens.txt ./ | ||
| 50 | + | ||
| 51 | + rm -rf sherpa-onnx-streaming-paraformer-trilingual-zh-cantonese-en | ||
| 52 | + | ||
| 53 | + ls -lh | ||
| 54 | + | ||
| 55 | + cd ../ | ||
| 56 | + | ||
| 57 | + sed -i.bak s/"type = 0"/"type = 1"/g ./sherpa-onnx.js | ||
| 58 | + sed -i.bak s/Zipformer/Paraformer/g ./index.html | ||
| 59 | + | ||
| 60 | + git diff | ||
| 61 | + | ||
| 62 | + - name: Build sherpa-onnx for WebAssembly (ASR) | ||
| 63 | + shell: bash | ||
| 64 | + run: | | ||
| 65 | + ./build-wasm-simd-asr.sh | ||
| 66 | + | ||
| 67 | + - name: collect files | ||
| 68 | + shell: bash | ||
| 69 | + run: | | ||
| 70 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 71 | + | ||
| 72 | + dst=sherpa-onnx-wasm-simd-${SHERPA_ONNX_VERSION}-zh-cantonese-en-asr-paraformer | ||
| 73 | + mv build-wasm-simd-asr/install/bin/wasm/asr $dst | ||
| 74 | + ls -lh $dst | ||
| 75 | + tar cjfv ${dst}.tar.bz2 ./${dst} | ||
| 76 | + | ||
| 77 | + - name: Upload wasm files | ||
| 78 | + uses: actions/upload-artifact@v4 | ||
| 79 | + with: | ||
| 80 | + name: sherpa-onnx-wasm-simd-zh-cantonese-en-asr-paraformer | ||
| 81 | + path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | ||
| 82 | + | ||
| 83 | + - name: Publish to huggingface | ||
| 84 | + env: | ||
| 85 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 86 | + uses: nick-fields/retry@v2 | ||
| 87 | + with: | ||
| 88 | + max_attempts: 20 | ||
| 89 | + timeout_seconds: 200 | ||
| 90 | + shell: bash | ||
| 91 | + command: | | ||
| 92 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 93 | + | ||
| 94 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 95 | + git config --global user.name "Fangjun Kuang" | ||
| 96 | + | ||
| 97 | + rm -rf huggingface | ||
| 98 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 99 | + | ||
| 100 | + git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer huggingface | ||
| 101 | + cd huggingface | ||
| 102 | + git fetch | ||
| 103 | + git pull | ||
| 104 | + git merge -m "merge remote" --ff origin main | ||
| 105 | + | ||
| 106 | + cp -v ../sherpa-onnx-wasm-simd-${SHERPA_ONNX_VERSION}-*/* . | ||
| 107 | + | ||
| 108 | + git status | ||
| 109 | + git lfs track "*.data" | ||
| 110 | + git lfs track "*.wasm" | ||
| 111 | + ls -lh | ||
| 112 | + | ||
| 113 | + git add . | ||
| 114 | + git commit -m "update model" | ||
| 115 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer main | ||
| 116 | + | ||
| 117 | + - name: Publish to ModelScope | ||
| 118 | + if: false | ||
| 119 | + env: | ||
| 120 | + MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | ||
| 121 | + uses: nick-fields/retry@v2 | ||
| 122 | + with: | ||
| 123 | + max_attempts: 10 | ||
| 124 | + timeout_seconds: 600 | ||
| 125 | + shell: bash | ||
| 126 | + command: | | ||
| 127 | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 128 | + | ||
| 129 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 130 | + git config --global user.name "Fangjun Kuang" | ||
| 131 | + | ||
| 132 | + rm -rf ms | ||
| 133 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 134 | + | ||
| 135 | + git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer.git ms | ||
| 136 | + cd ms | ||
| 137 | + git config lfs.locksverify true | ||
| 138 | + git fetch | ||
| 139 | + git pull | ||
| 140 | + git merge -m "merge remote" --ff origin main | ||
| 141 | + | ||
| 142 | + cp -v ../sherpa-onnx-wasm-simd-${SHERPA_ONNX_VERSION}-*/* . | ||
| 143 | + | ||
| 144 | + git status | ||
| 145 | + git lfs track "*.data" | ||
| 146 | + git lfs track "*.wasm" | ||
| 147 | + ls -lh | ||
| 148 | + | ||
| 149 | + git add . | ||
| 150 | + git commit -m "update model" | ||
| 151 | + git push https://oauth2:${MS_TOKEN}@www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer.git | ||
| 152 | + |
| @@ -81,6 +81,7 @@ jobs: | @@ -81,6 +81,7 @@ jobs: | ||
| 81 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | 81 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 |
| 82 | 82 | ||
| 83 | - name: Publish to ModelScope | 83 | - name: Publish to ModelScope |
| 84 | + if: false | ||
| 84 | env: | 85 | env: |
| 85 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | 86 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} |
| 86 | uses: nick-fields/retry@v2 | 87 | uses: nick-fields/retry@v2 |
| @@ -72,6 +72,7 @@ jobs: | @@ -72,6 +72,7 @@ jobs: | ||
| 72 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 | 72 | path: ./sherpa-onnx-wasm-simd-*.tar.bz2 |
| 73 | 73 | ||
| 74 | - name: Publish to ModelScope | 74 | - name: Publish to ModelScope |
| 75 | + if: false | ||
| 75 | env: | 76 | env: |
| 76 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} | 77 | MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} |
| 77 | uses: nick-fields/retry@v2 | 78 | uses: nick-fields/retry@v2 |
-
请 注册 或 登录 后发表评论