voice-2 / README.md
shadwl's picture
LoRA adapters for Hmong/Bahnar/Khmer + train & inference code + frozen base
4e022a9 verified
|
Raw
History Blame Contribute Delete
4.55 kB
---
license: apache-2.0
tags:
- text-to-speech
- omnivoice
- lora
- low-resource
---
# Per-language LoRA adapters for OmniVoice — Hmong, Bahnar, Khmer
Three low-rank adapters over a **frozen** multilingual OmniVoice base. Each adapter
is ~114 MB; the 2.45 GB base is shared between all of them.
```bash
pip install -r requirements.txt
python infer_lora.py --adapter adapters/km --text "សួស្តី" --output out.wav \
--ref_audio demo_voices/km_female.wav --ref_text "<the clip's transcript>"
```
Paths resolve relative to the repo, so nothing needs editing after cloning.
## Adapters
| dir | language | code | notes |
|-----|----------|------|-------|
| `adapters/km` | Khmer | `km` | in the base model's training mix |
| `adapters/bdq` | Bahnar | `bdq` | in the base model's training mix |
| `adapters/hmongv` | Hmong | `hmongv` | **new language**, not seen by the base |
`hmongv` is the **Vietnam-based Latin orthography** for Hmong (Vietnamese diacritics
plus final-consonant tone letters, e.g. *"Thâuv txos cheix ntux yiêz"*). It is a
different writing system from RPA White Hmong (*"Txheeb xyuas cov kab lus"*), which
appears in the same source corpus under `hmongz`. The two are deliberately **not**
merged — one tag for two orthographies would give the model contradictory spellings
for identical sounds.
## What is trained
| component | params | trained |
|---|---|---|
| Qwen3 backbone (28 layers) | 596M | frozen |
| LoRA r=16 on all attn + MLP projections | 10.1M | yes |
| `audio_embeddings` (8200×1024) | 8.4M | yes |
| `audio_heads` (1024×8200) | 8.4M | yes |
| text embedding (151676×1024) | 155M | frozen by default |
**26.9M / 639.5M trainable (4.2%).** The audio embedding and head tables are trained
in full because adapting to a new language is largely a matter of re-mapping which
audio tokens follow which text, and a rank-16 update inside the backbone is a narrow
channel for that. The text embedding is left frozen: it alone is nine times larger
than everything else trainable combined, and Qwen3's byte-level BPE tokenizes unseen
orthographies losslessly into known subwords. `train_lora.py --train_text_embed`
turns it on.
## Contents
```
train_lora.py LoRA training (base frozen)
infer_lora.py inference; load_lora_model() is the reusable entry point
hmong_to_lhotse.py Hmong ASR corpus -> Lhotse Shar
parquet_to_lhotse.py elego VC parquet -> Lhotse Shar
extract_tokens_parquet.py Lhotse/parquet -> Higgs audio tokens
lhotse_dataset.py shared Lhotse reader
parquet_dataset.py shared parquet reader
registry.py corpus registry
adapters/{km,bdq,hmongv}/ adapter weights + adapter_meta.json
base/ frozen base checkpoint (inference weights)
demo_voices/ reference clips + transcripts
```
## Reproducing
```bash
# 1. data -> Lhotse -> audio tokens
python hmong_to_lhotse.py --max_hours 150
python extract_tokens_parquet.py --lhotse_dir /path/lhotse/hmongv/train \
--language_id hmongv --output_dir /path/tokens/hmongv/train --gpu_ids 0,1,2,3
# 2. one adapter per language, one GPU each
CUDA_VISIBLE_DEVICES=0 python train_lora.py --language hmongv \
--output_dir exp/lora_hmongv --steps 8000
```
## Notes and gotchas
- **LoRA targets are a regex anchored on `llm.layers.N.`**, not bare module names. At
inference OmniVoice attaches the Higgs audio tokenizer, whose encoder also has
`q_proj`/`k_proj`/`v_proj`; bare names match those too and peft then injects
untrained adapters into the audio codec.
- **Ids must not contain dots.** WebDataset splits a member name at the first dot to
derive its key, so an id like `hmongv_413024.0_00000002` is truncated and every
label lookup fails — at training time, long after tokenization reports success.
- The Hmong training set excludes the ~44% of the source corpus that are synthetic
augmentations (reverb / pitch-shift / time-mask). Those are fine as ASR inputs and
ruinous as TTS targets — the model would learn to reproduce the reverb.
- Hmong speaker/gender metadata is largely absent, so its two reference clips are
labelled `voice1`/`voice2` rather than male/female.
- Use `sdpa` attention. `flex_attention`'s Triton kernels fail on torch 2.7.1+cu118.
## Base model
OmniVoice (Qwen3-0.6B + Higgs audio tokens) finetuned jointly on ~1,820 h across ten
languages of Vietnam and Cambodia, 60k steps. Also published at
[`shadwl/voice-demo`](https://huggingface.co/datasets/shadwl/voice-demo).