Skip to content

Commit bab5566

Browse files
Merge branch 'k2-fsa:master' into patch-1
2 parents 890a141 + dfcbc8d commit bab5566

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1390
-79
lines changed

.github/workflows/build-wheels-linux-cuda.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ jobs:
3434
- name: Install Python dependencies
3535
shell: bash
3636
run: |
37-
pip install -U pip wheel setuptools twine==5.0.0
37+
if [[ ${{ matrix.python-version }} == "3.7" ]]; then
38+
pip install -U pip wheel setuptools twine
39+
else
40+
pip install -U pip wheel setuptools twine==5.0.0
41+
fi
3842
3943
- name: Build alsa-lib
4044
shell: bash

.github/workflows/build-wheels-macos-x64.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ jobs:
110110
fi
111111
112112
python3 -m pip install $opts --upgrade pip
113-
python3 -m pip install $opts wheel twine==5.0.0 setuptools
113+
if [[ ${{ matrix.python-version }} == "cp37" ]]; then
114+
python3 -m pip install $opts wheel twine setuptools
115+
else
116+
python3 -m pip install $opts wheel twine==5.0.0 setuptools
117+
fi
114118
115119
twine upload ./wheelhouse/*.whl

.github/workflows/build-wheels-win64.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,16 @@ jobs:
8989
git push https://csukuangfj:[email protected]/csukuangfj/sherpa-onnx-wheels main
9090
9191
- name: Publish wheels to PyPI
92+
shell: bash
9293
env:
9394
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
9495
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
9596
run: |
9697
python3 -m pip install --upgrade pip
97-
python3 -m pip install wheel twine==5.0.0 setuptools
98+
if [[ ${{ matrix.python-version }} == "3.7" ]]; then
99+
python3 -m pip install wheel twine setuptools
100+
else
101+
python3 -m pip install wheel twine==5.0.0 setuptools
102+
fi
98103
99104
twine upload ./wheelhouse/*.whl

.github/workflows/export-kokoro.yaml

Lines changed: 172 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: export-kokoro-to-onnx
33
on:
44
push:
55
branches:
6-
- export-kokoro
6+
- export-kokoro-2
77

88
workflow_dispatch:
99

@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
version: ["0.19", "1.0"]
23+
version: ["0.19", "1.0", "1.1-zh"]
2424
python-version: ["3.10"]
2525

2626
steps:
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install Python dependencies
3535
shell: bash
3636
run: |
37-
pip install "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
3838
3939
- name: Run
4040
shell: bash
@@ -49,9 +49,15 @@ jobs:
4949
elif [[ $v == "1.0" ]]; then
5050
cd v1.0
5151
./run.sh
52+
elif [[ $v == "1.1-zh" ]]; then
53+
cd v1.1-zh
54+
./run.sh
55+
else
56+
echo "Unknown version $v"
57+
exit 1
5258
fi
5359
54-
- name: Collect results ${{ matrix.version }}
60+
- name: Collect results 0.19
5561
if: matrix.version == '0.19'
5662
shell: bash
5763
run: |
@@ -71,7 +77,7 @@ jobs:
7177
7278
ls -lh $d.tar.bz2
7379
74-
- name: Collect results ${{ matrix.version }}
80+
- name: Collect results 1.0
7581
if: matrix.version == '1.0'
7682
shell: bash
7783
run: |
@@ -87,7 +93,7 @@ jobs:
8793
8894
d=kokoro-multi-lang-v1_0
8995
mkdir $d
90-
cp -a LICENSE $d/LICENSE
96+
cp -v LICENSE $d/LICENSE
9197
cp -a espeak-ng-data $d/
9298
cp -v $src/kokoro.onnx $d/model.onnx
9399
cp -v $src/voices.bin $d/
@@ -105,7 +111,63 @@ jobs:
105111
106112
ls -lh $d.tar.bz2
107113
108-
- name: Publish to huggingface ${{ matrix.version }}
114+
- name: Collect results 1.1-zh
115+
if: matrix.version == '1.1-zh'
116+
shell: bash
117+
run: |
118+
curl -SL -O https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2
119+
tar xvf dict.tar.bz2
120+
rm dict.tar.bz2
121+
122+
curl -SL -o date-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/date.fst
123+
curl -SL -o number-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/number.fst
124+
curl -SL -o phone-zh.fst https://huggingface.co/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/main/data/phone.fst
125+
126+
src=scripts/kokoro/v1.1-zh
127+
128+
d=kokoro-multi-lang-v1_1
129+
mkdir $d
130+
cp -v LICENSE $d/LICENSE
131+
cp -a espeak-ng-data $d/
132+
cp -v $src/kokoro.onnx $d/model.onnx
133+
cp -v $src/voices.bin $d/
134+
cp -v $src/tokens.txt $d/
135+
cp -v $src/lexicon*.txt $d/
136+
cp -v $src/README.md $d/README.md
137+
cp -av dict $d/
138+
cp -v ./*.fst $d/
139+
ls -lh $d/
140+
echo "---"
141+
ls -lh $d/dict
142+
143+
tar cjfv $d.tar.bz2 $d
144+
rm -rf $d
145+
ls -lh $d.tar.bz2
146+
147+
d=kokoro-int8-multi-lang-v1_1
148+
mkdir $d
149+
cp -v LICENSE $d/LICENSE
150+
cp -a espeak-ng-data $d/
151+
cp -v $src/kokoro.int8.onnx $d/model.int8.onnx
152+
cp -v $src/voices.bin $d/
153+
cp -v $src/tokens.txt $d/
154+
cp -v $src/lexicon*.txt $d/
155+
cp -v $src/README.md $d/README.md
156+
cp -av dict $d/
157+
cp -v ./*.fst $d/
158+
ls -lh $d/
159+
echo "---"
160+
ls -lh $d/dict
161+
162+
tar cjfv $d.tar.bz2 $d
163+
rm -rf $d
164+
ls -lh $d.tar.bz2
165+
166+
echo "---"
167+
ls -lh *.tar.bz2
168+
169+
170+
- name: Publish to huggingface 0.19
109171
if: matrix.version == '0.19'
110172
env:
111173
HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -154,7 +216,7 @@ jobs:
154216
git commit -m "add models"
155217
git push https://csukuangfj:[email protected]/csukuangfj/kokoro-en-v0_19 main || true
156218
157-
- name: Publish to huggingface ${{ matrix.version }}
219+
- name: Publish to huggingface 1.0
158220
if: matrix.version == '1.0'
159221
env:
160222
HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -205,6 +267,108 @@ jobs:
205267
git commit -m "add models"
206268
git push https://csukuangfj:[email protected]/csukuangfj/kokoro-multi-lang-v1_0 main || true
207269
270+
- name: Publish to huggingface 1.1-zh
271+
if: matrix.version == '1.1-zh'
272+
env:
273+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
274+
uses: nick-fields/retry@v3
275+
with:
276+
max_attempts: 20
277+
timeout_seconds: 200
278+
shell: bash
279+
command: |
280+
git config --global user.email "[email protected]"
281+
git config --global user.name "Fangjun Kuang"
282+
283+
rm -rf huggingface
284+
export GIT_LFS_SKIP_SMUDGE=1
285+
export GIT_CLONE_PROTECTION_ACTIVE=false
286+
287+
git clone https://csukuangfj:[email protected]/csukuangfj/kokoro-multi-lang-v1_1 huggingface
288+
cd huggingface
289+
rm -rf ./*
290+
git fetch
291+
git pull
292+
293+
git lfs track "cmn_dict"
294+
git lfs track "ru_dict"
295+
git lfs track "*.wav"
296+
git lfs track "lexicon*.txt"
297+
298+
cp -a ../espeak-ng-data ./
299+
300+
cp -v ../scripts/kokoro/v1.1-zh/kokoro.onnx ./model.onnx
301+
302+
303+
cp -v ../scripts/kokoro/v1.1-zh/tokens.txt .
304+
cp -v ../scripts/kokoro/v1.1-zh/voices.bin .
305+
cp -v ../scripts/kokoro/v1.1-zh/lexicon*.txt .
306+
cp -v ../scripts/kokoro/v1.1-zh/README.md ./README.md
307+
cp -v ../LICENSE ./
308+
cp -av ../dict ./
309+
cp -v ../*.fst ./
310+
311+
git lfs track "*.onnx"
312+
git add .
313+
314+
ls -lh
315+
316+
git status
317+
318+
git commit -m "add models"
319+
git push https://csukuangfj:[email protected]/csukuangfj/kokoro-multi-lang-v1_1 main || true
320+
321+
- name: Publish to huggingface 1.1-zh-int8
322+
if: matrix.version == '1.1-zh'
323+
env:
324+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
325+
uses: nick-fields/retry@v3
326+
with:
327+
max_attempts: 20
328+
timeout_seconds: 200
329+
shell: bash
330+
command: |
331+
git config --global user.email "[email protected]"
332+
git config --global user.name "Fangjun Kuang"
333+
334+
rm -rf huggingface
335+
export GIT_LFS_SKIP_SMUDGE=1
336+
export GIT_CLONE_PROTECTION_ACTIVE=false
337+
338+
git clone https://csukuangfj:[email protected]/csukuangfj/kokoro-int8-multi-lang-v1_1 huggingface
339+
cd huggingface
340+
rm -rf ./*
341+
git fetch
342+
git pull
343+
344+
git lfs track "cmn_dict"
345+
git lfs track "ru_dict"
346+
git lfs track "*.wav"
347+
git lfs track "lexicon*.txt"
348+
349+
cp -a ../espeak-ng-data ./
350+
351+
cp -v ../scripts/kokoro/v1.1-zh/kokoro.int8.onnx ./model.int8.onnx
352+
353+
354+
cp -v ../scripts/kokoro/v1.1-zh/tokens.txt .
355+
cp -v ../scripts/kokoro/v1.1-zh/voices.bin .
356+
cp -v ../scripts/kokoro/v1.1-zh/lexicon*.txt .
357+
cp -v ../scripts/kokoro/v1.1-zh/README.md ./README.md
358+
cp -v ../LICENSE ./
359+
cp -av ../dict ./
360+
cp -v ../*.fst ./
361+
362+
git lfs track "*.onnx"
363+
git add .
364+
365+
ls -lh
366+
367+
git status
368+
369+
git commit -m "add models"
370+
git push https://csukuangfj:[email protected]/csukuangfj/kokoro-int8-multi-lang-v1_1 main || true
371+
208372
- name: Release
209373
if: github.repository_owner == 'csukuangfj'
210374
uses: svenstaro/upload-release-action@v2

.github/workflows/run-java-test.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ jobs:
105105
make -j4
106106
ls -lh lib
107107
108+
- name: Run java test (Online add punctuations)
109+
shell: bash
110+
run: |
111+
cd ./java-api-examples
112+
./run-online-add-punctuation-zh-en.sh
113+
# Delete model files to save space
114+
rm -rf sherpa-onnx-online-*
115+
116+
- name: Run java test (Offline add punctuations)
117+
shell: bash
118+
run: |
119+
cd ./java-api-examples
120+
./run-offline-add-punctuation-zh-en.sh
121+
# Delete model files to save space
122+
rm -rf sherpa-onnx-punct-*
123+
108124
- name: Run java test (Non-Streaming ASR)
109125
shell: bash
110126
run: |
@@ -196,13 +212,6 @@ jobs:
196212
./run-audio-tagging-ced-from-file.sh
197213
rm -rf sherpa-onnx-ced-*
198214
199-
- name: Run java test (add punctuations)
200-
shell: bash
201-
run: |
202-
cd ./java-api-examples
203-
./run-add-punctuation-zh-en.sh
204-
# Delete model files to save space
205-
rm -rf sherpa-onnx-punct-*
206215
207216
- name: Run java test (Spoken language identification)
208217
shell: bash

.github/workflows/test-go-package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
fetch-depth: 0
4444
- uses: actions/setup-go@v5
4545
with:
46-
go-version: '>=1.12'
46+
go-version: '>=1.17'
4747

4848
- name: Display go version
4949
shell: bash

.github/workflows/test-go.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- uses: actions/setup-go@v5
4949
with:
50-
go-version: '>=1.12'
50+
go-version: '>=1.17'
5151

5252
- name: Display go version
5353
shell: bash

java-api-examples/AddPunctuation.java renamed to java-api-examples/OfflineAddPunctuation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// The model supports both English and Chinese.
66
import com.k2fsa.sherpa.onnx.*;
77

8-
public class AddPunctuation {
8+
public class OfflineAddPunctuation {
99
public static void main(String[] args) {
1010
// please download the model from
1111
// https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 Xiaomi Corporation
2+
3+
// This file shows how to use a punctuation model to add punctuations to text.
4+
//
5+
// The model supports ONLY English.
6+
import com.k2fsa.sherpa.onnx.*;
7+
8+
public class OnlineAddPunctuation {
9+
public static void main(String[] args) {
10+
// please download the model from
11+
// https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-online-punct-en-2024-08-06.tar.bz2
12+
String model = "./sherpa-onnx-online-punct-en-2024-08-06/model.int8.onnx";
13+
String bpeVocab = "./sherpa-onnx-online-punct-en-2024-08-06/bpe.vocab";
14+
OnlinePunctuationModelConfig modelConfig =
15+
OnlinePunctuationModelConfig.builder()
16+
.setCnnBilstm(model)
17+
.setBpeVocab(bpeVocab)
18+
.setNumThreads(1)
19+
.setDebug(true)
20+
.build();
21+
OnlinePunctuationConfig config =
22+
OnlinePunctuationConfig.builder().setModel(modelConfig).build();
23+
24+
OnlinePunctuation punct = new OnlinePunctuation(config);
25+
26+
String[] sentences =
27+
new String[] {
28+
"how are you doing fantastic thank you how about you",
29+
"The African blogosphere is rapidly expanding bringing more voices online in the form of"
30+
+ " commentaries opinions analyses rants and poetry",
31+
};
32+
33+
System.out.println("---");
34+
for (String text : sentences) {
35+
String out = punct.addPunctuation(text);
36+
System.out.printf("Input: %s\n", text);
37+
System.out.printf("Output: %s\n", out);
38+
System.out.println("---");
39+
}
40+
}
41+
}

java-api-examples/run-add-punctuation-zh-en.sh renamed to java-api-examples/run-offline-add-punctuation-zh-en.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ fi
3434
java \
3535
-Djava.library.path=$PWD/../build/lib \
3636
-cp ../sherpa-onnx/java-api/build/sherpa-onnx.jar \
37-
./AddPunctuation.java
37+
./OfflineAddPunctuation.java

0 commit comments

Comments
 (0)