Back

My Fine-Tuned Voice Took Over Every Other Voice. One Base Model and Swappable LoRA Adapters Fixed It.

Today

I'm building a Hindi and English text-to-speech API on VoxCPM2. It has to do two jobs on one NVIDIA L4 with 24 GB: clone anyone's voice zero-shot from a short clip, and speak in a few voices fine-tuned on real teachers' lecture audio.

The first version did the second job by quietly breaking the first. This post covers what went wrong, what fixed it, and what I measured. The code, the trainer patch, listening samples and every checkpoint's scores are open source in suryxnshsingh/voxcpm2-lora-adapters.

The setup

Model VoxCPM2, a streaming TTS model that clones a voice from a reference clip
Hardware One NVIDIA L4, 24 GB, serving live streaming requests
Fine-tuned voices Three teachers, about 25–33 minutes of usable lecture audio each
Language Hinglish: Hindi in Devanagari, English terms in Latin script, numbers as words

Zero-shot cloning already gets a teacher's timbre from an 8 second clip. What it misses is how they actually teach: the pace, the accent, where the emphasis lands. That's what the fine-tune is for.

Step 1: a LoRA fine-tune on a Mac

I started on an M5 Pro with VoxCPM's official trainer. It runs on Apple's MPS backend unchanged, in fp32, at about 11 seconds a step.

The data pipeline matters more than the training config:

  1. Cut long lectures into 3–12 second clips at word gaps with Silero VAD.
  2. Drop any clip whose speaker embedding (ECAPA) is less than 0.55 similar to the teacher. That removes students and anyone else on the recording.
  3. Transcribe, then write Hindi in Devanagari and English terms in Latin script. That's how the model reads Hinglish best.
  4. Hold out a few clips the model never trains on, to score against.

The config was LoRA rank 32 on the language model and diffusion transformer attention, 400–500 steps, with a checkpoint every 50. With this little data the model overfits within a few hundred steps, so I never take the last checkpoint. I render the same unseen sentences from every checkpoint, then score them for voice similarity against the held-out clips and for transcription error. Then I listen.

Voice similarity by training step for three teachers

All three teachers improved over zero-shot, but not in a straight line. With only three sentences per checkpoint each point is noisy, so the served checkpoint isn't always the peak of the chart. The choice also weighed a longer reference clip, transcription error and my ears.

Problem: the fine-tune leaked into everyone

The obvious way to serve a fine-tune is to merge the LoRA into the weights and point the worker at the merged model. I did that for the first teacher: a 5.4 GB model, with one worker serving it.

But one worker serves one model. So every voice on that worker, including every customer's zero-shot clone, was now rendered by a model fine-tuned on one teacher. All of them drifted towards him. A female voice's similarity to its own reference clip fell from 0.84 to 0.45.

A fine-tune doesn't only learn a timbre. It shifts the model's whole idea of what a voice sounds like towards one speaker, and a reference clip can't fully pull it back.

The other obvious fix was a merged model per teacher, each with its own worker. At about 5 GB of GPU each, that doesn't scale on a 24 GB card.

Fix: one base model, LoRA weights copied in per sentence

The worker now loads base VoxCPM2 once, with LoRA layers built in at the same rank and targets as training. Before each sentence, it puts that voice's adapter into those layers:

  • A fine-tuned voice names an adapter: a 72 MB file of LoRA tensors. They're copied in place into the existing layers.
  • Any other voice gets the LoRA weights reset so they add nothing. That's exactly the base model, so cloned voices stop drifting.
  • Adapters stay in CPU RAM in a small LRU cache. A swap takes 0.16 s from disk and 0.06 s from the cache, against seconds to render a sentence. A swap to the voice that's already loaded is skipped.
  • Only values change, never modules or shapes, so a torch.compile'd graph stays valid.
  • It fails safe. An adapter that's missing, or doesn't fit the model, raises before any weight is touched. In production that's a visible error, never a quiet fallback to the wrong voice.
model = VoxCPM.from_pretrained("openbmb/VoxCPM2",
    lora_config=LoRAConfig(enable_lm=True, enable_dit=True, r=32, alpha=32))
swap = AdapterSwapper(model.tts_model, "adapters/")
 
swap.use("teacher_a_step250")   # fine-tuned voice
wav = model.generate(text="देखो, friction straight line में zero तक घटती है।",
                     reference_wav_path="refs/teacher_a.wav")
swap.use(None)                  # exactly the base model, for zero-shot clones

To be fair to upstream: VoxCPM already makes loading LoRA weights safe after torch.compile. What I added is the serving pattern around it:

  • one shared base model for every voice
  • switching inside a pool of model instances, each on its own render thread while it's checked out, so no request sees a half-copied adapter
  • the RAM cache
  • "no adapter" meaning exactly base

The result: each fine-tuned voice costs 72 MB of RAM instead of about 5 GB of GPU. All three teachers run on one model next to every cloned voice.

Second problem: training next to the live API

The serving worker uses about 9.7 GB on the L4 once it's warm. A LoRA training run needed 12.5 GB, so training the next teacher meant taking the API down.

The cause is in the trainer. Training mode upcasts every weight to fp32, which is 9.2 GB for the frozen base alone. But VoxCPM2 is released and served in bf16, so casting the frozen weights back to bf16 is exact: no information is lost.

That became a frozen_bf16 option: after loading, every parameter that doesn't train goes back to bf16, except the audio VAE. The LoRA weights stay in fp32. A run dropped from 12.5 GB to about 8 GB and now fits next to the live worker. On the L4 a step takes about 2 seconds, so 500 steps take about 20 minutes. The second and third teachers were trained this way.

A second patch helps the Hindi data. The trainer ran the diffusion decoder over every row of a batch, even rows with no audio target. Running it only on rows that carry loss gives the same loss for roughly 4× less decoder work. I checked equivalence on a toy model, not on a full run.

What I measured

What Result Hardware
Adapter swap, from disk / from cache 0.16 s / 0.06 s M5 Pro
Adapter size vs a merged fine-tune 72 MB vs 5.4 GB
Render speed, fine-tuned voice 0.67–0.72× real time L4, bf16
First audio, warm fine-tuned voice about 80 ms L4
Training memory, stock vs frozen_bf16 12.5 GB vs about 8 GB L4
Training speed about 2 s/step vs 11 s/step L4 vs M5 Pro

One thing I haven't measured yet: what it costs to carry LoRA layers on every sentence, compared with a model built without them.

What I'd tell someone doing this

Listen before you trust a score. In a separate voice conversion test, the system with the best similarity score (0.78) lost by ear to one scoring 0.70. Use metrics to shortlist checkpoints and your ears to pick one.

A fine-tune still slips sometimes. One voice once read "by two pi" as "pi two pi". It didn't happen again in 36 retries across nine spellings, so it was a random slip, not a pronunciation to fix. For audio that matters, render twice.

Keep tests off the live worker. Each model instance renders one sentence at a time, so a test run makes real requests queue and time out. Load a separate copy of the model for experiments.

A Mac is a real fallback. VoxCPM2 on MPS has to run in fp32, but it renders at about real time. When the GPU server was unreachable, I rendered 17 minutes of lesson narration in two fine-tuned voices locally in about the same time.

The adapter swapper, the trainer patch, the configs, and the listening samples (each teacher's real voice next to zero-shot and fine-tuned renders of the same lines) are all in the repo.