Skip to main content

Swedish voices for Kokoro-82M — one line to speak, 10 named voices, neural Swedish G2P.

Project description

kokoro-sv

Train a native Swedish voice for Kokoro-82M (StyleTTS2 architecture) — from raw data to a fast, deployable multi-speaker model with dynamic prosody and named voices. This repo is code + downloader scripts only; every weight, dataset, and audio file is .gitignored and fetched or regenerated on demand. Trained voices are published to HuggingFace.

Install & use (pip install kokoro-sv)

pip install kokoro-sv
from kokoro_sv import SwedishKokoro
tts = SwedishKokoro()                              # downloads model + G2P from HF, cached
tts.speak("Hej, jag är CandyTron!", voice="Stina", out="hej.wav")
print(tts.voices)                                  # Alice, Elsa, ... Björn, Nils, ...
tts.speak("God morgon!", voice=tts.blend("Björn", "Nils", 0.7), out="mix.wav")

Or the CLI: kokoro-sv speak "Hej" --voice Stina · kokoro-sv voices.

What's here

result
Multi-speaker Swedish base one model, 22+ real Swedish speakers, prosody-responsive (the style vector genuinely steers delivery: 4.9→9.5 semitone range on demand)
10-voice pack 5 female + 5 male named voicepacks (512 KB each), interpolatable
Neural Swedish G2P hybrid NST-lexicon + transformer, with a growing tech/brand lexicon (MQTT, RISE, YOLO, …)
Reproducible pipeline dataset loaders, manifest format, prosody QC battery, training bridge, evaluation

Voices are distilled/trained from CC0 sources (NST + Swedish LibriVox) and published on HF. See the model cards there.

Repository layout

.                     README, LICENSE, gpu_run.sh + the import-backbone modules
  g2p_sv.py           Swedish G2P adapter (imported everywhere)
  nst_g2p.py          neural G2P entry (SV_NEURAL_G2P=nst_g2p)
  synth_real.py       deployable inference (KModel + notch chain)
  eval_renders.py     the ASR-CER + DNSMOS + comb evaluation battery
  kokoro_symbols.py   the 178-slot sparse Kokoro vocab
  g2p/                neural Swedish G2P model code (weights auto-download from HF)
  configs/            all training/model configs (config_sv_*.yml) + pixi
  scripts/            setup, convert, prepare, export, and other standalone tools
  examples/           download the published voices from HF and synthesize
  training/           reproducible multi-speaker pipeline (loaders, train, eval)
  data-gen/           Chatterbox teacher — synthesize single-speaker data
  docs/               training-recipe.md, RUN1.md, PLAN.md

Reproduce, end to end

Nothing but code is committed; these steps download/regenerate everything.

# 0. base weights + kikiri recipe + PL-BERT
bash setup_3090.sh                       # (works on the GB10 too; adjust venv per docs)

# 1. data — streamed from HuggingFace, gender-balanced, quality-gated
cd pipeline
python scripts/prepare_dataset.py nst          --gender Male   --max-hours 5
python scripts/prepare_dataset.py nst          --gender Female --max-hours 5
python scripts/prepare_dataset.py tts_swedish                  --max-hours 5
python scripts/extract_prosody.py --manifest data/manifests/nst.jsonl
python scripts/build_mix.py                     # configs/datasets.yaml

# 2. train the multi-speaker base (StyleTTS2 via kikiri; smoke first!)
python scripts/train_kokoro.py --manifest data/manifests/train_mix.jsonl --name base --smoke --launch
python scripts/train_kokoro.py --manifest data/manifests/train_mix.jsonl --name base --launch

# 3. evaluate EVERY checkpoint (never pick on loss alone)
python scripts/eval_base.py                     # ASR-CER + DNSMOS + comb + prosody-responsiveness

# 4. build a HuggingFace voice pack from chosen speakers
python scripts/build_hf_pack.py "Signe,Astrid,…,Björn,Sven,…"

Alternatively, data-gen/ synthesizes a clean single-speaker corpus with Chatterbox (the RUN1 distillation path) — see data-gen/README.md.

Hard-won lessons (baked into the code)

  1. One compute job at a time. The GB10 has unified CPU+GPU memory; two heavy jobs hard-froze it. Everything runs through gpu_run.sh (kernel flock).
  2. Never rank a checkpoint on one metric. Gate on ASR-CER (intelligibility) → DNSMOS (quality) → artifact metrics. A comb-optimized checkpoint was unintelligible.
  3. Validate the corpus against downstream filters before bulk generation (35 % of an early corpus exceeded the 12 s training cap = wasted GPU).
  4. Prosody lives in the style vector ([128 timbre | 128 prosody]); train on many real speakers so the predictor learns to use it — single-speaker distillation is flat.
  5. The GAN/adversarial stage is needed for decoder quality (with enough data); low decoder-lr prevents the fine-tune upsampler-tone artifacts (notched at inference).

Credits

Built on hexgrad/Kokoro-82M (Apache-2.0), yl4579/StyleTTS2 (MIT), and semidark/kikiri-tts. Data: NST (Språkbanken, CC0) and Swedish LibriVox (TTS-Swedish, CC0). Evaluation: KBLab VoxRex

  • Microsoft DNSMOS. Data manufactured with Chatterbox (MIT).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kokoro_sv-0.1.0.tar.gz (149.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kokoro_sv-0.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file kokoro_sv-0.1.0.tar.gz.

File metadata

  • Download URL: kokoro_sv-0.1.0.tar.gz
  • Upload date:
  • Size: 149.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kokoro_sv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44e2484e4e5a216433820dcd9df70f6ef10162044599e35e413b94080c2dabec
MD5 9431a1828c40be5da50cd681e1f4133d
BLAKE2b-256 4ba25627dcf38c0c2bfe42ea08dbe22ed11346209a53bf5243c3a50b83cf136f

See more details on using hashes here.

File details

Details for the file kokoro_sv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kokoro_sv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kokoro_sv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a46de36448408e86b67e9eb86aaaac56a875ca83185b04a94276130cf30fb3b
MD5 09bd5a1d5e768fb857b60ed9d3590a7f
BLAKE2b-256 054925f3e19e533cffc2183bc87f910e91974075d977886f90c101fa06cd46ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page