Skip to content
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
56 changes: 56 additions & 0 deletions .github/scripts/export-ascend/generate_whisper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
# Copyright 2026 Xiaomi Corp. (authors: Fangjun Kuang)

import itertools
import json
from dataclasses import asdict, dataclass

from generate_zipformer_ctc_20250703 import get_image, get_soc_version, get_cann_version


@dataclass
class Config:
# 7.0, 8.0, 8.2
cann: str

# 910B, 910B2, 910B3, 310P3
soc_version: str

model: str

image: str = ""

def __post_init__(self):
self.image = get_image(self.cann, soc_version=self.soc_version)


def main():
cann_version = get_cann_version()
soc_version = get_soc_version()
model_list = [
"turbo",
"distil-medium.en",
"distil-small.en",
"tiny.en",
"base.en",
"small.en",
"medium.en",
"tiny",
"base",
"small",
"medium",
"medium-aishell",
]

configs = [
Config(cann=cann, soc_version=soc, model=model)
for cann, soc, model in itertools.product(cann_version, soc_version, model_list)
]

ans = [asdict(c) for c in configs]

print(json.dumps({"include": ans}))


if __name__ == "__main__":
main()
91 changes: 89 additions & 2 deletions .github/workflows/export-paraformer-to-ascend-npu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: export-paraformer-to-ascend-npu
on:
push:
branches:
- ascend-910b4-2
- ci-export-whisper-ascend-npu-2
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Install curl
shell: bash
run: apt-get update && apt-get install -y curl bzip2
run: apt-get update && apt-get install -y curl bzip2 git git-lfs

- name: Verify environment
shell: bash
Expand Down Expand Up @@ -127,6 +127,8 @@ jobs:
python3 ./export_decoder_onnx.py
python3 ./export_predictor_onnx.py

rm -v *.pt

ls -lh *.onnx

source /usr/local/Ascend/ascend-toolkit/set_env.sh
Expand Down Expand Up @@ -171,6 +173,8 @@ jobs:

ls -lh *.om

rm -v *.onnx


echo "collect results"
d=sherpa-onnx-ascend-${soc_version}-cann-$cann-paraformer-zh-2023-03-28
Expand All @@ -191,6 +195,8 @@ jobs:
ls -lh *.tar.bz2
rm -rf $d

rm -v *.om

echo "----show---"
ls -lh *.tar.bz2

Expand Down Expand Up @@ -267,6 +273,7 @@ jobs:

ls -lh *.om

rm -v *.onnx

echo "collect results"
d=sherpa-onnx-ascend-${soc_version}-cann-$cann-paraformer-zh-2025-10-07
Expand All @@ -287,6 +294,8 @@ jobs:
ls -lh *.tar.bz2
rm -rf $d

rm -v *.om

echo "----show---"
ls -lh *.tar.bz2

Expand All @@ -311,3 +320,81 @@ jobs:
file: ./*.tar.bz2
overwrite: true
tag: asr-models-ascend

- name: Publish to huggingface
if: true
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"
for m in "*.tar.bz2"; do
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models huggingface

d=asr-models/ascend-npu/paraformer
mkdir -p huggingface/$d

cp -v $m huggingface/$d/

pushd huggingface
git lfs track "*.tar.bz2"
ls -lh $d
pushd $d
git lfs track "*.tar.bz2"
popd

git status
git add .

git commit -m "add $m"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models main
popd
done
rm -rf huggingface

- name: Publish to modelscope
if: true
env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_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"
for m in "*.tar.bz2"; do
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false

rm -rf ms
git clone https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git ms

d=ascend-npu/paraformer
mkdir -p ms/$d

cp -av $m ms/$d/

pushd ms
git lfs track "*.tar.bz2"
git status
ls -lh $d/$m

ls -lh $d
git add .

git commit -m "add $m"
git push https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git

popd
done
rm -rf ms
95 changes: 93 additions & 2 deletions .github/workflows/export-sense-voice-to-ascend-npu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: export-sense-voice-to-ascend-npu
on:
push:
branches:
- ascend-910b4-2
- ci-export-whisper-ascend-npu-2
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:

- name: Install curl
shell: bash
run: apt-get update && apt-get install -y curl bzip2
run: apt-get update && apt-get install -y curl bzip2 git git-lfs

- name: Verify environment
shell: bash
Expand Down Expand Up @@ -116,6 +116,7 @@ jobs:
echo "export to onnx"

python3 ./export_onnx.py
rm -v *.pt

ls -lh *.onnx

Expand All @@ -137,6 +138,8 @@ jobs:
--input_shape="x:1,-1,560;prompt:4" \
--soc_version="Ascend${soc_version}"

rm -v *.onnx

ls -lh *.om

echo "collect results"
Expand All @@ -156,6 +159,8 @@ jobs:
ls -lh *.tar.bz2
rm -rf $d

rm -v *.om

echo "----show---"
ls -lh *.tar.bz2

Expand Down Expand Up @@ -186,6 +191,7 @@ jobs:

echo "export to onnx"
python3 ./export_onnx.py
rm -v *.pt

ls -lh *.onnx

Expand All @@ -207,6 +213,7 @@ jobs:
--input_shape="x:1,-1,560;prompt:4" \
--soc_version="Ascend${soc_version}"

rm -v *.onnx
ls -lh *.om

echo "collect results"
Expand All @@ -225,6 +232,8 @@ jobs:
ls -lh *.tar.bz2
rm -rf $d

rm -v *.om

echo "----show---"
ls -lh *.tar.bz2

Expand All @@ -249,3 +258,85 @@ jobs:
file: ./*.tar.bz2
overwrite: true
tag: asr-models-ascend

- name: Publish to huggingface
if: true
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"
for m in "*.tar.bz2"; do
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
rm -rf huggingface
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models huggingface

d=asr-models/ascend-npu/sense-voice
mkdir -p huggingface/$d

cp -v $m huggingface/$d/

pushd huggingface
git lfs track "*.tar.bz2"
ls -lh $d/$m

ls -lh $d

pushd $d
git lfs track "*.tar.bz2"
popd

git status
git add .

git commit -m "add $m"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models main
popd
done

rm -rf huggingface

- name: Publish to modelscope
if: true
env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_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"
for m in "*.tar.bz2"; do
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false

rm -rf ms
git clone https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git ms

d=ascend-npu/sense-voice
mkdir -p ms/$d

cp -av $m ms/$d/

pushd ms
git lfs track "*.tar.bz2"
git status
ls -lh $d/$m

ls -lh $d
git add .

git commit -m "add $m"
git push https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git

popd
done
rm -rf ms
Loading