-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add multilingual Nemotron-3.5 streaming ASR support #3671
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
Merged
csukuangfj
merged 5 commits into
k2-fsa:master
from
JulianPscheid:feature/nemotron-multilingual-streaming
Jun 12, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3b9ad1e
Add multilingual Nemotron-3.5 streaming ASR runtime support
JulianPscheid 0cea16e
Add export script and CI workflow for nemotron-3.5-asr-streaming-0.6b
JulianPscheid 6b5abf8
Expose the per-stream language option in Flutter and Swift online str…
JulianPscheid cd500b0
Avoid copies in multilingual NeMo decode path
JulianPscheid fc071e3
Address review comments: use nlohmann/json for the prompt dictionary
JulianPscheid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
185 changes: 185 additions & 0 deletions
185
.github/workflows/export-nemotron-3.5-asr-streaming-0.6b.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| name: export-nemotron-3-5-asr-streaming-06b | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - export-nemotron-3-5-asr-streaming | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: export-nemotron-3-5-asr-streaming-to-onnx-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| export-nemotron-3-5-asr-streaming-0-6b-to-onnx: | ||
| if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj' | ||
| name: nemotron-3-5-asr-streaming-0-6b-to-onnx | ||
| 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: | | ||
| # nemotron-3.5-asr-streaming-0.6b requires EncDecRNNTBPEModelWithPrompt, | ||
| # which is not in the stable nemo-toolkit release yet; the model card | ||
| # instructs installing NeMo from main. | ||
| BRANCH='main' | ||
| pip install Cython packaging | ||
| pip install "nemo_toolkit[asr] @ git+https://github.com/NVIDIA/NeMo.git@$BRANCH" | ||
| pip install onnxruntime ipython sentencepiece | ||
| pip install kaldi-native-fbank | ||
| pip install soundfile librosa | ||
|
|
||
| - name: Run | ||
| shell: bash | ||
| run: | | ||
| cd scripts/nemo/nemotron-3.5-asr-streaming-0.6b | ||
|
|
||
| python3 ./export_onnx.py | ||
|
|
||
| ls -lh | ||
| echo "---" | ||
|
|
||
| ls -lh */ | ||
|
|
||
| echo "---" | ||
|
|
||
| - name: Collect results | ||
| shell: bash | ||
| run: | | ||
| src=scripts/nemo/nemotron-3.5-asr-streaming-0.6b | ||
|
|
||
| for chunk in 80 160 560 1120; do | ||
| d=sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-${chunk}ms-2026-06-11 | ||
| mkdir -p $d | ||
|
|
||
| cp -av $src/$chunk/encoder.onnx $d/ | ||
| cp -av $src/$chunk/encoder.data $d/ | ||
| cp -av $src/$chunk/decoder.onnx $d/ | ||
| cp -av $src/$chunk/joiner.onnx $d/ | ||
| cp -av $src/tokens.txt $d/ | ||
| cat >$d/README.md <<EOF | ||
| # Introduction | ||
| This model is from https://huggingface.co/nvidia/nemotron-3.5-asr-streaming-0.6b | ||
|
|
||
| The chunk size is ${chunk}ms for the exported ONNX model. | ||
|
|
||
| Use per-stream language strings such as "en", "ja", or "auto". | ||
| EOF | ||
|
|
||
| ls -lh $d | ||
|
|
||
| d=sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-${chunk}ms-int8-2026-06-11 | ||
| mkdir -p $d | ||
|
|
||
| cp -av $src/${chunk}/encoder.int8.onnx $d/ | ||
| cp -av $src/${chunk}/decoder.int8.onnx $d/ | ||
| cp -av $src/${chunk}/joiner.int8.onnx $d/ | ||
| cp -av $src/tokens.txt $d/ | ||
| cat >$d/README.md <<EOF | ||
| # Introduction | ||
| This model is from https://huggingface.co/nvidia/nemotron-3.5-asr-streaming-0.6b | ||
|
|
||
| The chunk size is ${chunk}ms for the exported ONNX model. | ||
|
|
||
| Use per-stream language strings such as "en", "ja", or "auto". | ||
| EOF | ||
|
|
||
| ls -lh $d | ||
| done | ||
|
|
||
| - name: Download test waves | ||
| shell: bash | ||
| run: | | ||
| mkdir test_wavs | ||
| pushd test_wavs | ||
| curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/en.wav | ||
| curl -SL -O https://hf-mirror.com/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/resolve/main/test_wavs/ja.wav | ||
| popd | ||
|
|
||
| models=( | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-80ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-160ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-1120ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-80ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-160ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-1120ms-2026-06-11 | ||
| ) | ||
| for m in ${models[@]}; do | ||
| cp -av test_wavs $m | ||
| tar cjvf $m.tar.bz2 $m | ||
| done | ||
|
|
||
| ls -lh *.tar.bz2 | ||
|
|
||
| - name: Release | ||
| uses: svenstaro/upload-release-action@v2 | ||
| with: | ||
| file_glob: true | ||
| file: sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-*-int8-2026-06-11.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-nemotron-3.5-asr-streaming-0.6b-80ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-160ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-1120ms-int8-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-80ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-160ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-2026-06-11 | ||
| sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-1120ms-2026-06-11 | ||
| ) | ||
|
|
||
| for m in ${models[@]}; do | ||
| if [ ! -d $m ]; then | ||
| echo "skip $m" | ||
| continue | ||
| fi | ||
|
|
||
| rm -rf huggingface | ||
| export GIT_LFS_SKIP_SMUDGE=1 | ||
| export GIT_CLONE_PROTECTION_ACTIVE=false | ||
| git clone https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$m huggingface | ||
| cp -av $m/* huggingface | ||
| cd huggingface | ||
| git lfs track "*.onnx" | ||
| git lfs track "*.data" | ||
| git lfs track "*.wav" | ||
| git status | ||
| git add . | ||
| git status | ||
| git commit -m "first commit" | ||
| git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/$m main | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| cd .. | ||
| done | ||
|
|
||
| rm -rf huggingface | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Multilingual Nemotron-3.5 Streaming ASR | ||
|
|
||
| This directory exports the NVIDIA NeMo model | ||
| `nvidia/nemotron-3.5-asr-streaming-0.6b` to sherpa-onnx streaming transducer | ||
| packages. | ||
|
|
||
| The exporter writes the same package layout as | ||
| `nvidia/nemotron-speech-streaming-en-0.6b`: | ||
|
|
||
| - `encoder.onnx` | ||
| - `encoder.data` | ||
| - `decoder.onnx` | ||
| - `joiner.onnx` | ||
| - int8 variants for all three ONNX graphs | ||
| - `tokens.txt` converted from the model's SentencePiece tokenizer | ||
|
|
||
| The encoder metadata contains `prompt_dictionary` and `auto_prompt_id`. Users | ||
| set the per-stream language as a string; the numerical prompt id is internal. | ||
| An empty language string and `auto` use the model's auto-detect prompt. | ||
|
|
||
| ## Export | ||
|
|
||
| As of June 2026, stable NeMo releases lack `EncDecRNNTBPEModelWithPrompt`, | ||
| so install NeMo from git main. | ||
|
|
||
| ```bash | ||
| pip install Cython packaging | ||
| pip install "nemo_toolkit[asr] @ git+https://github.com/NVIDIA/NeMo.git@main" | ||
| pip install onnxruntime ipython sentencepiece | ||
| pip install kaldi-native-fbank | ||
| pip install soundfile librosa | ||
|
|
||
| python3 ./export_onnx.py | ||
| ``` | ||
|
|
||
| The script exports 80ms, 160ms, 560ms, and 1120ms chunk sizes. | ||
|
|
||
| ## Decode | ||
|
|
||
| Forced language: | ||
|
|
||
| ```bash | ||
| ./build/bin/sherpa-onnx \ | ||
| --encoder=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/encoder.int8.onnx \ | ||
| --decoder=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/decoder.int8.onnx \ | ||
| --joiner=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/joiner.int8.onnx \ | ||
| --tokens=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/tokens.txt \ | ||
| --language=ja \ | ||
| ./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/test_wavs/ja.wav | ||
| ``` | ||
|
|
||
| Auto language: | ||
|
|
||
| ```bash | ||
| ./build/bin/sherpa-onnx \ | ||
| --encoder=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/encoder.int8.onnx \ | ||
| --decoder=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/decoder.int8.onnx \ | ||
| --joiner=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/joiner.int8.onnx \ | ||
| --tokens=./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/tokens.txt \ | ||
| --language=auto \ | ||
| ./sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/test_wavs/ja.wav | ||
| ``` | ||
|
|
||
| The same auto behavior is used when `--language` is omitted. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.