Firoj Paudel

I fit a 24 kHz bilingual TTS into 1.49M parameters. Then I let an AI agent edit its weights.

Moving English–Nepali phonology out of the network got a full 24 kHz TTS, vocoder included, down to 5.98 MB and 1.11 ms per chunk. Then Gemini 4 Neon tried editing its weights directly, under proper controls.

a whole voice in 5.98 MB. or 1.12 MB.English + नेपाली · 24 kHz · runs on a CPU1.49M5.98 MB281K1.12 MB173× real time on a laptop CPU · weights edited by Gemini 4 Neon

Most text-to-speech models these days are secretly language models. Hundreds of millions of parameters, neural audio codecs, autoregressive token loops. They sound amazing on a datacenter GPU. They're also useless if you want natural Nepali, English, and the Nepali–English mix people actually speak, running locally on a laptop CPU or a phone.

So I went the other way, as far as I could: what if you throw out the language model entirely, move all the linguistics into a frontend with zero learned parameters, and let the neural network do acoustics and nothing else?

That became PAWP-TTS (Phoneme-Aware Weight Programming). Counting every learned tensor you need at inference, waveform decoder included, PAWP-1.5M is 1,490,390 parameters. That's 5.98 MB as FP32 safetensors and 5.16 MB as a folded ONNX graph. It decodes a 60 ms chunk of audio in 1.11 ms on a 4-thread CPU, about 173× faster than real time. And a 281K-parameter sibling (1.12 MB) still stays intelligible in both languages.

Then there's the second half of the project, which honestly ended up being my favorite part: weight-space programming. That means reading a trained network's weights and editing them directly, with zero gradient steps, to fix pronunciation and timing bugs. I didn't do the edits myself. I handed that part to an AI research agent, Gemini 4 Neon, which designed and ran the edit experiments while I set the rules and checked the results. Once proper controls were in place, it mostly taught me how easy it is to fool yourself. Here's the whole story, including the parts that humbled me.

Don't take my word for it, though. The demo below runs the actual model, right here in your browser. Type anything in English, Nepali or both and hit Speak.

Try it. It runs entirely in your browser.The real 1.49M model, computed on your machine. No server ever sees your text or audio. Type English, Nepali, or both.
78/600
Press Speak. The waveform draws itself as the audio streams in.

Weights and lexicon: PAWP-TTS, CC BY 4.0. Runtime: onnxruntime-web and eSpeak-ng (English phonemes), loaded only when you use the demo.

Everything happens in your browser: the frontend, the 1.49M-parameter model and the 24 kHz vocoder. Nothing you type is sent anywhere.

Why multilingual TTS gets Nepali wrong

Here's the boring truth before any neural nets show up: a lot of multilingual and Indic TTS treats Nepali like Hindi with different words. Native speakers hear the difference instantly.

Everyday Kathmandu Nepali has:

If you feed raw Devanagari and Latin characters into a tiny network, it has to spend a big chunk of its weights memorizing spelling rules, heteronyms and where one script ends and the other starts. A 1.5M-parameter model can't afford that.

Splitting the job: zero parameters for spelling, 1.49M for sound

So PAWP-TTS splits the problem down the middle.

The frontend is fully deterministic. Zero learned parameters, 0.16 ms per sentence. It splits the text into Devanagari and Latin spans, sends English through libespeak-ng (called in-process via ctypes, under 0.20 ms a sentence), and sends Nepali through Kathmandu phonology rules backed by a 105,868-word lexicon and 76 heteronyms with 152 readings. Everything lands in one shared 128-token IPA inventory, tagged with language, stress and word boundaries.

That leaves the whole neural budget for acoustics and the waveform:

text
Component                                         Parameters     Share-----------------------------------------------------------------------Embeddings & conditioning                             18,432      1.2%Text encoder (4 ConvNeXt1D + language residuals)     366,608     24.6%Variance predictors (dur, F0, voicing, energy)        62,372      4.2%Acoustic network + mel head                          378,208     25.4%Waveform decoder (ConvNeXt1D + 24 kHz iSTFT)         664,770     44.6%-----------------------------------------------------------------------Total deployed inference graph                     1,490,390    100.0%

Look where almost half the model lives: 44.6% of the parameters are in the iSTFT waveform decoder. Once you go below 2M parameters, the vocoder is the last thing you should starve.

Two more choices keep it fast and stable. Every depthwise convolution looks at most one frame (10 ms) into the future, so chunked streaming works. And durations come from an explicit predictor trained on CTC forced alignments, with no autoregressive attention, so the model can't skip words, repeat phrases or make up an ending.

The frontend handles all the spelling with zero learned parameters. Of the 1.49M that are learned, the biggest share by far goes to the 24 kHz waveform decoder.

Language-gated weights (that fold away for free)

To get one small backbone to speak English, Nepali and the mix without the two languages fighting over the same weights, every pointwise projection in the encoder and acoustic blocks gets language-gated low-rank residuals:

Each is a rank-16 residual for one language, and the masks and come straight from the frontend's script router. In a code-mixed sentence the gates flip at exactly the token where the language switches.

The nice bonus: if you only need one language, the residual folds into at export time. Zero extra ops at inference.

src/pawp_tts/infrastructure/neural/convnext.py · GatedLowRankLinearpython
def forward(    self,    x: torch.Tensor,    lang_masks: torch.Tensor | None = None,) -> torch.Tensor:    """    Forward pass on `(B, T, in_features)` with optional `(B, T, 2)` `[m_en, m_ne]` gates.    """    out = F.linear(x, self.weight, self.bias)    if self.residual_rank <= 0 or lang_masks is None:        return out     m_en = lang_masks[..., 0:1]    m_ne = lang_masks[..., 1:2]     if torch.any(m_en != 0):        res_en = F.linear(F.linear(x, self.v_en), self.u_en)        out = out + (m_en * self.gate_en) * res_en    if torch.any(m_ne != 0):        res_ne = F.linear(F.linear(x, self.v_ne), self.u_ne)        out = out + (m_ne * self.gate_ne) * res_ne    return out def fold_language(self, language: Literal["en", "ne"]) -> nn.Linear:    """Materialize dense monolingual weights `W_shared + g_lang * U_lang @ V_lang`."""    folded = nn.Linear(self.in_features, self.out_features, bias=self.bias is not None)    with torch.no_grad():        merged = self.weight.detach().clone()        if self.residual_rank > 0:            if language == "en":                merged = merged + self.gate_en.detach() * (                    self.u_en.detach() @ self.v_en.detach()                )            else:                merged = merged + self.gate_ne.detach() * (                    self.u_ne.detach() @ self.v_ne.detach()                )        folded.weight.copy_(merged)        if self.bias is not None and folded.bias is not None:            folded.bias.copy_(self.bias.detach())    return folded

One training trick mattered way more than I expected: scheduled sampling on prosody. On half of all training steps, the acoustic network gets its own predicted pitch and energy instead of the ground truth. Without it, the model sounds crisp on teacher-forced validation and flat when you actually use it. With it, that gap mostly went away.

From the paper: (a) the full PAWP-1.5M stack with per-block parameter counts, (b) one language-gated ConvNeXt1D block, where the en/ne residuals sit beside W₁ and W₂, and (c) the iSTFT waveform head.
From the paper: (a) the full PAWP-1.5M stack with per-block parameter counts, (b) one language-gated ConvNeXt1D block, where the en/ne residuals sit beside W₁ and W₂, and (c) the iSTFT waveform head.

The biggest win wasn't an architecture change

Before the small models and the weight editing, I want to show the single biggest jump in the whole project. It wasn't a clever layer or a new loss.

My early runs (v2) trained on a feature cache I'd built before the final Nepali lexicon and the व → /b/ rule existed. So the phoneme labels and CTC durations in the cache came from an older frontend than the one I used at inference. The model was quietly learning from labels that disagreed with what it would see later.

When I rebuilt the whole 136,807-utterance cache (v3), retrained the CTC aligner (loss went from about 1.0 to 0.614) and re-extracted the durations:

Fixing a silent version mismatch between the frontend and the cache did more than every architecture tweak and weight edit combined. Even worse: before I caught it, those व errors looked exactly like a neural bug. A whole weight-editing experiment had already gone into trying to "surgically repair" something that was really a data problem.

The v2 cache came from an older frontend, so training labels disagreed with what the model saw at inference. Rebuilding it fixed the /b/ → /w/ errors and nearly halved Nepali PER.

How small can it go? 1.49M vs. 281K

Training data was about 219 hours of speech: 77 h of English LibriSpeech, 108 h of Nepali studio and read speech (including OpenSLR) and 34 h of code-mixed speech. On top of that sits a single-voice bilingual target corpus, synthesized by a fine-tuned OmniVoice teacher and filtered with an independent ASR model (CER ≤ 0.10 for English, ≤ 0.12 for Nepali). Everything trained in BF16 on one RTX 4090.

Once PAWP-1.5M worked on v3, I wanted to find the floor. First I tried the lazy route, one-shot SVD compression of the 1.5M model (EXP-010). It fell apart completely by 500K parameters without retraining. You can't just slice a model down and hope.

So I trained two 281K-parameter models from scratch on v3, same recipe, 36k steps each, and repeated both with three seeds (42, 101, 202):

Here's everything on clean v3 data. The ASR columns are held-out live recognition (n=30 English, 30 Nepali, 9 code-mixed, seed 42), shown next to the score real human recordings get, as an intelligibility check rather than a naturalness one. The last column is phoneme error on 600 untouched test utterances, as the mean ± std over the three seeds for the 281K models.

text
Model (v3)          Unique Params   FP32    EN WER/CER    NE WER/CER    Mix WER/CER   Test NE / EN PER------------------------------------------------------------------------------------------------------Human Floor (ASR)             ---    ---   2.63 / 0.75  11.60 / 3.82   25.91 / 12.88               ---PAWP-1.5M v3            1,490,390  5.98M   4.02 / 1.50  12.35 / 1.75   12.32 /  5.32     5.04% / 4.02%PAWP-300K Shared          281,078  1.12M   6.88 / 2.93  19.71 / 5.93   12.02 /  5.01   6.35±0.11 / 6.57±0.47%Dense-300K                281,442  1.13M   6.15 / 2.42  20.21 / 6.59   18.09 /  9.01   5.53±0.08 / 5.34±0.28%

Two things jumped out:

  1. 281K parameters really does speak both languages. With 5.3× fewer parameters than PAWP-1.5M, Dense-300K averages 5.53% Nepali PER and 5.34% English PER on the 600 test utterances across three seeds, and tells apart 79.2% of my 77 Nepali/bilingual minimal pairs.
  2. Plain dense beat weight sharing on the big test set. Shared-300K was slightly ahead on validation mel loss and on the tiny 9-sentence code-mix set. But on the 600 untouched test utterances, Dense-300K won on all three seeds in both languages, with no overlap: 0.82 pp better on Nepali PER and 1.23 pp on English, on average (paired bootstrap on seed 42, ). Sharing weights across layers just doesn't pay at this size.

On speed (4-thread x86_64 CPU, folded 5.16 MB ONNX), a 60 ms chunk takes 1.11 ms at the median and 1.52 ms at p99. That's 173.36× real time (RTF 0.0058), and the output matches the PyTorch streaming waveform with cosine similarity between 0.987 and 0.99998. To be clear about what that measures: it's per-chunk compute after the sentence is encoded. True end-to-end streaming latency is still on my list.

The thin bar under each name is model size. At about a fifth of the parameters, Dense-300K stays close to the 1.5M model, on every seed.
Held-out live ASR (from the paper's results table), next to what real human recordings score.

Weight-space programming: what actually held up

Now the wild part. Inspired by weight-space programming and ROME-style rank-one model editing, I wanted to know: can you look inside a trained TTS network and patch a pronunciation or timing bug with zero training, without breaking the other language?

Instead of hand-crafting edits myself, I gave this whole track to Gemini 4 Neon as a research agent. It read activations, proposed edits, applied them and ran the evaluations. My job was the rules of the game and deciding what counted as a real result.

The first round (EXP-009) was an unconstrained weight transplant. On my small held-out ASR set it took code-mix WER from 11.99% to 9.93%. Looked exciting. But that edit had been picked while looking at the test set, which is a great way to fool yourself, and the gain was within noise anyway. So I locked everything down before the agent ran anything else:

Three experiments came out of that.

Gemini 4 NeonresearcherDesigned and ran every weight edit, in Antigravity.
Claude CodeverifierChecked the edits and results before anything counted.
meleadSet the rules, picked the controls, decided what counted.
Who did what in this part of the project.

1. Shared edits hurt everything; language residuals isolate perfectly

In EXP-013a, an unconstrained rank-1 edit to the shared weight acoustic_blocks.3.pw2.weight fixed the targeted confusion but made overall PER worse in both languages (Nepali +1.22%, English +1.75%). And when I checked which words those /b/ → /w/ errors came from, 90.3% (65/72) were व words, the stale v2 cache problem from earlier. I'd been editing weights to fix bad data.

Compare that with EXP-017: a ROME null-space rank-1 edit placed strictly inside the Nepali-only residual encoder_blocks.0.pw2.{u_ne, v_ne} (6,144 parameters, 0.41% of the model). English collateral was exactly 0.000%, by construction, and Nepali PER didn't move (5.036% → 5.026%, ). The language residuals really do behave like separate circuits.

From the paper: every edit next to its two controls, a random edit of the same size and gradient fine-tuning of the same parameters. The pause edit doesn't beat its own random control, and one duration scalar does best.
From the paper: every edit next to its two controls, a random edit of the same size and gradient fine-tuning of the same parameters. The pause edit doesn't beat its own random control, and one duration scalar does best.

2. 27:1 surgical selectivity on pauses, beaten by a single scalar

On clean v3 validation data (EXP-016), word-boundary <sp> pauses came out too short (6.16 frames predicted vs. 10.38 real). And at the 96-dim input to duration_predictor.proj.weight, pause tokens were 90.8% linearly separable from normal phonemes. Those are just 96 weights, 0.0064% of the model:

src/pawp_tts/infrastructure/neural/variance_adaptor.py · DurationPredictorpython
class DurationPredictor(nn.Module):    """Predicts log-duration per phonological token."""     def __init__(self, d_model: int = 128, hidden: int = 96, kernel_size: int = 3) -> None:        super().__init__()        self.block1 = _DWSepPredictorBlock(d_model, hidden, kernel_size)        self.block2 = _DWSepPredictorBlock(hidden, hidden, kernel_size)        self.proj = nn.Linear(hidden, 1)     def forward(self, x: torch.Tensor) -> torch.Tensor:        """Return positive predicted frame durations `(B, L)` from `(B, L, D)`."""        h = self.block2(self.block1(x))        log_dur = self.proj(h).squeeze(-1)        return F.softplus(log_dur)

The agent's ROME-whitened rank-1 update to those 96 weights did something genuinely cool. On untouched test data it made pauses 1.001 frames longer while regular phonemes moved only 0.037 frames. That's 27:1 selectivity. It cut deletions (19 fewer in Nepali, 21 in English) and beat gradient fine-tuning of the same 96 weights (4.93% vs. 5.55% Nepali PER).

Then the random control humbled us both. A random edit with the same norm in those same 96 weights scored 4.84% Nepali PER (), better than the surgical edit (4.93%, ).

How does random beat 27:1? I went through all 13,450 phonemes in 169 Nepali validation utterances, class by class, and found it: every single phoneme class was predicted 3.5% to 13% too short. Overall it was −7.3% (6.105 predicted vs. 6.585 real frames). That's Jensen's inequality, from training durations in the log domain. Any edit that happened to stretch durations a bit was going to help.

So I tried the dumbest baseline possible: change one number, duration_predictor.proj.bias. I picked the shift on validation only (+0.10) and ran it once on the test set. This comparison has its own evaluation baseline, and Nepali PER went from 4.744% to 4.513% (−0.27 pp, 95% CI [−0.41, −0.12], ) with no English regression (4.044% → 4.016%, ). One scalar beat 96-weight ROME and 96-weight fine-tuning, and it points straight at the real fix: correct for the bias in the duration loss during training.

Gemini 4 Neon's pause edit really was surgical, but a random edit of the same size scored better, because every phoneme was predicted too short. One bias shift fixed that best.

3. When the "model error" is just how people talk

After v3, the most common remaining Nepali substitution on validation was the retroflex nasal /ɳ/ coming out as dental /n/ (EXP-017). Before blaming the weights again, I ran the aligner on the real human studio recordings in the test set: 62 occurrences across 52 utterances.

The humans said ण as dental /n/ 90.3% of the time (56/62). That matches how linguists describe spoken Kathmandu Nepali: only three nasals actually contrast (/m, n, ŋ/), and ण is dental except right before a retroflex stop. The model had learned real spoken Nepali. My lexicon was the one being too literal about spelling.

Update: paper on arXiv and #1 & #3 on the Open TTS Leaderboard

Two quick updates since I first wrote this post.

First, the paper is officially out on arXiv: arxiv.org/pdf/2611.29455.

Second, I submitted both models to Hugging Face's Open TTS Leaderboard — and on CPU streaming (batch size 1, 3-sample warmup, timed across 497 utterances from CV3-Eval's English split), PAWP-300K landed at global rank #1 and PAWP-1.5M at global rank #3:

text
Rank   Model                       TTFA p95    TTFA p50     RTFx   Streaming   Size (B)----------------------------------------------------------------------------------------  1    Firoj112/pawp-tts-300k        4.4 ms      2.2 ms   172.00         yes     0.0003  3    Firoj112/pawp-tts-1.5m        6.0 ms      3.3 ms    75.08         yes     0.0015

To keep the record reproducible, those leaderboard numbers come from commit 2356518 ("Optimize streaming inference with 30ms TTFA, comfort padding, and fast in-memory lexicon", built on the slim HF Jobs evaluation backend added in 699d027–cd3002f). Three small engineering changes did the heavy lifting:

Top 5 on Hugging Face's Open TTS Leaderboard (CPU · Streaming, 497 CV3-Eval utterances): PAWP-300K at #1 (2.2 ms p50 TTFA, 172× RTFx) and PAWP-1.5M at #3 (3.3 ms p50 TTFA, 75× RTFx), commit 2356518.
Top 5 on Hugging Face's Open TTS Leaderboard (CPU · Streaming, 497 CV3-Eval utterances): PAWP-300K at #1 (2.2 ms p50 TTFA, 172× RTFx) and PAWP-1.5M at #3 (3.3 ms p50 TTFA, 75× RTFx), commit 2356518.

What I'm honest about

Wrapping up

Two things stuck with me. First, you don't need a 500M-parameter language model for crisp 24 kHz bilingual and code-mixed speech. 1.49M parameters, vocoder included, runs at 75× real time end-to-end on CPU (and 281K hits 172× real time and 2.2 ms TTFA, good enough for #1 on Hugging Face's Open TTS CPU streaming leaderboard) when you give the vocoder most of the budget and keep the frontend deterministic.

Second, letting an agent poke at the weights is an amazing diagnostic tool, even when the edits lose to simple baselines. Gemini 4 Neon's experiments forced me to find a stale cache, a −7.3% duration bias and a lexicon rule that was too literal. Every one of those fixes belongs upstream, in the data, the loss or the frontend. I'd never have seen them so clearly without the weight edits first.

Code, ONNX graphs, weights, paper and audio samples are all open: