Fangjun Kuang
Committed by GitHub

Fix building for risc-v (#2549)

@@ -62,7 +62,7 @@ jobs: @@ -62,7 +62,7 @@ jobs:
62 path: ./*.jar 62 path: ./*.jar
63 63
64 - name: Release jar 64 - name: Release jar
65 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 65 + if: repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
66 uses: svenstaro/upload-release-action@v2 66 uses: svenstaro/upload-release-action@v2
67 with: 67 with:
68 file_glob: true 68 file_glob: true
@@ -70,7 +70,15 @@ jobs: @@ -70,7 +70,15 @@ jobs:
70 file: ./*.jar 70 file: ./*.jar
71 repo_name: k2-fsa/sherpa-onnx 71 repo_name: k2-fsa/sherpa-onnx
72 repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} 72 repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
73 - tag: v1.12.10 73 + tag: v1.12.11
  74 +
  75 + - name: Release jar
  76 + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  77 + uses: svenstaro/upload-release-action@v2
  78 + with:
  79 + file_glob: true
  80 + overwrite: true
  81 + file: ./*.jar
74 82
75 - name: Build sherpa-onnx 83 - name: Build sherpa-onnx
76 uses: addnab/docker-run-action@v3 84 uses: addnab/docker-run-action@v3
@@ -179,15 +187,23 @@ jobs: @@ -179,15 +187,23 @@ jobs:
179 du -h -d1 . 187 du -h -d1 .
180 188
181 - name: Release pre-compiled binaries and libs for linux x64 189 - name: Release pre-compiled binaries and libs for linux x64
182 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 190 + if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  191 + uses: svenstaro/upload-release-action@v2
  192 + with:
  193 + file_glob: true
  194 + overwrite: true
  195 + file: sherpa-onnx-*.tar.bz2
  196 + repo_name: k2-fsa/sherpa-onnx
  197 + repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
  198 + tag: v1.12.11
  199 +
  200 + - name: Release pre-compiled binaries and libs for linux x64
  201 + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
183 uses: svenstaro/upload-release-action@v2 202 uses: svenstaro/upload-release-action@v2
184 with: 203 with:
185 file_glob: true 204 file_glob: true
186 overwrite: true 205 overwrite: true
187 file: sherpa-onnx-*.tar.bz2 206 file: sherpa-onnx-*.tar.bz2
188 - # repo_name: k2-fsa/sherpa-onnx  
189 - # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}  
190 - # tag: v1.12.10  
191 207
192 - name: Publish to huggingface 208 - name: Publish to huggingface
193 if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') 209 if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
@@ -127,66 +127,6 @@ jobs: @@ -127,66 +127,6 @@ jobs:
127 127
128 readelf -d build-riscv64-linux-gnu/bin/sherpa-onnx 128 readelf -d build-riscv64-linux-gnu/bin/sherpa-onnx
129 129
130 - - name: Test sherpa-onnx  
131 - shell: bash  
132 - run: |  
133 - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH  
134 - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH  
135 - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot  
136 - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib  
137 -  
138 - ls -lh ./build-riscv64-linux-gnu/bin  
139 -  
140 - echo "----------sherpa-onnx----------"  
141 - qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx --help  
142 - readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx  
143 -  
144 - echo "----------sherpa-onnx-offline----------"  
145 - qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline --help  
146 - readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline  
147 -  
148 - echo "----------sherpa-onnx-offline-tts----------"  
149 - qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help  
150 - readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts  
151 -  
152 - - name: Test streaming speech recognition  
153 - shell: bash  
154 - run: |  
155 - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH  
156 - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH  
157 - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot  
158 - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib  
159 -  
160 - wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2  
161 - tar xvf sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2  
162 - rm sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2  
163 -  
164 - qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx \  
165 - --tokens=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/tokens.txt \  
166 - --encoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/encoder-epoch-99-avg-1.onnx \  
167 - --decoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/decoder-epoch-99-avg-1.onnx \  
168 - --joiner=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/joiner-epoch-99-avg-1.onnx \  
169 - ./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/test_wavs/0.wav  
170 -  
171 - - name: Test offline tts  
172 - shell: bash  
173 - run: |  
174 - export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH  
175 - export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH  
176 - export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot  
177 - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib  
178 -  
179 - wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-lessac-medium.tar.bz2  
180 - tar xf vits-piper-en_US-lessac-medium.tar.bz2  
181 - rm vits-piper-en_US-lessac-medium.tar.bz2  
182 -  
183 - qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts \  
184 - --vits-model=./vits-piper-en_US-lessac-medium/en_US-lessac-medium.onnx \  
185 - --vits-data-dir=./vits-piper-en_US-lessac-medium/espeak-ng-data \  
186 - --vits-tokens=./vits-piper-en_US-lessac-medium/tokens.txt \  
187 - --output-filename=./liliana-piper-en_US-lessac-medium.wav \  
188 - 'liliana, the most beautiful and lovely assistant of our team!'  
189 -  
190 - name: Copy files 130 - name: Copy files
191 shell: bash 131 shell: bash
192 run: | 132 run: |
@@ -260,21 +200,92 @@ jobs: @@ -260,21 +200,92 @@ jobs:
260 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 200 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
261 201
262 - uses: actions/upload-artifact@v4 202 - uses: actions/upload-artifact@v4
263 - if: matrix.lib_type == 'shared'  
264 - with:  
265 - name: wave  
266 - path: ./*.wav  
267 -  
268 - - uses: actions/upload-artifact@v4  
269 if: matrix.lib_type == 'static' 203 if: matrix.lib_type == 'static'
270 with: 204 with:
271 name: sherpa-onnx-linux-riscv64-static 205 name: sherpa-onnx-linux-riscv64-static
272 path: sherpa-onnx-*linux-riscv64-static.tar.bz2 206 path: sherpa-onnx-*linux-riscv64-static.tar.bz2
273 207
274 - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }} 208 - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }}
275 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 209 + if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
276 uses: svenstaro/upload-release-action@v2 210 uses: svenstaro/upload-release-action@v2
277 with: 211 with:
278 file_glob: true 212 file_glob: true
279 overwrite: true 213 overwrite: true
280 file: sherpa-onnx-*linux-riscv64*.tar.bz2 214 file: sherpa-onnx-*linux-riscv64*.tar.bz2
  215 + repo_name: k2-fsa/sherpa-onnx
  216 + repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
  217 + tag: v1.12.11
  218 +
  219 + - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }}
  220 + if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  221 + uses: svenstaro/upload-release-action@v2
  222 + with:
  223 + file_glob: true
  224 + overwrite: true
  225 + file: sherpa-onnx-*linux-riscv64*.tar.bz2
  226 +
  227 + - name: Test sherpa-onnx
  228 + shell: bash
  229 + run: |
  230 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  231 + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
  232 + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
  233 + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
  234 +
  235 + ls -lh ./build-riscv64-linux-gnu/bin
  236 +
  237 + echo "----------sherpa-onnx----------"
  238 + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx --help
  239 + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx
  240 +
  241 + echo "----------sherpa-onnx-offline----------"
  242 + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline --help
  243 + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline
  244 +
  245 + echo "----------sherpa-onnx-offline-tts----------"
  246 + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help
  247 + readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts
  248 +
  249 + - name: Test streaming speech recognition
  250 + shell: bash
  251 + run: |
  252 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  253 + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
  254 + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
  255 + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
  256 +
  257 + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
  258 + tar xvf sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
  259 + rm sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2
  260 +
  261 + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx \
  262 + --tokens=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/tokens.txt \
  263 + --encoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/encoder-epoch-99-avg-1.onnx \
  264 + --decoder=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/decoder-epoch-99-avg-1.onnx \
  265 + --joiner=./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/joiner-epoch-99-avg-1.onnx \
  266 + ./sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23/test_wavs/0.wav
  267 +
  268 + - name: Test offline tts
  269 + shell: bash
  270 + run: |
  271 + export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
  272 + export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
  273 + export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
  274 + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/toolchain/sysroot/lib
  275 +
  276 + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-lessac-medium.tar.bz2
  277 + tar xf vits-piper-en_US-lessac-medium.tar.bz2
  278 + rm vits-piper-en_US-lessac-medium.tar.bz2
  279 +
  280 + qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts \
  281 + --vits-model=./vits-piper-en_US-lessac-medium/en_US-lessac-medium.onnx \
  282 + --vits-data-dir=./vits-piper-en_US-lessac-medium/espeak-ng-data \
  283 + --vits-tokens=./vits-piper-en_US-lessac-medium/tokens.txt \
  284 + --output-filename=./liliana-piper-en_US-lessac-medium.wav \
  285 + 'liliana, the most beautiful and lovely assistant of our team!'
  286 +
  287 + - uses: actions/upload-artifact@v4
  288 + if: matrix.lib_type == 'shared'
  289 + with:
  290 + name: wave
  291 + path: ./*.wav
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 #include "sherpa-onnx/csrc/offline-tts-zipvoice-model.h" 5 #include "sherpa-onnx/csrc/offline-tts-zipvoice-model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
  8 +#include <cstring>
8 #include <iostream> 9 #include <iostream>
9 #include <random> 10 #include <random>
10 #include <string> 11 #include <string>