Skip to content

Support Giga AM transducer V2 #2136

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
merged 3 commits into from
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/scripts/test-offline-ctc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,23 @@ for type in base small; do
rm -rf sherpa-onnx-dolphin-$type-ctc-multi-lang-2025-04-02
done

log "------------------------------------------------------------"
log "Run NeMo GigaAM Russian models v2"
log "------------------------------------------------------------"
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19.tar.bz2
tar xvf sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19.tar.bz2
rm sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19.tar.bz2

$EXE \
--nemo-ctc-model=./sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19/model.int8.onnx \
--tokens=./sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19/tokens.txt \
--debug=1 \
./sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19/test_wavs/example.wav

rm -rf sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19

log "------------------------------------------------------------"
log "Run NeMo GigaAM Russian models"
log "Run NeMo GigaAM Russian models v1"
log "------------------------------------------------------------"
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-ctc-giga-am-russian-2024-10-24.tar.bz2
tar xvf sherpa-onnx-nemo-ctc-giga-am-russian-2024-10-24.tar.bz2
Expand Down
18 changes: 18 additions & 0 deletions .github/scripts/test-offline-transducer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ echo "PATH: $PATH"

which $EXE

log "------------------------------------------------------------"
log "Run NeMo GigaAM Russian models v2"
log "------------------------------------------------------------"
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19.tar.bz2
tar xvf sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19.tar.bz2
rm sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19.tar.bz2

$EXE \
--encoder=./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/encoder.int8.onnx \
--decoder=./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/decoder.onnx \
--joiner=./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/joiner.onnx \
--tokens=./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/tokens.txt \
--model-type=nemo_transducer \
./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/test_wavs/example.wav

rm sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19


log "------------------------------------------------------------------------"
log "Run zipformer transducer models (Russian) "
log "------------------------------------------------------------------------"
Expand Down
112 changes: 104 additions & 8 deletions .github/workflows/export-nemo-giga-am-to-onnx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
mv -v scripts/nemo/GigaAM/tokens.txt $d/
mv -v scripts/nemo/GigaAM/*.wav $d/test_wavs/
mv -v scripts/nemo/GigaAM/run-ctc.sh $d/
mv -v scripts/nemo/GigaAM/*-ctc.py $d/
mv -v scripts/nemo/GigaAM/export-onnx-ctc.py $d/
cp -v scripts/nemo/GigaAM/test-onnx-ctc.py $d/

ls -lh scripts/nemo/GigaAM/

Expand Down Expand Up @@ -71,7 +72,8 @@ jobs:
mv -v scripts/nemo/GigaAM/tokens.txt $d/
mv -v scripts/nemo/GigaAM/*.wav $d/test_wavs/
mv -v scripts/nemo/GigaAM/run-rnnt.sh $d/
mv -v scripts/nemo/GigaAM/*-rnnt.py $d/
mv -v scripts/nemo/GigaAM/export-onnx-rnnt.py $d/
cp -v scripts/nemo/GigaAM/test-onnx-rnnt.py $d/

ls -lh scripts/nemo/GigaAM/

Expand All @@ -91,20 +93,49 @@ jobs:
mkdir $d/test_wavs
rm scripts/nemo/GigaAM/v2_ctc.onnx
mv -v scripts/nemo/GigaAM/*.int8.onnx $d/
cp -v scripts/nemo/GigaAM/LICENCE $d/
cp -v scripts/nemo/GigaAM/LICENSE $d/
mv -v scripts/nemo/GigaAM/tokens.txt $d/
mv -v scripts/nemo/GigaAM/*.wav $d/test_wavs/
mv -v scripts/nemo/GigaAM/run-ctc.sh $d/
mv -v scripts/nemo/GigaAM/run-ctc-v2.sh $d/
mv -v scripts/nemo/GigaAM/*-ctc-v2.py $d/
cp -v scripts/nemo/GigaAM/test-onnx-ctc.py $d/

ls -lh scripts/nemo/GigaAM/

ls -lh $d

tar cjvf ${d}.tar.bz2 $d

- name: Run Transducer v2
shell: bash
run: |
pushd scripts/nemo/GigaAM
./run-rnnt-v2.sh
popd

d=sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19
mkdir $d
mkdir $d/test_wavs

mv -v scripts/nemo/GigaAM/encoder.int8.onnx $d/
mv -v scripts/nemo/GigaAM/decoder.onnx $d/
mv -v scripts/nemo/GigaAM/joiner.onnx $d/

cp -v scripts/nemo/GigaAM/*.md $d/
cp -v scripts/nemo/GigaAM/LICENSE $d/
mv -v scripts/nemo/GigaAM/tokens.txt $d/
mv -v scripts/nemo/GigaAM/*.wav $d/test_wavs/
mv -v scripts/nemo/GigaAM/run-rnnt-v2.sh $d/
cp -v scripts/nemo/GigaAM/test-onnx-rnnt.py $d/

ls -lh scripts/nemo/GigaAM/

ls -lh $d

tar cjvf ${d}.tar.bz2 $d

- name: Release
if: github.repository_owner == 'csukuangfj'
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
Expand All @@ -114,7 +145,16 @@ jobs:
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: asr-models

- name: Publish to huggingface (Transducer)
- name: Release
if: github.repository_owner == 'k2-fsa'
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
file: ./*.tar.bz2
overwrite: true
tag: asr-models

- name: Publish to huggingface (CTC)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
Expand All @@ -126,11 +166,66 @@ jobs:
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"

d=sherpa-onnx-nemo-ctc-giga-am-russian-2024-10-24/
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
cp -av $d/* ./huggingface
cd huggingface
git lfs track "*.onnx"
git lfs track "*.wav"
git status
git add .
git status
git commit -m "add models"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d main

- name: Publish to huggingface (Transducer)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 5
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"

d=sherpa-onnx-nemo-transducer-giga-am-russian-2024-10-24/
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
cp -av $d/* ./huggingface
cd huggingface
git lfs track "*.onnx"
git lfs track "*.wav"
git status
git add .
git status
git commit -m "add models"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d main

- name: Publish v2 to huggingface (CTC)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 5
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"

d=sherpa-onnx-nemo-ctc-giga-am-v2-russian-2025-04-19/
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
mv -v $d/* ./huggingface
cp -av $d/* ./huggingface
cd huggingface
git lfs track "*.onnx"
git lfs track "*.wav"
Expand All @@ -145,7 +240,7 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 20
max_attempts: 5
timeout_seconds: 200
shell: bash
command: |
Expand All @@ -155,8 +250,9 @@ jobs:
d=sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
mv -v $d/* ./huggingface
cp -av $d/* ./huggingface
cd huggingface
git lfs track "*.onnx"
git lfs track "*.wav"
Expand Down
2 changes: 1 addition & 1 deletion scripts/nemo/GigaAM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ to sherpa-onnx.
The ASR models are for Russian speech recognition in this folder.

Please see the license of the models at
https://github.com/salute-developers/GigaAM/blob/main/GigaAM%20License_NC.pdf
https://github.com/salute-developers/GigaAM/blob/main/LICENSE
11 changes: 9 additions & 2 deletions scripts/nemo/GigaAM/export-onnx-ctc-v2.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import gigaam
import onnx
import torch
Expand Down Expand Up @@ -27,7 +28,13 @@ def add_meta_data(filename: str, meta_data: dict[str, str]):

def main() -> None:
model_name = "v2_ctc"
model = gigaam.load_model(model_name, fp16_encoder=False, use_flash=False, download_root=".")
model = gigaam.load_model(
model_name, fp16_encoder=False, use_flash=False, download_root="."
)

# use characters
# space is 0
# <blk> is the last token
with open("./tokens.txt", "w", encoding="utf-8") as f:
for i, s in enumerate(model.cfg["labels"]):
f.write(f"{s} {i}\n")
Expand All @@ -53,5 +60,5 @@ def main() -> None:
)


if __name__ == '__main__':
if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions scripts/nemo/GigaAM/export-onnx-ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def main():
model.load_state_dict(ckpt, strict=False)
model.eval()

# use characters
# space is 0
# <blk> is the last token
with open("tokens.txt", "w", encoding="utf-8") as f:
for i, t in enumerate(model.cfg.labels):
f.write(f"{t} {i}\n")
Expand Down
Loading
Loading