Export Kokoro 1.0 to sherpa-onnx (#1788)

This commit is contained in:
Fangjun Kuang
2025-02-05 08:24:43 +08:00
committed by GitHub
parent 8677d83efc
commit 08cefe8488
13 changed files with 706 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ on:
push:
branches:
- export-kokoro
- kokoro-1.0-2
workflow_dispatch:
@@ -14,12 +15,13 @@ concurrency:
jobs:
export-kokoro-to-onnx:
if: github.repository_owner == 'k2-fsa' || github.repository_owner == 'csukuangfj'
name: export kokoro
name: export kokoro ${{ matrix.version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: ["0.19", "1.0"]
python-version: ["3.10"]
steps:
@@ -33,7 +35,7 @@ jobs:
- name: Install Python dependencies
shell: bash
run: |
pip install -q "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
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
- name: Run
shell: bash
@@ -42,9 +44,16 @@ jobs:
tar xf espeak-ng-data.tar.bz2
rm espeak-ng-data.tar.bz2
cd scripts/kokoro
./run.sh
v=${{ matrix.version }}
if [[ $v = "0.19" ]]; then
./run.sh
elif [[ $v == "1.0" ]]; then
cd v1.0
./run.sh
fi
- name: Collect results
- name: Collect results ${{ matrix.version }}
if: matrix.version == '0.19'
shell: bash
run: |
src=scripts/kokoro
@@ -53,7 +62,7 @@ jobs:
mkdir $d
cp -a LICENSE $d/LICENSE
cp -a espeak-ng-data $d/
cp -v $src/kokoro-v0_19_hf.onnx $d/model.onnx
cp -v $src/kokoro-v0_19.onnx $d/model.onnx
cp -v $src/voices.bin $d/
cp -v $src/tokens.txt $d/
cp -v $src/README-new.md $d/README.md
@@ -61,9 +70,31 @@ jobs:
tar cjfv $d.tar.bz2 $d
rm -rf $d
ls -h $.tar.bz2
ls -lh $d.tar.bz2
- name: Publish to huggingface
- name: Collect results ${{ matrix.version }}
if: matrix.version == '1.0'
shell: bash
run: |
src=scripts/kokoro/v1.0
d=kokoro-multi-lang-v1_0
mkdir $d
cp -a LICENSE $d/LICENSE
cp -a espeak-ng-data $d/
cp -v $src/kokoro.onnx $d/model.onnx
cp -v $src/voices.bin $d/
cp -v $src/tokens.txt $d/
cp -v $src/lexicon*.txt $d/
cp -v $src/README.md $d/README.md
ls -lh $d/
tar cjfv $d.tar.bz2 $d
rm -rf $d
ls -lh $d.tar.bz2
- name: Publish to huggingface ${{ matrix.version }}
if: matrix.version == '0.19'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
@@ -92,9 +123,9 @@ jobs:
cp -a ../espeak-ng-data ./
mkdir -p test_wavs
cp -v ../scripts/kokoro/kokoro-v0_19_hf.onnx ./model.onnx
cp -v ../scripts/kokoro/kokoro-v0_19.onnx ./model.onnx
cp -v ../scripts/kokoro/kokoro-v0_19_hf-*.wav ./test_wavs/
cp -v ../scripts/kokoro/kokoro-v0_19-*.wav ./test_wavs/
cp -v ../scripts/kokoro/tokens.txt .
cp -v ../scripts/kokoro/voices.bin .
@@ -111,6 +142,55 @@ jobs:
git commit -m "add models"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-en-v0_19 main || true
- name: Publish to huggingface ${{ matrix.version }}
if: matrix.version == '1.0'
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"
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-multi-lang-v1_0 huggingface
cd huggingface
rm -rf ./*
git fetch
git pull
git lfs track "cmn_dict"
git lfs track "ru_dict"
git lfs track "*.wav"
git lfs track "lexicon*.txt"
cp -a ../espeak-ng-data ./
cp -v ../scripts/kokoro/v1.0/kokoro.onnx ./model.onnx
cp -v ../scripts/kokoro/v1.0/tokens.txt .
cp -v ../scripts/kokoro/v1.0/voices.bin .
cp -v ../scripts/kokoro/v1.0/lexicon*.txt .
cp -v ../scripts/kokoro/v1.0/README.md ./README.md
cp -v ../LICENSE ./
git lfs track "*.onnx"
git add .
ls -lh
git status
git commit -m "add models"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kokoro-multi-lang-v1_0 main || true
- name: Release
uses: svenstaro/upload-release-action@v2
with: