Download code/README.md from oProfM/LuaNovaV1: direct link, hf CLI and curl.
- Browser
- Download file 10.8 kB
-
https://huggingface.co/oProfM/LuaNovaV1/resolve/main/code/README.md
- Command line
-
hf download hf://oProfM/LuaNovaV1/code/README.md
-
curl -L -o README.md https://huggingface.co/oProfM/LuaNovaV1/resolve/main/code/README.md
Lua Nova V1
A compact, high-naturalness 24 kHz Brazilian Portuguese (PT-BR) neural Text-to-Speech system combining an 85-symbol eSpeak-NG phonetic front end, ProsodyFlow (generative DurationFlow & ProsodyFlow), an Optimal-Transport Conditional Flow Matching (OT-CFM) acoustic decoder operating in universal Slaney 100-band log-mel space, Sway Sampling, and a gently adapted MIT BigVGAN-base vocoder.
This release packages the CFM v5 (Option A + Weight Soup) + BigVGAN-base FT (Option B) architecture (~35.8M total inference parameters, ~137 MB FP32 / ~68 MB FP16) cleanly for public reproduction, fine-tuning, 2-step Euler distillation (v1.1.0), split ONNX Runtime CPU inference, and overlap-crossfaded chunked streaming — with zero binary checkpoints committed to Git (weights belong on Hugging Face).
Highlights & Benchmarks (tts-eval v1.0.0)
Evaluated on a frozen multi-metric suite across heldout_ref (30 paired studio utterances) and stress_ptbr (36 challenging PT-BR sentences covering questions, exclamations, long clauses, numbers, homographs, and foreign/tech terms):
| System | Held-out (30) Pass | Held-out Comp ↑ | Nat ↑ | Anti-Rob ↑ | SCOREQ ↑ | UTMOS22 ↑ | Stress (36) Comp ↑ | Stress Anti-Rob ↑ | Stress WER ↓ | Stress CER Phon ↓ |
|---|---|---|---|---|---|---|---|---|---|---|
Real Studio Recording (24 kHz) |
30/30 | 88.1 | 95.1 | 77.8 | 3.77 | 3.61 | — | — | — | — |
BigVGAN v1 Large Copy-GT (stock oracle) |
30/30 | 82.7 | 88.4 | 63.8 | 3.59 | 3.42 | — | — | — | — |
BigVGAN-base Copy-GT (stock oracle) |
30/30 | 78.8 | 84.1 | 53.9 | 3.51 | 3.28 | — | — | — | — |
CFM v5 + BigVGAN-base (stock) |
30/30 | 81.9 | 88.1 | 54.4 | 3.60 | 3.43 | 79.9 | 50.9 | 1.84% | 0.31% |
CFM v5 Option A (Soup50+Sway) + BigVGAN-base |
30/30 | 81.3 | 86.7 | 52.9 | 3.60 | 3.44 | 80.7 | 54.3 | 1.85% | 0.33% |
CFM v5 Option A+B + BigVGAN-base FT (8p Sway Midpoint) |
30/30 | 83.9 | 91.6 | 59.1 | 3.74 | 3.49 | 85.0 | 65.4 | 1.85% | 0.28% |
CFM v5 Fast (2p Euler) + BigVGAN-base FT (v1.1.0) |
30/30 | 85.2 | 91.0 | 64.4 | 3.74 | 3.51 | 84.8 | 64.3 | 1.67% | 0.23% |
CFM v5 Option A+B + BigVGAN v1 Large FT (8p Sway Midpoint) |
30/30 | 83.5 | 90.9 | 58.5 | 3.72 | 3.48 | 84.1 | 61.9 | 1.68% | 0.33% |
CPU, GPU & Streaming Latency (v1.0.0 vs. v1.1.0)
Measured across 5 representative PT-BR sentences (24.5 s audio total, warmup excluded; 6 physical / 12 logical CPU cores + RTX 4070 GPU):
| Mode | Avg Latency / Sentence | Speed (RT ↑) | Streaming TTFA (avg) | Model Size |
|---|---|---|---|---|
PyTorch CPU — v1.0.0 Baseline (8p Sway Midpoint) |
3,213 ms | 1.53× |
3,213 ms | 188.8 MB (135.1 + 53.7) |
PyTorch CPU — v1.1.0 Distilled (2p Euler) |
2,337 ms | 2.10× |
2,337 ms | 136.9 MB (83.2 + 53.7) |
PyTorch CPU — v1.1.0 Streaming (2p Euler, chunk=24) |
2,610 ms | 1.88× |
465.3 ms |
136.9 MB (83.2 + 53.7) |
ONNX CPU (6 threads) — 8p Sway Midpoint |
4,223 ms | 1.16× |
4,223 ms | 145.0 MB (90.3 + 54.7) |
ONNX CPU (6 threads) — v1.1.0 Distilled (2p Euler) |
3,469 ms | 1.41× |
3,469 ms | 141.0 MB (86.3 + 54.7) |
ONNX CPU (6 threads) — Streaming (2p Euler, chunk=24) |
5,166 ms | 0.95× |
554.9 ms |
141.0 MB (86.3 + 54.7) |
PyTorch GPU — 8p -> 2p Euler |
535 ms -> 437 ms | 9.10× -> 11.13× |
— | 192 MB loaded / 319 MB peak VRAM |
See CPU & Latency Optimization Guide for distillation training, split ONNX export, and chunked streaming details.
Audio Comparison Samples
Reference 24 kHz studio recordings compared side-by-side against unconstrained CFM v5 Option A+B + BigVGAN-base FT synthesis from raw text:
| Sample | Text | Reference (24 kHz) |
Synthesized (Lua Nova V1) |
|---|---|---|---|
01 |
"Se crivarmos a proposta da permissionária, eu premo por essa decisão." | sample_01_ref.wav | sample_01_gen.wav |
02 |
"Precisamos frisarmos que eles pensassem em visitar a praia de Arribá." | sample_02_ref.wav | sample_02_gen.wav |
03 |
"Você sustentas a ideia de que o sínodo aguentou a pressão?" | sample_03_ref.wav | sample_03_gen.wav |
Installation
Prerequisites
- Python 3.11 or 3.12 and
uv. espeak-ngavailable onPATH(used at runtime and alignment for PT-BR G2P, invoked only as an external subprocess):- Linux (Debian/Ubuntu):
sudo apt-get install espeak-ng - macOS:
brew install espeak-ng - Windows: install eSpeak NG and ensure
espeak-ng.exeis inPATH.
- Linux (Debian/Ubuntu):
Install with uv
# Inference only
uv sync
# Inference + full training & forced alignment stack
uv sync --extra train
# Optional: ONNX tools
uv sync --extra onnx
Note on NVIDIA CUDA PyTorch wheels: If you are training on GPU and
uv syncresolves CPU-only wheels on your platform, install matchingtorch/torchaudioCUDA wheels via--extra-index-url https://download.pytorch.org/whl/cu126(or your CUDA version) after syncing dependencies.
Model Weights (Hugging Face)
Binary model weights (*.pt, *.onnx, *.safetensors) are excluded from this Git repository and distributed via Hugging Face. Place downloaded weights in a local checkpoints/ folder (git-ignored):
- CFM checkpoints:
cfm_v5_fast2.pt(recommended,v1.1.0) — 2-step Euler distilled fromcfm_v5_soup50.pt(2.10× RTCPU /465 msTTFA)cfm_v5_soup50.pt(baseline,v1.0.0) — 8-step Sway Midpoint teacher (50/50 weight soup ofCFM v5+Option AE2E)
- Vocoder checkpoint:
bigvgan_base_optB_2k.pt(fine-tuned MITnvidia/bigvgan_base_24khz_100band) or pass any compatible HF ID directly (nvidia/bigvgan_base_24khz_100bandornvidia/bigvgan_24khz_100band)
You can also strip legacy Vocos buffers from a training checkpoint before uploading to Hugging Face:
from lua_nova_v1.utils import strip_legacy_vocoder
strip_legacy_vocoder("runs/cfm_v5_e2e/inference_v5_soup50.pt", "release_weights/cfm_v5_soup50_fp16.pt", fp16=True)
Quickstart
CLI Inference
uv run lua-nova-speak \
--text "Olá! Dia 22/03 às 14h30 custou R$ 45,90; você prefere testar o modelo agora?" \
--out output.wav \
--cfm checkpoints/cfm_v5_soup50.pt \
--vocoder checkpoints/bigvgan_base_optB_2k.pt \
--device cpu
Python API (PyTorch Streaming & 2-Step Fast Mode)
import numpy as np
from lua_nova_v1 import Synthesizer
synth = Synthesizer.from_checkpoints(
cfm_path="checkpoints/cfm_v5_fast2.pt",
vocoder_path_or_id="checkpoints/bigvgan_base_optB_2k.pt",
device="cpu",
)
# Full utterance (2 Euler steps)
wav = synth.speak(
"Você tem certeza de que o modelo já fala perguntas com naturalidade?",
n_steps=2,
solver="euler",
sway_coef=0.0,
temperature=0.35,
)
synth.save_wav("output.wav", wav)
# Low-latency chunked streaming (TTFA ~465 ms on CPU)
chunks = list(
synth.speak_stream(
"Olá! Este áudio está sendo gerado em partes com transição suave.",
n_steps=2,
solver="euler",
sway_coef=0.0,
chunk_frames=24,
)
)
synth.save_wav("output_stream.wav", np.concatenate(chunks))
ONNX Runtime CPU (PyTorch-free Deployment)
# Export split opset-17 ONNX graphs
uv run lua-nova-export-onnx \
--cfm checkpoints/cfm_v5_fast2.pt \
--vocoder checkpoints/bigvgan_base_optB_2k.pt \
--out-dir checkpoints/onnx \
--steps 2 --solver euler --sway-coef 0.0 --verify
# Synthesize directly with ONNX Runtime CPU + streaming
uv run lua-nova-speak \
--onnx-cfm checkpoints/onnx/cfm_v5.onnx \
--onnx-vocoder checkpoints/onnx/bigvgan_base_ft.onnx \
--text "Síntese em CPU via ONNX Runtime com streaming por chunks." \
--out output_onnx.wav --stream --chunk-frames 24
from lua_nova_v1 import OnnxSynthesizer
ox = OnnxSynthesizer("checkpoints/onnx/cfm_v5.onnx", "checkpoints/onnx/bigvgan_base_ft.onnx")
wav = ox.speak("Oi! Tudo bem com você?")
ox.save_wav("onnx.wav", wav)
Documentation & Guides
- Architecture & Key Design Choices
- CPU & Latency Optimization Guide (Distillation, ONNX & Streaming)
- Fine-Tuning on a New Voice
- Training From Scratch Guide
- Third-Party Notices & Licenses
Repository Layout
lua-nova-v1/
├── assets/samples/ # Paired 24 kHz studio reference & generated audio examples
├── docs/ # Architecture, optimization, training, and fine-tuning guides
├── src/lua_nova_v1/
│ ├── config.py # ModelConfig & CFMConfig dataclasses
│ ├── text/ # PT-BR normalizer (numbers, currency, dates) & eSpeak G2P
│ ├── models/ # Front end, ProsodyFlow, OT-CFM v5 + Sway Sampling, BigVGAN wrapper
│ ├── data/ # Acoustic prep, wav2vec2 CTC forced aligner, Dataset & BucketSampler
│ ├── training/ # Stage 1, ProsodyFlow, CFM v5, Option A (E2E), Option B (Vocoder FT), Distill
│ ├── export/ # Split opset-17 ONNX exporters for CFM v5 and BigVGAN
│ ├── inference/ # PyTorch Synthesizer, OnnxSynthesizer, overlap-crossfade streaming, CLI
│ └── utils/ # RMS/fade/PCM16 post-processing, weight souping, checkpoint stripping
├── tests/ # Unit & end-to-end synthetic verification tests
└── third_party/bigvgan/ # MIT-licensed NVIDIA BigVGAN generator, losses & discriminators
License
Code authored in this repository is released under the Apache License 2.0 (LICENSE). Components under third_party/bigvgan/ are MIT-licensed by NVIDIA (third_party/bigvgan/LICENSE). See THIRD_PARTY_NOTICES.md.