|
| 1 | +name: export-sense-voice-to-ascend-npu |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - export-sense-voice-ascend |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: export-sense-voice-to-ascend-npu-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + export-sense-voice-to-ascend-npu: |
| 15 | + if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj' |
| 16 | + name: ${{ matrix.framework }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + container: |
| 19 | + # image: ascendai/cann:latest |
| 20 | + # image: ascendai/cann:8.1.rc1-910b-ubuntu22.04-py3.10 |
| 21 | + # see https://hub.docker.com/r/gpustack/ascendai-cann/tags?name=8.0 |
| 22 | + image: gpustack/ascendai-cann:8.0.RC3-910b-ubuntu20.04-py3.9 |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + os: [ubuntu-latest] |
| 27 | + python-version: ["3.8"] |
| 28 | + framework: ["FunASR", "WSYue-ASR"] |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Setup Python ${{ matrix.python-version }} |
| 34 | + uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + |
| 38 | + - name: Show Python |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + python3 --version |
| 42 | +
|
| 43 | + - name: Install curl |
| 44 | + shell: bash |
| 45 | + run: apt-get update && apt-get install -y curl bzip2 |
| 46 | + |
| 47 | + - name: Verify environment |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + ls -lh /usr/local/Ascend/ascend-toolkit/set_env.sh |
| 51 | +
|
| 52 | + find /usr/local/Ascend -name "libascend*.so" 2>/dev/null |
| 53 | +
|
| 54 | +
|
| 55 | + source /usr/local/Ascend/ascend-toolkit/set_env.sh |
| 56 | + export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux/devlib/linux/x86_64:$LD_LIBRARY_PATH |
| 57 | +
|
| 58 | + echo "CANN environment:" |
| 59 | + which atc || echo "atc not found" |
| 60 | + atc --help |
| 61 | +
|
| 62 | + - name: Install Python dependencies |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + python3 -m pip install "numpy<2" \ |
| 66 | + onnx==1.17.0 \ |
| 67 | + torch==2.0.0+cpu -f https://download.pytorch.org/whl/torch \ |
| 68 | + attrs psutil scipy decorator cloudpickle ml-dtypes tornado \ |
| 69 | + sentencepiece \ |
| 70 | + pyyaml |
| 71 | +
|
| 72 | + - name: Run SenseVoice from FunAsr |
| 73 | + if: matrix.framework == 'FunASR' |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + cd scripts/sense-voice/ascend-npu |
| 77 | +
|
| 78 | + curl -SL -O https://hf-mirror.com/FunAudioLLM/SenseVoiceSmall/resolve/main/am.mvn |
| 79 | + curl -SL -O https://hf-mirror.com/FunAudioLLM/SenseVoiceSmall/resolve/main/model.pt |
| 80 | + curl -SL -O https://hf-mirror.com/FunAudioLLM/SenseVoiceSmall/resolve/main/chn_jpn_yue_eng_ko_spectok.bpe.model |
| 81 | +
|
| 82 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/en.wav |
| 83 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/ja.wav |
| 84 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/ko.wav |
| 85 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/yue.wav |
| 86 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/zh.wav |
| 87 | +
|
| 88 | + rm -f README.md || true |
| 89 | +
|
| 90 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/README.md |
| 91 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/LICENSE |
| 92 | +
|
| 93 | + echo "export to onnx" |
| 94 | +
|
| 95 | + python3 ./export_onnx.py |
| 96 | +
|
| 97 | + ls -lh *.onnx |
| 98 | +
|
| 99 | + source /usr/local/Ascend/ascend-toolkit/set_env.sh |
| 100 | + export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux/devlib/linux/x86_64:$LD_LIBRARY_PATH |
| 101 | +
|
| 102 | + atc --model=./model.onnx \ |
| 103 | + --framework=5 \ |
| 104 | + --host_env_os=linux \ |
| 105 | + --host_env_cpu=aarch64 \ |
| 106 | + --output=model \ |
| 107 | + --input_format=ND \ |
| 108 | + --input_shape="x:1,-1,560;prompt:4" \ |
| 109 | + --soc_version="Ascend910B" |
| 110 | +
|
| 111 | + ls -lh *.om |
| 112 | +
|
| 113 | + echo "collect results" |
| 114 | + d=sherpa-onnx-ascend-910B-sense-voice-zh-en-ja-ko-yue-2024-07-17 |
| 115 | +
|
| 116 | + mkdir -p $d |
| 117 | + mkdir -p $d/test_wavs |
| 118 | +
|
| 119 | + cp -v README.md $d |
| 120 | + cp -v LICENSE $d |
| 121 | + cp -v model_linux_aarch64.om $d/model.om |
| 122 | + cp -v tokens.txt $d |
| 123 | + cp -v test_om.py $d |
| 124 | + cp -v *.wav $d/test_wavs |
| 125 | + ls -lh $d |
| 126 | + tar cjfv $d.tar.bz2 $d |
| 127 | + ls -lh *.tar.bz2 |
| 128 | + rm -rf $d |
| 129 | +
|
| 130 | + echo "----show---" |
| 131 | + ls -lh *.tar.bz2 |
| 132 | +
|
| 133 | + mv *.tar.bz2 ../../.. |
| 134 | +
|
| 135 | + - name: Run SenseVoice from WSYue-ASR |
| 136 | + if: matrix.framework == 'WSYue-ASR' |
| 137 | + shell: bash |
| 138 | + run: | |
| 139 | + cd scripts/sense-voice/ascend-npu |
| 140 | +
|
| 141 | + curl -SL -O https://huggingface.co/ASLP-lab/WSYue-ASR/resolve/main/sensevoice_small_yue/model.pt |
| 142 | +
|
| 143 | + curl -SL -O https://hf-mirror.com/FunAudioLLM/SenseVoiceSmall/resolve/main/am.mvn |
| 144 | + curl -SL -O https://hf-mirror.com/FunAudioLLM/SenseVoiceSmall/resolve/main/chn_jpn_yue_eng_ko_spectok.bpe.model |
| 145 | +
|
| 146 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/en.wav |
| 147 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/yue.wav |
| 148 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/zh.wav |
| 149 | +
|
| 150 | + for i in $(seq 0 17); do |
| 151 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09/resolve/main/test_wavs/yue-$i.wav |
| 152 | + done |
| 153 | +
|
| 154 | + rm -f README.md || true |
| 155 | +
|
| 156 | + curl -SL -O https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09/resolve/main/README.md |
| 157 | +
|
| 158 | + echo "export to onnx" |
| 159 | + python3 ./export_onnx.py |
| 160 | +
|
| 161 | + ls -lh *.onnx |
| 162 | +
|
| 163 | + source /usr/local/Ascend/ascend-toolkit/set_env.sh |
| 164 | + export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux/devlib/linux/x86_64:$LD_LIBRARY_PATH |
| 165 | +
|
| 166 | + atc --model=./model.onnx \ |
| 167 | + --framework=5 \ |
| 168 | + --host_env_os=linux \ |
| 169 | + --host_env_cpu=aarch64 \ |
| 170 | + --output=model \ |
| 171 | + --input_format=ND \ |
| 172 | + --input_shape="x:1,-1,560;prompt:4" \ |
| 173 | + --soc_version="Ascend910B" |
| 174 | +
|
| 175 | + ls -lh *.om |
| 176 | +
|
| 177 | + echo "collect results" |
| 178 | + d=sherpa-onnx-ascend-910B-sense-voice-zh-en-ja-ko-yue-2025-09-09 |
| 179 | +
|
| 180 | + mkdir -p $d |
| 181 | + mkdir -p $d/test_wavs |
| 182 | +
|
| 183 | + cp -v README.md $d |
| 184 | + cp -v model_linux_aarch64.om $d/model.om |
| 185 | + cp -v tokens.txt $d |
| 186 | + cp -v test_om.py $d |
| 187 | + cp -v *.wav $d/test_wavs |
| 188 | + ls -lh $d |
| 189 | + tar cjfv $d.tar.bz2 $d |
| 190 | + ls -lh *.tar.bz2 |
| 191 | + rm -rf $d |
| 192 | +
|
| 193 | + echo "----show---" |
| 194 | + ls -lh *.tar.bz2 |
| 195 | +
|
| 196 | + mv *.tar.bz2 ../../.. |
| 197 | +
|
| 198 | + - name: Release |
| 199 | + if: github.repository_owner == 'csukuangfj' |
| 200 | + uses: svenstaro/upload-release-action@v2 |
| 201 | + with: |
| 202 | + file_glob: true |
| 203 | + file: ./*.tar.bz2 |
| 204 | + overwrite: true |
| 205 | + repo_name: k2-fsa/sherpa-onnx |
| 206 | + repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} |
| 207 | + tag: asr-models |
| 208 | + |
| 209 | + - name: Release |
| 210 | + if: github.repository_owner == 'k2-fsa' |
| 211 | + uses: svenstaro/upload-release-action@v2 |
| 212 | + with: |
| 213 | + file_glob: true |
| 214 | + file: ./*.tar.bz2 |
| 215 | + overwrite: true |
| 216 | + tag: asr-models |
0 commit comments