Skip to content

Commit d5da943

Browse files
authored
Add PengChengStarling models to sherpa-onnx (#1835)
1 parent 2ac41d3 commit d5da943

File tree

7 files changed

+190
-2
lines changed

7 files changed

+190
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: export-peng-cheng-starling-to-onnx
2+
3+
on:
4+
push:
5+
branches:
6+
- export-peng-cheng-starling-2
7+
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: export-peng-cheng-starling-to-onnx-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
export-peng-cheng-starling-to-onnx:
16+
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
17+
name: export peng cheng starling ${{ matrix.version }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest]
23+
python-version: ["3.10"]
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install Python dependencies
34+
shell: bash
35+
run: |
36+
pip install "numpy<=1.26.4" onnx==1.16.0 onnxruntime==1.17.1
37+
38+
- name: Run
39+
shell: bash
40+
run: |
41+
cd scripts/peng-cheng-starling
42+
./run.sh
43+
python3 ./quantize_models.py
44+
45+
ls -lh
46+
rm encoder-epoch-75-avg-11-chunk-16-left-128.onnx
47+
rm joiner-epoch-75-avg-11-chunk-16-left-128.onnx
48+
echo "----"
49+
ls -lh
50+
51+
52+
- name: Collect results ${{ matrix.version }}
53+
shell: bash
54+
run: |
55+
src=scripts/peng-cheng-starling
56+
d=sherpa-onnx-streaming-zipformer-ar_en_id_ja_ru_th_vi_zh-2025-02-10
57+
mkdir $d
58+
59+
mv -v $src/*.onnx $d
60+
cp -v $src/README.md $d
61+
cp -v $src/bpe.model $d
62+
cp -av $src/test_wavs $d
63+
64+
ls -lh $d/
65+
tar cjfv $d.tar.bz2 $d
66+
67+
ls -lh $d.tar.bz2
68+
69+
- name: Publish to huggingface ${{ matrix.version }}
70+
env:
71+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
72+
uses: nick-fields/retry@v3
73+
with:
74+
max_attempts: 20
75+
timeout_seconds: 200
76+
shell: bash
77+
command: |
78+
git config --global user.email "csukuangfj@gmail.com"
79+
git config --global user.name "Fangjun Kuang"
80+
81+
rm -rf huggingface
82+
export GIT_LFS_SKIP_SMUDGE=1
83+
export GIT_CLONE_PROTECTION_ACTIVE=false
84+
85+
src=sherpa-onnx-streaming-zipformer-ar_en_id_ja_ru_th_vi_zh-2025-02-10
86+
87+
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$src huggingface
88+
cd huggingface
89+
rm -rf ./*
90+
git fetch
91+
git pull
92+
93+
cp -av ../$src/* ./
94+
95+
git lfs track "*.onnx"
96+
git add .
97+
98+
ls -lh
99+
100+
git status
101+
102+
git commit -m "add models"
103+
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$src main || true
104+
105+
- name: Release
106+
if: github.repository_owner == 'csukuangfj'
107+
uses: svenstaro/upload-release-action@v2
108+
with:
109+
file_glob: true
110+
file: ./*.tar.bz2
111+
overwrite: true
112+
repo_name: k2-fsa/sherpa-onnx
113+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
114+
tag: asr-models
115+
116+
- name: Release
117+
if: github.repository_owner == 'k2-fsa'
118+
uses: svenstaro/upload-release-action@v2
119+
with:
120+
file_glob: true
121+
file: ./*.tar.bz2
122+
overwrite: true
123+
tag: asr-models

scripts/matcha-tts/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
This folder contains script for adding meta data to tts models
3+
This folder contains scripts for adding meta data to tts models
44
from https://github.com/shivammehta25/Matcha-TTS
55

66
Note: If you use icefall to train a MatchaTTS model, you don't need this folder.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bpe.model
2+
*.wav
3+
*.onnx

scripts/peng-cheng-starling/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Introduction
2+
3+
This folder contains scripts for files from
4+
https://github.com/yangb05/PengChengStarling
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
from onnxruntime.quantization import QuantType, quantize_dynamic
3+
from pathlib import Path
4+
5+
6+
def main():
7+
suffix = "epoch-75-avg-11-chunk-16-left-128"
8+
9+
for m in ["encoder", "joiner"]:
10+
if Path(f"{m}-{suffix}.int8.onnx").is_file():
11+
continue
12+
13+
quantize_dynamic(
14+
model_input=f"./{m}-{suffix}.onnx",
15+
model_output=f"./{m}-{suffix}.int8.onnx",
16+
op_types_to_quantize=["MatMul"],
17+
weight_type=QuantType.QInt8,
18+
)
19+
20+
21+
if __name__ == "__main__":
22+
main()

scripts/peng-cheng-starling/run.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
if [ ! -f bpe.model ]; then
6+
curl -SL -O https://huggingface.co/stdo/PengChengStarling/resolve/main/bpe.model
7+
fi
8+
9+
if [ ! -f tokens.txt ]; then
10+
curl -SL -O https://huggingface.co/stdo/PengChengStarling/resolve/main/tokens.txt
11+
fi
12+
13+
if [ ! -f decoder-epoch-75-avg-11-chunk-16-left-128.onnx ]; then
14+
curl -SL -O https://huggingface.co/stdo/PengChengStarling/resolve/main/decoder-epoch-75-avg-11-chunk-16-left-128.onnx
15+
fi
16+
17+
if [ ! -f encoder-epoch-75-avg-11-chunk-16-left-128.onnx ]; then
18+
curl -SL -O https://huggingface.co/stdo/PengChengStarling/resolve/main/encoder-epoch-75-avg-11-chunk-16-left-128.onnx
19+
fi
20+
21+
if [ ! -f joiner-epoch-75-avg-11-chunk-16-left-128.onnx ]; then
22+
curl -SL -O https://huggingface.co/stdo/PengChengStarling/resolve/main/joiner-epoch-75-avg-11-chunk-16-left-128.onnx
23+
fi
24+
25+
mkdir -p test_wavs
26+
if [ ! -f test_wavs/zh.wav ]; then
27+
curl -SL --output test_wavs/zh.wav https://huggingface.co/marcoyang/sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23/resolve/main/test_wavs/0.wav
28+
fi
29+
30+
if [ ! -f test_wavs/en.wav ]; then
31+
curl -SL --output test_wavs/en.wav https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-02-21/resolve/main/test_wavs/0.wav
32+
fi
33+
34+
if [ ! -f test_wavs/ja.wav ]; then
35+
curl -SL --output test_wavs/ja.wav https://huggingface.co/csukuangfj/reazonspeech-k2-v2/resolve/main/test_wavs/5.wav
36+
fi

sherpa-onnx/csrc/offline-tts.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct OfflineTtsConfig {
3232
// If you set it to -1, then we process all sentences in a single batch.
3333
int32_t max_num_sentences = 1;
3434

35-
// A silence interval containing audio samples with value close to 0.
35+
// A silence interval contains audio samples with value close to 0.
3636
//
3737
// the duration of the new interval is old_duration * silence_scale.
3838
float silence_scale = 0.2;

0 commit comments

Comments
 (0)