k2-fsa_sherpa-onnx/.github/workflows/export-nemo-fast-conformer-hybrid-transducer-ctc.yaml
Fangjun Kuang 6122a678f5
Refactor exporting NeMo models (#2362)
Refactors and extends model export support to include new NeMo Parakeet TDT int8 variants for English and Japanese, updating the Kotlin API, export scripts, test runners, and CI workflows.

- Added support for two new int8 model types in OfflineRecognizer.kt.
- Enhanced Python export scripts to perform dynamic quantization and metadata injection.
- Updated shell scripts and GitHub workflows to package, test, and publish int8 model artifacts.
2025-07-09 16:02:12 +08:00

117 lines
4.1 KiB
YAML

name: export-nemo-fast-conformer-ctc-to-onnx
on:
workflow_dispatch:
concurrency:
group: export-nemo-fast-conformer-hybrid-transducer-ctc-to-onnx-${{ github.ref }}
cancel-in-progress: true
jobs:
export-nemo-fast-conformer-hybrid-transducer-ctc-to-onnx:
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
name: Hybrid ctc streaming
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install NeMo
shell: bash
run: |
BRANCH='main'
pip install git+https://github.com/NVIDIA/NeMo.git@$BRANCH#egg=nemo_toolkit[asr]
pip install onnxruntime ipython
pip install kaldi-native-fbank
pip install soundfile librosa
- name: Run
shell: bash
run: |
cd scripts/nemo/fast-conformer-hybrid-transducer-ctc
./run-ctc.sh
mv -v sherpa-onnx-nemo* ../../..
- name: Download test waves
shell: bash
run: |
mkdir test_wavs
pushd test_wavs
curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-nemo-ctc-en-conformer-small/resolve/main/test_wavs/0.wav
curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-nemo-ctc-en-conformer-small/resolve/main/test_wavs/1.wav
curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-nemo-ctc-en-conformer-small/resolve/main/test_wavs/8k.wav
curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-nemo-ctc-en-conformer-small/resolve/main/test_wavs/trans.txt
popd
names=(
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-80ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-480ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-1040ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-80ms-int8
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-480ms-int8
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-1040ms-int8
)
for d in ${names[@]}; do
cp -av test_wavs $d/
tar cjvf $d.tar.bz2 $d
done
- name: Release
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
file: ./*.tar.bz2
overwrite: true
repo_name: k2-fsa/sherpa-onnx
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: asr-models
- name: Publish to huggingface
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 20
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
models=(
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-80ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-480ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-1040ms
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-80ms-int8
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-480ms-int8
sherpa-onnx-nemo-streaming-fast-conformer-ctc-en-1040ms-int8
)
for m in ${models[@]}; do
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$m huggingface
cp -av $m/* huggingface
cd huggingface
git lfs track "*.onnx"
git lfs track "*.wav"
git status
git add .
git status
git commit -m "first commit"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$m main
cd ..
done