Skip to content

feat(sherpa-onnx): add Kokoro TTS + multilingual Piper voices#10309

Merged
mudler merged 1 commit into
masterfrom
feat/sherpa-onnx-kokoro-voices
Jun 13, 2026
Merged

feat(sherpa-onnx): add Kokoro TTS + multilingual Piper voices#10309
mudler merged 1 commit into
masterfrom
feat/sherpa-onnx-kokoro-voices

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

Adds Kokoro TTS support to the sherpa-onnx backend (it previously only wired the VITS/Piper config path) and ships a set of multilingual gallery voices.

Backend

  • csrc/shim.{c,h}: new sherpa_shim_tts_config_set_kokoro_* setters (model / voices / tokens / data_dir / dict_dir / lexicon / lang / length_scale) mirroring the existing VITS setters, plus the matching frees in tts_config_free.
  • backend.go: loadTTS now detects a Kokoro model (a voices.bin next to the ONNX) and routes to configureKokoroTTS; everything else stays on the refactored configureVitsTTS. Kokoro picks up espeak-ng-data, the jieba dict/ and the per-language lexicons. Only one English lexicon variant is passed (US preferred) to avoid tens of thousands of "duplicated word" warnings at load; the language= model option hints the Kokoro language.
  • backend_test.go: functional unit test for isKokoroModel.

Gallery

Six new entries served via sherpa-onnx-tts.yaml (native streaming TTS), archives auto-extracted:

Entry Language License
vits-piper-it_IT-paola-sherpa Italian other
vits-piper-en_US-amy-sherpa English other
vits-piper-es_ES-davefx-sherpa Spanish CC0
vits-piper-fr_FR-siwis-sherpa French CC-BY 4.0
vits-piper-de_DE-thorsten-sherpa German CC0
kokoro-multi-lang-v1.0-sherpa multilingual (incl. Italian) Apache-2.0

Why

The backend could only run VITS/Piper models, so the rich Kokoro multilingual model (which covers Italian and many other languages in a single model) was unusable. This also gives first-class non-English TTS voices that pair with the realtime streaming-TTS pipeline.

Testing

Built the sherpa-onnx backend from source and synthesized with a real Piper model (it_IT-paola) and the real Kokoro multi-lang model via a local synth smoke spec: both produce valid WAVs. Full suite: 31/31 specs pass, gofmt and golangci-lint (new-from-merge-base) clean.

Assisted-by: Claude:claude-opus-4-8 gofmt golangci-lint go-test

Wire the Kokoro model family into the sherpa-onnx backend (which only
supported VITS/Piper before) and add gallery voices for Italian, English,
Spanish, French and German plus a multilingual Kokoro model.

- csrc/shim.{c,h}: kokoro_* config setters (model/voices/tokens/data_dir/
  dict_dir/lexicon/lang/length_scale) mirroring the VITS path, with the
  matching frees in tts_config_free.
- backend.go: loadTTS now detects a Kokoro model (a voices.bin beside the
  ONNX) and routes to configureKokoroTTS, otherwise configureVitsTTS.
  Kokoro picks up espeak-ng-data, the jieba dict and the per-language
  lexicons (only one English variant, to avoid tens of thousands of
  duplicate-word warnings at load); the language= option hints the lang.
- backend_test.go: functional test for isKokoroModel detection.
- gallery: 5 Piper VITS voices (it_IT-paola, en_US-amy, es_ES-davefx,
  fr_FR-siwis, de_DE-thorsten) + kokoro-multi-lang-v1.0, served through
  sherpa-onnx-tts.yaml with native streaming TTS.

Verified by building the backend and synthesizing with a real Piper and
Kokoro model (31/31 specs pass, including real-model synth smokes).

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 gofmt golangci-lint go-test
@localai-bot

Copy link
Copy Markdown
Collaborator Author

Real end-to-end verification

Ran the prebuilt local-ai against this branch's gallery index (served over HTTP) with the freshly-built sherpa-onnx backend registered as an external gRPC backend. Full pipeline per voice: gallery list → install (real download from the k2-fsa GitHub releases → archive auto-extract → model config generation) → /v1/audio/speech → external backend over gRPC → WAV out.

Voice Code path Result
vits-piper-it_IT-paola-sherpa (Italian) configureVitsTTS HTTP 200, 22050 Hz WAV, 104 KB
vits-piper-de_DE-thorsten-sherpa (German) configureVitsTTS HTTP 200, 22050 Hz WAV, 100 KB
kokoro-multi-lang-v1.0-sherpa (multilingual) configureKokoroTTS (new) HTTP 200, 24000 Hz WAV, 194 KB

What this confirms beyond the unit test:

  • Gallery entry correctness - the generated config resolved parameters.model to the extracted path (e.g. vits-piper-it_IT-paola-medium/it_IT-paola-medium.onnx), the tarball extracted there, and the backend loaded it.
  • Kokoro end-to-end through the server, with 0 "duplicated word" warnings (the single-English-lexicon choice held in the real path).
  • The OpenAI-compatible /v1/audio/speech endpoint works for all three.

Coverage note: 3 of the 6 entries (it/de Piper + Kokoro) were fully synthesized. The remaining en_US-amy, es_ES-davefx, fr_FR-siwis Piper entries use the identical code path and gallery structure, and their sha256 + internal onnx paths were verified directly against the downloaded tarballs when authoring the entries.

@mudler
mudler merged commit 2034108 into master Jun 13, 2026
62 checks passed
@mudler
mudler deleted the feat/sherpa-onnx-kokoro-voices branch June 13, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants