@@ -3,7 +3,7 @@ name: export-kokoro-to-onnx
33on :
44 push :
55 branches :
6- - fix-export- kokoro-1.0 -2
6+ - refactor- kokoro-2
77
88 workflow_dispatch :
99
@@ -34,24 +34,94 @@ jobs:
3434 - name : Install Python dependencies
3535 shell : bash
3636 run : |
37- pip install kokoro "numpy<=1.26.4" onnx==1.16.0 onnxruntime==1.17.1 librosa soundfile piper_phonemize -f https://k2-fsa.github.io/icefall/piper_phonemize.html misaki[en] misaki[zh] torch==2.6.0+cpu -f https://download.pytorch.org/whl/torch
37+ pip install kokoro "numpy<=1.26.4" onnx==1.16.0 onnxruntime==1.17.1 librosa soundfile piper_phonemize -f https://k2-fsa.github.io/icefall/piper_phonemize.html misaki[en] misaki[zh] torch==2.6.0+cpu -f https://download.pytorch.org/whl/torch sherpa-onnx
3838
3939 - name : Run
40+ env :
41+ HF_TOKEN : ${{ secrets.HF_TOKEN }}
4042 shell : bash
4143 run : |
4244 curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/espeak-ng-data.tar.bz2
4345 tar xf espeak-ng-data.tar.bz2
4446 rm espeak-ng-data.tar.bz2
47+ cp -a ./espeak-ng-data ./scripts/kokoro/v0.19
48+ cp -a ./espeak-ng-data ./scripts/kokoro/v1.0
49+ cp -a ./espeak-ng-data ./scripts/kokoro/v1.1-zh
50+
51+ git config --global user.email "csukuangfj@gmail.com"
52+ git config --global user.name "Fangjun Kuang"
53+
4554 cd scripts/kokoro
4655 v=${{ matrix.version }}
4756 if [[ $v = "0.19" ]]; then
57+ cd v0.19
4858 ./run.sh
59+
60+ if false; then
61+ # generate samples
62+ git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples hf
63+ mkdir -p hf/kokoro/v0.19/mp3
64+ ./generate_samples.py
65+ pushd hf
66+ git pull
67+ git add .
68+ git commit -m 'add kokoro samples for v0.19'
69+ git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples main
70+ popd
71+ rm -rf hf
72+ fi
73+
4974 elif [[ $v == "1.0" ]]; then
5075 cd v1.0
5176 ./run.sh
77+
78+ if false; then
79+ git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples hf
80+ mkdir -p hf/kokoro/v1.0/mp3
81+
82+ curl -SL -O https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2
83+ tar xvf dict.tar.bz2
84+ rm dict.tar.bz2
85+
86+ curl -SL -o date-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/date.fst
87+ curl -SL -o number-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/number.fst
88+ curl -SL -o phone-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/phone.fst
89+
90+ ./generate_samples.py
91+ pushd hf
92+ git pull
93+ git add .
94+ git commit -m 'add kokoro samples for v1.0'
95+ git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples main
96+ popd
97+ rm -rf hf
98+ fi
99+
52100 elif [[ $v == "1.1-zh" ]]; then
53101 cd v1.1-zh
54102 ./run.sh
103+
104+ if false; then
105+ git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples hf
106+ mkdir -p hf/kokoro/v1.1-zh/mp3
107+
108+ curl -SL -O https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2
109+ tar xvf dict.tar.bz2
110+ rm dict.tar.bz2
111+
112+ curl -SL -o date-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/date.fst
113+ curl -SL -o number-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/number.fst
114+ curl -SL -o phone-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/phone.fst
115+
116+ ./generate_samples.py
117+ pushd hf
118+ git pull
119+ git add .
120+ git commit -m 'add kokoro samples for v1.1-zh'
121+ git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-tts-samples main
122+ popd
123+ rm -rf hf
124+ fi
55125 else
56126 echo "Unknown version $v"
57127 exit 1
@@ -61,19 +131,39 @@ jobs:
61131 if : matrix.version == '0.19'
62132 shell : bash
63133 run : |
64- src=scripts/kokoro
134+ src=scripts/kokoro/v0.19
65135
66136 d=kokoro-en-v0_19
137+
67138 mkdir $d
68139 cp -a LICENSE $d/LICENSE
69140 cp -a espeak-ng-data $d/
70- cp -v $src/kokoro-v0_19 .onnx $d/model.onnx
141+ cp -v $src/model .onnx $d/model.onnx
71142 cp -v $src/voices.bin $d/
72143 cp -v $src/tokens.txt $d/
73- cp -v $src/README-new.md $d/README.md
144+ cp -v $src/../README.md $d/README.md
145+ ls -lh $d/
146+ tar cjfv $d.tar.bz2 $d
147+
148+ ls -lh $d.tar.bz2
149+
150+ - name : Collect results 0.19 (int8)
151+ if : matrix.version == '0.19'
152+ shell : bash
153+ run : |
154+ src=scripts/kokoro/v0.19
155+
156+ d=kokoro-int8-en-v0_19
157+
158+ mkdir $d
159+ cp -a LICENSE $d/LICENSE
160+ cp -a espeak-ng-data $d/
161+ cp -v $src/model.int8.onnx $d/model.int8.onnx
162+ cp -v $src/voices.bin $d/
163+ cp -v $src/tokens.txt $d/
164+ cp -v $src/../README.md $d/README.md
74165 ls -lh $d/
75166 tar cjfv $d.tar.bz2 $d
76- rm -rf $d
77167
78168 ls -lh $d.tar.bz2
79169
@@ -219,41 +309,39 @@ jobs:
219309 git config --global user.email "csukuangfj@gmail.com"
220310 git config --global user.name "Fangjun Kuang"
221311
222- rm -rf huggingface
312+ dirs=(
313+ kokoro-en-v0_19
314+ # kokoro-int8-en-v0_19
315+ )
316+
223317 export GIT_LFS_SKIP_SMUDGE=1
224318 export GIT_CLONE_PROTECTION_ACTIVE=false
319+ for d in ${dirs[@]}; do
320+ rm -rf huggingface
225321
226- git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-en-v0_19 huggingface
227- cd huggingface
228- rm -rf ./*
229- git fetch
230- git pull
322+ git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-en-v0_19 huggingface
323+ cd huggingface
324+ rm -rf ./*
231325
232- git lfs track "cmn_dict"
233- git lfs track "ru_dict"
234- git lfs track "*.wav"
326+ git lfs track "*.onnx"
327+ git lfs track af_dict
328+ git lfs track ar_dict
329+ git lfs track cmn_dict
330+ git lfs track da_dict en_dict fa_dict hu_dict ia_dict it_dict lb_dict phondata ru_dict ta_dict
331+ git lfs track ur_dict yue_dict
235332
236- cp -a ../espeak-ng-data ./
237- mkdir -p test_wavs
238333
239- cp -v ../scripts/kokoro/kokoro-v0_19.onnx ./model.onnx
334+ cp -a ../$d ./
240335
241- cp -v ../scripts/kokoro/kokoro-v0_19-*.wav ./test_wavs/
336+ git add .
242337
243- cp -v ../scripts/kokoro/tokens.txt .
244- cp -v ../scripts/kokoro/voices.bin .
245- cp -v ../scripts/kokoro/README-new.md ./README.md
246- cp -v ../LICENSE ./
338+ ls -lh
247339
248- git lfs track "*.onnx"
249- git add .
340+ git status
250341
251- ls -lh
252-
253- git status
254-
255- git commit -m "add models"
256- git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-en-v0_19 main || true
342+ git commit -m "add models"
343+ git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-en-v0_19 main || true
344+ done
257345
258346 - name : Publish to huggingface 1.0 float32
259347 if : matrix.version == '1.0'
0 commit comments