|
Download code/docs/ARCHITECTURE.md from oProfM/LuaNovaV1: direct link, hf CLI and curl.
- Browser
- Download file 3.97 kB
-
https://huggingface.co/oProfM/LuaNovaV1/resolve/main/code/docs/ARCHITECTURE.md
- Command line
-
hf download hf://oProfM/LuaNovaV1/code/docs/ARCHITECTURE.md
-
curl -L -o ARCHITECTURE.md https://huggingface.co/oProfM/LuaNovaV1/resolve/main/code/docs/ARCHITECTURE.md
3.97 kB
| # Architecture Overview | |
| Lua Nova V1 decouples **Brazilian Portuguese linguistic/prosodic generation** from **universal waveform reconstruction**, allowing fast acoustic training (`< 3.5 GB` VRAM) and plug-and-play compatibility with MIT-licensed `BigVGAN` vocoders. | |
| ```text | |
| Raw Text | |
| └─▶ PT-BR Normalizer (numbers, currency, dates, ordinals, time, abbreviations) | |
| └─▶ eSpeak-NG G2P (`pt-br`, 85-symbol inventory + primary/secondary lexical stress) | |
| └─▶ 4-layer RoPE Text Encoder | |
| ├─▶ LinguisticContextAdapter (26 word/stress/clause geometry features) | |
| ├─▶ Duration Predictor + 4-step Generative DurationFlow | |
| └─▶ Frame Expansion + 4-step Multiscale ProsodyFlow (F0, voicing, energy) | |
| └─▶ 5-layer RoPE Acoustic Prior | |
| └─▶ 8-layer FlowDecoder (OT-CFM, d=320, Sway Sampling s=-0.5) | |
| └─▶ Slaney 100-Band Physical Log-Mel [24 kHz, hop=256] | |
| └─▶ BigVGAN-base (MIT, gently adapted via Option B) | |
| └─▶ 24 kHz PCM Waveform | |
| ``` | |
| ## Core Components | |
| ### 1. Deterministic Text Normalizer & Unified G2P (`src/lua_nova_v1/text/`) | |
| - **`normalizer.py`:** Pure Python normalizer converting cardinals, ordinals, percentages, `R$` currencies, `DD/MM(/YYYY)` dates, `HHhMM` times, Roman numerals, and common PT-BR abbreviations before phonemization. | |
| - **`phonemizer.py`:** Tokenizes `espeak-ng --ipa` output into a fixed 85-symbol vocabulary (`PHONES + PUNCTUATION + SPECIALS`) paired with a parallel stress tensor (`0 = unstressed`, `1 = primary`, `2 = secondary`). Explicit `<sp>` and punctuation tokens carry predicted silence pauses. | |
| ### 2. Generative Prosody & Context (`src/lua_nova_v1/models/cfm.py`) | |
| - **`LinguisticContextAdapter`:** Computes 26 ONNX-safe utterance, word, stress-distance, and clause geometry features so questions (`?`), exclamations (`!`), and comma boundaries modulate intonation globally. | |
| - **`DurationFlow`:** 4-step OT-CFM flow predictor over phoneme `log1p(frames)`, paired with a separate binary pause-presence head. | |
| - **`ProsodyFlow`:** 4-step OT-CFM contour generator over `(log_F0, energy)` fed with a smooth multiscale 1D-convolved Gaussian prior (`smooth_prosody_noise`) to avoid robotic frame-to-frame pitch jitter. | |
| ### 3. Slaney-100 OT-CFM Decoder (`FlowDecoder`) | |
| - 8 AdaLN-Zero RoPE + depthwise-conv blocks (`d=320`, `8` heads, `ff=1024`, `16.27M` flow/acoustic parameters) centered on the deterministic `AcousticStack` prior mel (`x0 = prior + sigma * gate * eps`). | |
| - Trained with `t` logit-normal sampling, temporal (`dt`) and cross-band (`df`) mel derivative losses, high-frequency mel weighting (`40` top bands × `1.4`), and **Sway Sampling** (`sway_coef = -0.5` concentrating ODE steps near noisy initial flow where global structure forms). | |
| ### 4. Artifact Elimination Strategy (Option A + Option B) | |
| Why two gentle stages beat brute-force training: | |
| 1. **Option A (`training/cfm_e2e.py` + `utils/checkpoint.py`):** Unrolls 4 checkpointed ODE steps through a **frozen MIT BigVGAN** and **frozen NVIDIA 5M-step pretrained MPD/MRD discriminators** (`bigvgan_discriminator_optimizer.pt`), plus a **50/50 weight soup** (`soup_checkpoints`) with the base CFM v5 weights. This fixes mel oversmoothing and acoustic–vocoder mismatch without drifting harmonics. | |
| 2. **Option B (`training/vocoder_ft.py`):** Fine-tunes `BigVGAN-base` (`14M` params) for 2,000 steps using **NVIDIA's pretrained 5M-step MIT MPD/MRD discriminators** (`--pretrained-disc --disc-warmup 0`) on 60% Option A predicted mels + 40% ground-truth `24 kHz` recordings. Starting from pretrained discriminators prevents phase/harmonic collapse (`CPP` rises rather than falls) and boosts even Copy-GT reconstruction. | |