Skip to content

Commit f2991e2

Browse files
authored
Export X-ASR models to sherpa-onnx (k2-fsa#3662)
1 parent 8799533 commit f2991e2

8 files changed

Lines changed: 1050 additions & 21 deletions

File tree

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
name: export-x-asr
2+
3+
on:
4+
push:
5+
branches:
6+
- export-x-asr
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: export-x-asr-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
export-non-streaming:
15+
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
16+
name: Non-streaming ONNX
17+
runs-on: ubuntu-22.04
18+
strategy:
19+
fail-fast: false
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Clone icefall
25+
shell: bash
26+
run: |
27+
git clone https://github.com/k2-fsa/icefall
28+
29+
- name: Export onnx models
30+
uses: addnab/docker-run-action@v3
31+
with:
32+
image: ghcr.io/${{ github.repository_owner }}/icefall:cpu-py3.10-torch2.6.0-v20250630
33+
options: |
34+
--volume ${{ github.workspace }}/icefall:/icefall
35+
--volume ${{ github.workspace }}/:/sherpa-onnx
36+
shell: bash
37+
run: |
38+
export PYTHONPATH=/icefall:$PYTHONPATH
39+
cd /icefall
40+
git config --global --add safe.directory /icefall
41+
42+
python3 -m torch.utils.collect_env
43+
python3 -m k2.version
44+
45+
python3 -m pip install kaldi-native-fbank
46+
47+
/sherpa-onnx/scripts/zipformer-transducer/x-asr/export-non-streaming.sh
48+
49+
mv punct /sherpa-onnx
50+
mv no-punct /sherpa-onnx
51+
mv test_wavs /sherpa-onnx
52+
53+
- name: Show model files
54+
shell: bash
55+
run: |
56+
ls -lh punct
57+
echo "---"
58+
ls -lh no-punct
59+
60+
- name: Collect model files (punct fp32)
61+
shell: bash
62+
run: |
63+
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-punct-2026-06-03
64+
mkdir $d
65+
cp -av test_wavs $d
66+
cp -v punct/README.md $d
67+
cp -v punct/encoder-epoch-99-avg-1.onnx $d
68+
cp -v punct/decoder-epoch-99-avg-1.onnx $d
69+
cp -v punct/joiner-epoch-99-avg-1.onnx $d
70+
cp -v punct/tokens.txt $d
71+
cp -v punct/test_onnx.py $d
72+
cp -v punct/bpe.model $d
73+
74+
tar cjfv $d.tar.bz2 $d
75+
76+
ls -lh $d
77+
ls -lh $d.tar.bz2
78+
79+
- name: Collect model files (punct int8)
80+
shell: bash
81+
run: |
82+
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-punct-int8-2026-06-03
83+
mkdir $d
84+
cp -av test_wavs $d
85+
cp -v punct/README.md $d
86+
cp -v punct/encoder-epoch-99-avg-1.int8.onnx $d
87+
cp -v punct/decoder-epoch-99-avg-1.onnx $d # NOTE: Use fp32 for decoder
88+
cp -v punct/joiner-epoch-99-avg-1.int8.onnx $d
89+
cp -v punct/tokens.txt $d
90+
cp -v punct/test_onnx.py $d
91+
cp -v punct/bpe.model $d
92+
93+
tar cjfv $d.tar.bz2 $d
94+
95+
ls -lh $d
96+
ls -lh $d.tar.bz2
97+
98+
- name: Collect model files (no-punct fp32)
99+
shell: bash
100+
run: |
101+
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-2026-06-03
102+
mkdir $d
103+
cp -av test_wavs $d
104+
cp -v no-punct/README.md $d
105+
cp -v no-punct/encoder-epoch-99-avg-1.onnx $d
106+
cp -v no-punct/decoder-epoch-99-avg-1.onnx $d
107+
cp -v no-punct/joiner-epoch-99-avg-1.onnx $d
108+
cp -v no-punct/tokens.txt $d
109+
cp -v no-punct/test_onnx.py $d
110+
cp -v no-punct/bpe.model $d
111+
112+
tar cjfv $d.tar.bz2 $d
113+
114+
ls -lh $d
115+
ls -lh $d.tar.bz2
116+
117+
- name: Collect model files (no-punct int8)
118+
shell: bash
119+
run: |
120+
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-int8-2026-06-03
121+
mkdir $d
122+
cp -av test_wavs $d
123+
cp -v no-punct/README.md $d
124+
cp -v no-punct/encoder-epoch-99-avg-1.int8.onnx $d
125+
cp -v no-punct/decoder-epoch-99-avg-1.onnx $d # NOTE: Use fp32 for decoder
126+
cp -v no-punct/joiner-epoch-99-avg-1.int8.onnx $d
127+
cp -v no-punct/tokens.txt $d
128+
cp -v no-punct/test_onnx.py $d
129+
cp -v no-punct/bpe.model $d
130+
131+
tar cjfv $d.tar.bz2 $d
132+
133+
ls -lh $d
134+
ls -lh $d.tar.bz2
135+
136+
- name: Release
137+
if: true
138+
uses: svenstaro/upload-release-action@v2
139+
with:
140+
file_glob: true
141+
file: ./sherpa-onnx-x-asr-*.tar.bz2
142+
overwrite: true
143+
repo_name: k2-fsa/sherpa-onnx
144+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
145+
tag: asr-models
146+
147+
148+
export-streaming:
149+
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
150+
name: streaming ONNX
151+
runs-on: ubuntu-22.04
152+
strategy:
153+
fail-fast: false
154+
matrix:
155+
chunk_size_ms: [160, 480, 960, 1920]
156+
157+
steps:
158+
- uses: actions/checkout@v4
159+
160+
- name: Clone icefall
161+
shell: bash
162+
run: |
163+
git clone https://github.com/k2-fsa/icefall
164+
165+
- name: Export onnx models
166+
uses: addnab/docker-run-action@v3
167+
with:
168+
image: ghcr.io/${{ github.repository_owner }}/icefall:cpu-py3.10-torch2.6.0-v20250630
169+
options: |
170+
--volume ${{ github.workspace }}/icefall:/icefall
171+
--volume ${{ github.workspace }}/:/sherpa-onnx
172+
shell: bash
173+
run: |
174+
export PYTHONPATH=/icefall:$PYTHONPATH
175+
cd /icefall
176+
git config --global --add safe.directory /icefall
177+
178+
python3 -m torch.utils.collect_env
179+
python3 -m k2.version
180+
181+
python3 -m pip install kaldi-native-fbank
182+
183+
chunk_size_ms=${{ matrix.chunk_size_ms }}
184+
185+
/sherpa-onnx/scripts/zipformer-transducer/x-asr/export-streaming.sh $chunk_size_ms
186+
187+
mv punct /sherpa-onnx
188+
mv no-punct /sherpa-onnx
189+
mv test_wavs /sherpa-onnx
190+
191+
- name: Show model files
192+
shell: bash
193+
run: |
194+
ls -lh punct
195+
echo "---"
196+
ls -lh no-punct
197+
198+
- name: Collect model files (punct fp32)
199+
shell: bash
200+
run: |
201+
chunk=${{ matrix.chunk_size_ms }}ms
202+
d=sherpa-onnx-x-asr-$chunk-streaming-zipformer-transducer-zh-en-punct-2026-06-05
203+
mkdir $d
204+
cp -av test_wavs $d
205+
cp -v punct/README.md $d
206+
cp -v punct/encoder.onnx $d
207+
cp -v punct/decoder.onnx $d
208+
cp -v punct/joiner.onnx $d
209+
cp -v punct/tokens.txt $d
210+
cp -v punct/test_onnx.py $d
211+
cp -v punct/bpe.model $d
212+
213+
tar cjfv $d.tar.bz2 $d
214+
215+
ls -lh $d
216+
ls -lh $d.tar.bz2
217+
218+
- name: Collect model files (punct int8)
219+
shell: bash
220+
run: |
221+
chunk=${{ matrix.chunk_size_ms }}ms
222+
d=sherpa-onnx-x-asr-$chunk-streaming-zipformer-transducer-zh-en-punct-int8-2026-06-05
223+
mkdir $d
224+
cp -av test_wavs $d
225+
cp -v punct/README.md $d
226+
cp -v punct/encoder.int8.onnx $d
227+
cp -v punct/decoder.onnx $d
228+
cp -v punct/joiner.int8.onnx $d
229+
cp -v punct/tokens.txt $d
230+
cp -v punct/test_onnx.py $d
231+
cp -v punct/bpe.model $d
232+
233+
tar cjfv $d.tar.bz2 $d
234+
235+
ls -lh $d
236+
ls -lh $d.tar.bz2
237+
238+
- name: Collect model files (no-punct fp32)
239+
shell: bash
240+
run: |
241+
chunk=${{ matrix.chunk_size_ms }}ms
242+
d=sherpa-onnx-x-asr-$chunk-streaming-zipformer-transducer-zh-en-2026-06-05
243+
mkdir $d
244+
cp -av test_wavs $d
245+
cp -v no-punct/README.md $d
246+
cp -v no-punct/encoder.onnx $d
247+
cp -v no-punct/decoder.onnx $d
248+
cp -v no-punct/joiner.onnx $d
249+
cp -v no-punct/tokens.txt $d
250+
cp -v no-punct/test_onnx.py $d
251+
cp -v no-punct/bpe.model $d
252+
253+
tar cjfv $d.tar.bz2 $d
254+
255+
ls -lh $d
256+
ls -lh $d.tar.bz2
257+
258+
- name: Collect model files (no-punct int8)
259+
shell: bash
260+
run: |
261+
chunk=${{ matrix.chunk_size_ms }}ms
262+
d=sherpa-onnx-x-asr-$chunk-streaming-zipformer-transducer-zh-en-int8-2026-06-05
263+
mkdir $d
264+
cp -av test_wavs $d
265+
cp -v no-punct/README.md $d
266+
cp -v no-punct/encoder.int8.onnx $d
267+
cp -v no-punct/decoder.onnx $d
268+
cp -v no-punct/joiner.int8.onnx $d
269+
cp -v no-punct/tokens.txt $d
270+
cp -v no-punct/test_onnx.py $d
271+
cp -v no-punct/bpe.model $d
272+
273+
tar cjfv $d.tar.bz2 $d
274+
275+
ls -lh $d
276+
ls -lh $d.tar.bz2
277+
278+
279+
- name: Release
280+
if: true
281+
uses: svenstaro/upload-release-action@v2
282+
with:
283+
file_glob: true
284+
file: ./sherpa-onnx-x-asr-*.tar.bz2
285+
overwrite: true
286+
repo_name: k2-fsa/sherpa-onnx
287+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
288+
tag: asr-models

.github/workflows/upload-models.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
ls -lh $d $d.tar.bz2
7474
7575
- name: X-ASR non-stremaing zipformer transducer punct
76-
if: true
76+
if: false
7777
shell: bash
7878
run: |
7979
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-punct-2026-06-03
@@ -98,7 +98,7 @@ jobs:
9898
ls -lh $d $d.tar.bz2
9999
100100
- name: X-ASR non-stremaing zipformer transducer punct int8
101-
if: true
101+
if: false
102102
shell: bash
103103
run: |
104104
d=sherpa-onnx-x-asr-zipformer-transducer-zh-en-punct-int8-2026-06-03

0 commit comments

Comments
 (0)