Repository navigation
Refactor exporting NeMo models #2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
810d1c7
2545f92
6f5b9f9
f062f82
1c4fd97
42a093b
242e8d3
67f2587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||||||||
| name: export-nemo-parakeet-tdt | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||||
| - refactor-export-nemo | ||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||||
| group: export-nemo-parakeet-tdt-${{ github.ref }} | ||||||||||||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| export-nemo-parakeet-tdt-0_6b-v2: | ||||||||||||||||||||||||||||||||||
| if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj' | ||||||||||||||||||||||||||||||||||
| name: parakeet tdt | ||||||||||||||||||||||||||||||||||
| 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 python dependencies | ||||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| pip install \ | ||||||||||||||||||||||||||||||||||
| nemo_toolkit['asr'] \ | ||||||||||||||||||||||||||||||||||
| "numpy<2" \ | ||||||||||||||||||||||||||||||||||
| ipython \ | ||||||||||||||||||||||||||||||||||
| kaldi-native-fbank \ | ||||||||||||||||||||||||||||||||||
| librosa \ | ||||||||||||||||||||||||||||||||||
| onnx==1.17.0 \ | ||||||||||||||||||||||||||||||||||
| onnxmltools==1.13.0 \ | ||||||||||||||||||||||||||||||||||
| onnxruntime==1.17.1 \ | ||||||||||||||||||||||||||||||||||
| soundfile | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Run | ||||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| cd scripts/nemo/parakeet-tdt_ctc-0.6b-ja | ||||||||||||||||||||||||||||||||||
| ./run-ctc.sh | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Collect files | ||||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| models=( | ||||||||||||||||||||||||||||||||||
| sherpa-onnx-nemo-parakeet-tdt_ctc-0.6b-ja-35000-int8 | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| for m in ${models[@]}; do | ||||||||||||||||||||||||||||||||||
| mv -v scripts/nemo/parakeet-tdt_ctc-0.6b-ja/$m . | ||||||||||||||||||||||||||||||||||
| tar cjfv $m.tar.bz2 $m | ||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix shell script quoting issues. Shellcheck identifies several quoting issues that should be addressed for robustness. models=(
sherpa-onnx-nemo-parakeet-tdt_ctc-0.6b-ja-35000-int8
)
- for m in ${models[@]}; do
- mv -v scripts/nemo/parakeet-tdt_ctc-0.6b-ja/$m .
- tar cjfv $m.tar.bz2 $m
+ for m in "${models[@]}"; do
+ mv -v "scripts/nemo/parakeet-tdt_ctc-0.6b-ja/$m" .
+ tar cjfv "$m.tar.bz2" "$m"
done📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)54-54: shellcheck reported issue in this script: SC2068:error:4:10: Double quote array expansions to avoid re-splitting elements (shellcheck) 54-54: shellcheck reported issue in this script: SC2086:info:5:47: Double quote to prevent globbing and word splitting (shellcheck) 54-54: shellcheck reported issue in this script: SC2086:info:6:12: Double quote to prevent globbing and word splitting (shellcheck) 54-54: shellcheck reported issue in this script: SC2086:info:6:23: Double quote to prevent globbing and word splitting (shellcheck) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - 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-parakeet-tdt_ctc-0.6b-ja-35000-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 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - 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 | ||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,5 +23,6 @@ This folder contains scripts for exporting models from | |
| - https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_multilingual_fastconformer_hybrid_large_pc | ||
|
|
||
| - https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/parakeet-tdt_ctc-110m | ||
| - https://huggingface.co/nvidia/parakeet-tdt_ctc-0.6b-ja | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix markdown formatting issues. The line has incorrect indentation and should format the URL properly according to markdown standards. Apply this diff to fix the formatting: - - https://huggingface.co/nvidia/parakeet-tdt_ctc-0.6b-ja
+- https://huggingface.co/nvidia/parakeet-tdt_ctc-0.6b-ja
🧰 Tools🪛 LanguageTool[grammar] ~26-~26: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) 🪛 markdownlint-cli2 (0.17.2)26-26: Unordered list indentation (MD007, ul-indent) 26-26: Bare URL used (MD034, no-bare-urls) 🤖 Prompt for AI Agents |
||
|
|
||
| to `sherpa-onnx`. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make the Hugging Face publish loop idempotent & cheaper
git lfs track "*.onnx"and"*.wav"run on every iteration – do it once outside the loop or inside the repo after the first clone."first commit"becomes inaccurate after the first push – consider a generic message ("update models") or includedate +"%F"to avoid duplicate-headline warnings.set -euo pipefailat the top of the script block to fail fast on any publishing error.No diff provided since it spans multiple script blocks.
🤖 Prompt for AI Agents