Skip to content

Commit f95b772

Browse files
authored
Export NeMo unified streaming 0.6b models (k2-fsa#3602)
1 parent 11519a4 commit f95b772

5 files changed

Lines changed: 214 additions & 1 deletion

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: export-nemo-parakeet-unified-en-0.6b-streaming
2+
3+
on:
4+
push:
5+
branches:
6+
- export-nemo-unified-streaming-2
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: export-nemo-parakeet-unified-en-0.6b-streaming-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
HF_HUB_ENABLE_HF_TRANSFER: "0"
15+
16+
jobs:
17+
export-nemo-parakeet-unified-en-0_6b_streaming:
18+
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
19+
name: parakeet unified-en 0.6b streaming
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [macos-latest]
25+
python-version: ["3.10"]
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Show disk space
31+
run: |
32+
df -h
33+
34+
# See https://github.com/vlayer-xyz/vlayer/pull/543/files
35+
# Free up disk space as the macOS runners end up using most for Xcode
36+
# versions we don't need and use iOS simulators.
37+
- name: Free up disk space
38+
run: |
39+
echo '*** Delete iOS simulators and their caches'
40+
xcrun simctl delete all
41+
sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
42+
43+
- name: Show disk space
44+
run: |
45+
df -h
46+
47+
- name: Setup Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Run
53+
shell: bash
54+
run: |
55+
cd scripts/nemo/parakeet-unified-en-0.6b/
56+
./run-streaming.sh
57+
58+
mv -v *.tar.bz2 ../../../
59+
mv -v sherpa-onnx-nemo-parakeet* ../../../
60+
61+
- name: Publish to huggingface
62+
env:
63+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
64+
uses: nick-fields/retry@v3
65+
with:
66+
max_attempts: 20
67+
timeout_seconds: 200
68+
shell: bash
69+
command: |
70+
git config --global user.email "csukuangfj@gmail.com"
71+
git config --global user.name "Fangjun Kuang"
72+
73+
models=(
74+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-int8-streaming-1120ms
75+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-streaming-1120ms
76+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-int8-streaming-560ms
77+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-streaming-560ms
78+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-int8-streaming-240ms
79+
sherpa-onnx-nemo-parakeet-unified-en-0.6b-streaming-240ms
80+
)
81+
82+
for m in ${models[@]}; do
83+
rm -rf huggingface
84+
export GIT_LFS_SKIP_SMUDGE=1
85+
export GIT_CLONE_PROTECTION_ACTIVE=false
86+
git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$m huggingface
87+
cp -av $m/* huggingface
88+
cd huggingface
89+
git lfs track "*.onnx"
90+
git lfs track "*.wav"
91+
git lfs track "*.weights"
92+
git status
93+
git add .
94+
git status
95+
git commit -m "first commit"
96+
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$m main
97+
cd ..
98+
done
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

scripts/nemo/parakeet-unified-en-0.6b/export_onnx_streaming.py

100644100755
File mode changed.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2026 Xiaomi Corp. (authors: Fangjun Kuang)
3+
4+
set -ex
5+
6+
log() {
7+
# This function is from espnet
8+
local fname=${BASH_SOURCE[1]##*/}
9+
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
10+
}
11+
12+
if [ ! -f ./parakeet-unified-en-0.6b.nemo ]; then
13+
curl -SL -O https://huggingface.co/nvidia/parakeet-unified-en-0.6b/resolve/main/parakeet-unified-en-0.6b.nemo
14+
fi
15+
16+
curl -SL -O https://huggingface.co/nvidia/parakeet-unified-en-0.6b/resolve/main/bias.md
17+
curl -SL -O https://huggingface.co/nvidia/parakeet-unified-en-0.6b/resolve/main/explainability.md
18+
curl -SL -O https://huggingface.co/nvidia/parakeet-unified-en-0.6b/resolve/main/privacy.md
19+
curl -SL -O https://huggingface.co/nvidia/parakeet-unified-en-0.6b/resolve/main/safety.md
20+
21+
curl -SL -O https://dldata-public.s3.us-east-2.amazonaws.com/2086-149220-0033.wav
22+
23+
pip install \
24+
"nemo_toolkit[asr] @ git+https://github.com/NVIDIA/NeMo.git" \
25+
"numpy<2" \
26+
ipython \
27+
kaldi-native-fbank \
28+
librosa \
29+
onnx \
30+
onnxruntime \
31+
soundfile
32+
33+
latency_list=(
34+
1120ms
35+
560ms
36+
240ms
37+
)
38+
39+
for latency in ${latency_list[@]}; do
40+
rm -fv layers.*.* Constant_* onnx__*
41+
ls -lh
42+
echo "---"
43+
ls -lh
44+
echo "---"
45+
python3 ./export_onnx_streaming.py --latency $latency
46+
47+
ls -lh *.onnx
48+
49+
echo "---int8----"
50+
python3 ./test_onnx_streaming.py \
51+
--encoder ./encoder.int8.onnx \
52+
--decoder ./decoder.int8.onnx \
53+
--joiner ./joiner.int8.onnx \
54+
--tokens ./tokens.txt \
55+
--wav 2086-149220-0033.wav
56+
57+
echo "---fp32----"
58+
python3 ./test_onnx_streaming.py \
59+
--encoder ./encoder.int8.onnx \
60+
--decoder ./decoder.onnx \
61+
--joiner ./joiner.onnx \
62+
--tokens ./tokens.txt \
63+
--wav 2086-149220-0033.wav
64+
65+
d=sherpa-onnx-nemo-parakeet-unified-en-0.6b-streaming-$latency
66+
mkdir -p $d
67+
mkdir -p $d/test_wavs
68+
mv -v encoder.onnx $d
69+
mv -v encoder.weights $d
70+
mv -v decoder.onnx $d
71+
mv -v joiner.onnx $d
72+
cp -v tokens.txt $d
73+
cp -v 2086-149220-0033.wav $d/test_wavs/0.wav
74+
cp -v bias.md $d
75+
cp -v explainability.md $d
76+
cp -v privacy.md $d
77+
cp -v safety.md $d
78+
echo "----$d---"
79+
ls -lh $d
80+
echo "----"
81+
82+
d=sherpa-onnx-nemo-parakeet-unified-en-0.6b-int8-streaming-$latency
83+
mkdir -p $d
84+
mkdir -p $d/test_wavs
85+
mv -v encoder.int8.onnx $d
86+
mv -v decoder.int8.onnx $d
87+
mv -v joiner.int8.onnx $d
88+
mv -v tokens.txt $d
89+
cp -v 2086-149220-0033.wav $d/test_wavs/0.wav
90+
cp -v bias.md $d
91+
cp -v explainability.md $d
92+
cp -v privacy.md $d
93+
cp -v safety.md $d
94+
echo "----$d---"
95+
ls -lh $d
96+
tar cjfv $d.tar.bz2 $d
97+
ls -lh $d.tar.bz2
98+
echo "----"
99+
done
100+
101+
102+
103+
104+

scripts/nemo/parakeet-unified-en-0.6b/test_buffered_streaming_helpers.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
# Copyright 2026 Milan Leonard
23
import unittest
34

45
import numpy as np

scripts/nemo/parakeet-unified-en-0.6b/test_onnx_streaming.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright 2026 Xiaomi Corp. (authors: Fangjun Kuang)
2+
# Copyright 2026 Milan Leonard
33
"""ONNX Runtime smoke test for buffered Parakeet Unified streaming."""
44

55
import argparse

0 commit comments

Comments
 (0)