The problem this page solves. You have a character. You need several clips of them — calm, then frightened, then relieved — and they must sound like the same person throughout, matching a reference recording you already have. Generate the clips independently and they will not: the timbre wanders, the level and register jump, and a listener hears a cut between two recordings, or two different actors.
This page is self-contained. It assumes only that you are driving laion/moss-tts-local-transformer-4.55b-voice-acting-v2 through its AutoProcessor, and nothing about how it was worked out. Everything here is measured over ~2,000 generations; the underlying experiments are in the acting-challenge tree if you want the workings.
1. Fix one anchor clip. Either your reference recording, or generate clip 1 and keep the best take. Every later clip is measured against this one, never against its predecessor. 2. Generate later clips in mode="continuation", with the assistant turn holding the anchor + ~4 s of the previous clip — not the whole previous clip. 3. Keep the GENERAL voice description byte-identical across clips. Change only the delivery cue and the emotional state. 4. Append a continuity sentence to GENERAL on every continuation clip. 5. Measure ECAPA cosine similarity against the anchor and enforce it — but at a much lower threshold than feels right: regenerate below 0.58, repair with voice conversion below 0.45, reject below 0.40. Higher thresholds discard the majority of takes a listener accepts and quietly select flat delivery (§5b). 6. Do not apply step 5 to non-verbal clips (screams, sobs, gasps). The metric stops working there.
Measured effect of doing this versus reference conditioning alone, over 9 scenes × 3 rounds: mean similarity on later clips 0.662 → 0.811, share below 0.75 54 % → 12 %, and — the part that matters most — share below 0.55 fell from 25 % to 0 %. Identity no longer collapses.
Restricted to the spoken scenes (excluding screams and other non-verbal clips, where the metric breaks down — §8) the figures are 0.816 mean and 0 % below 0.55.
build_user_message(..., reference=[path]) conditions on your reference and gets the timbre roughly right. But it still starts a fresh utterance: its own onset, its own level, its own register. That is what a listener hears as a splice, and it happens at similarity values that look perfectly acceptable on paper.
mode="continuation" is the stronger tool. It places real audio in the assistant turn, so the model treats it as tokens it already produced and predicts what comes next — inheriting level, register and speaking manner, not just timbre.
conv = [[
proc.build_user_message(text=cumulative_text, instruction=caption,
language="English", tokens=n_tokens),
proc.build_assistant_message(audio_codes_list=[prefix_codes]),
]]
batch = proc(conv, mode="continuation")
out = model.generate(input_ids=batch["input_ids"].cuda(),
attention_mask=batch["attention_mask"].cuda(),
max_new_frames=400, do_sample=True,
audio_temperature=1.0, audio_top_p=0.95, audio_top_k=30)
the assistant turn takes codec codes [T, n_vq=12] | passing a waveform raises audio code tensor must have shape [T, 12] |
proc.encode_audios_from_wav([x], 48000) wants a torch tensor | a numpy array fails on .unsqueeze() |
text must be cumulative | the words already spoken and the words still to come, so the model knows where in the script it is |
| the decode returns only the continuation | measured: a 9.3 s prefix returned 5.7–12.0 s of new audio. Do not trim the output. Blind trimming left 0.2 s stubs; a "1.2× prefix length" guard then mis-trimmed exactly the good long takes |
In continuation mode the reference= slot is ignored — the prompt audio is the conditioning.
The obvious thing is to feed each clip the whole previous clip. It is measurably wrong, for two separate reasons:
| clip 2 | clip 3 | clip 4 | |
|---|---|---|---|
| chained from the full previous clip | 0.691 | 0.692 | 0.280 |
| anchor + 4 s tail | 0.777 | 0.787 | 0.835 |
So build the prefix from two pieces:
tail = prev_clip[-int(4.0 * SR):] # ~4 s of prosodic context
prefix = np.concatenate([anchor_wav, tail]) # identity that cannot drift, + context
The anchor supplies an identity that never degrades; the short tail supplies just enough recent context to continue the delivery. Always measure against the anchor, never against the previous clip — otherwise the reference drifts with the audio.
Continuation resists mood change: you are asking the model to continue an utterance and turn it. Three levers, in order of effect.
Write the cue as a CHANGE, not a state. The single most effective textual lever. "The composure finally breaks and it collapses into sobbing" works; "sad" does not. Name what the delivery stops being as well as what it becomes.
Write the cue as an ACTION, not a tone label. The most common continuation failure is that the voice stays right but the model stops acting and simply reads the remaining words out. A tone label ("resigned, quiet") is an invitation to narrate; a physical direction ("the sentence collapses halfway and they have to start it again") is not. This is measurable with the VoiceNet style heads:
narration_index = ½(S_NARR + S_NEWS) − ½(S_DRAM + S_CONV) # positive = reading it out
Raise the emotion adapter on the clip that carries the turn. The usable band is 0.35–0.75; above ~1.0 genuineness and intelligibility collapse. A clip that has to swing hard sits near the top of the band; an opening clip can sit lower.
State the emotion the clip moves out of as well as into. A caption that says "moves out of guarded composure and into open grief" outperforms one that only names the destination.
Append a continuity sentence to GENERAL on every continuation clip:
"The same speaker from the preceding audio continues without interruption: identical voice, identical person, same microphone and same room — no cut, no new narrator, no change of casting."
Keep the GENERAL voice description byte-identical across clips. Describe the person once and repeat that description verbatim; vary only the delivery cue and the emotional state. A GENERAL that re-describes the voice in different words is an invitation to cast a different voice.
Both cost nothing and both measurably help.
Generating N candidates and keeping the best of one batch is not enough: if the whole batch drifts, the least-bad take still ships. That is precisely how a second actor appears mid-scene.
| threshold | value | action |
|---|---|---|
spk_target | 0.58 | no candidate reaches it → generate the clip again with fresh seeds and merge the candidate pools |
vc_threshold | 0.45 | attempt voice conversion to the anchor as a repair |
spk_floor | 0.40 | reject the take outright — exclude it from ranking entirely |
These numbers were 0.82 / 0.75 / 0.68 and are now much lower. That correction is the single most important thing on this page — see §5b for the measurements behind it. Setting them high feels safe and is not: it discards most of the takes a listener would accept, and quietly selects flat, unexpressive delivery.
Two details that turned out to matter:
When scoring a whole multi-clip sequence, use ½ mean + ½ minimum similarity. A plain mean lets a sequence containing one 0.28 clip win on the strength of the others; a listener does not average identity across a performance.
Chatterbox VC to the anchor can flatten emotion and add artefacts, so run it only below threshold and **keep it only if similarity rose and DNSMOS did not fall by more than 0.15**.
conv = voice_converter().convert(src_path, anchor_path) # float32 @ 24 kHz
keep = (sim_after > sim_before) and (dnsmos_after >= dnsmos_before - 0.15)
Everything in §5 depends on one assumption: that the similarity score means what you think it means. It does not, and this section is the evidence. All of it comes from 200 real clip-pairs from this pipeline, each judged by a strong audio model on two questions — is this the same speaker? and how smooth is the transition, 0–5?
Among the 170 pairs judged to be the SAME speaker:
| median ECAPA similarity | 0.632 |
| share below a 0.68 floor | 55 % |
| share below a 0.82 target | 84 % |
| highest score reached by a genuinely DIFFERENT speaker | 0.816 |
Read the last row against the others. A threshold of 0.68 throws away more than half of the acceptable takes, and a real speaker change scored 0.816 — so no cut-off in that region separates the two groups. The Youden-optimal floor on this data is 0.29; 0.40 is a reasonable compromise that catches ~80 % of genuine swaps while discarding ~29 % of good takes.
We tested four ways of measuring "same speaker" on the identical 200 pairs. AUC is the probability that a genuinely different pair scores below a same-speaker pair (0.5 = chance):
| embedding | what it is | AUC | median (same) | max (different) | same-speaker below that max |
|---|---|---|---|---|---|
| ECAPA-TDNN | standard speaker verification, VoxCeleb | 0.847 | 0.632 | 0.821 | 84 % |
| VoiceNet time-independent | 18 of our own perceptual dims (age, gender, register, pitch range, brightness, fullness, harmonicity, metallic, roughness, smoothness, warmth, 6× resonance) | 0.814 | 0.409 | 0.527 | 74 % |
| WavLM timbre | Orange/Speaker-wavLM-tbr, compares timbre only | 0.794 | 0.746 | 0.943 | 95 % |
| VoiceCLAP | the raw encoder, never trained for identity | 0.770 | 0.672 | 0.711 | 61 % |
The last column is the finding. For every single method, the large majority of same-speaker pairs score below the highest different-speaker pair. There is no clean threshold with any of them. The problem is not that we picked the wrong embedding — it is that gating hard on a single similarity number does not work on emotionally varied speech.
An out-of-fold logistic ensemble of ECAPA + the VoiceNet profile reaches AUC 0.854 versus 0.838 for ECAPA alone. Real, small, and essentially free if you already compute those dimensions — but not a solution.
This distinction is easy to miss and it changes what you build:
1. Floor 0.40, resample target 0.58, VC threshold 0.45. Not 0.68/0.82/0.75. 2. Rank with ECAPA, optionally ensembled with the VoiceNet time-independent profile. 3. Never raise the floor to "be safe". The failure it creates — flat, over-clean delivery — is less visible than a voice change but more damaging, because it affects every take rather than a few. 4. Judge agreement is 84 % between a fast and a strong reasoning model on these labels, and the stronger model is more permissive (47/50 vs 43/50 "same"). Automatic labels tend to over-report speaker changes, so treat any measured drift rate as an upper bound. 5. Get more different-speaker examples before tuning further. Every threshold number here rests on 30 of them; that is the binding constraint on knowing more.
If you generate N candidates per clip, make sure they are genuinely N draws:
seed = (zlib.crc32(character_id.encode()) % 100000) * 1000 + base + 100*round + 10*clip
torch.manual_seed(seed + 7919 * (i // batch)) # several sub-batches per clip
Two failure modes, both observed:
candidates == batch_size means a single RNG stream per clip, so "best of 16" explores one neighbourhood and your selection is far weaker than the candidate count suggests. Keep batch < candidates.Everything in §5 stops working on screams, sobs and non-verbal agony. Measured, splitting the same run by clip type:
| n | mean similarity | below 0.55 | |
|---|---|---|---|
| spoken clips | 44 | 0.816 | 0 % |
| non-verbal clips | 8 | 0.610 | 38 % |
Every identity failure left in the corpus is a non-verbal clip. ECAPA needs voiced, sustained material; a 1–3 s scream gives it almost none, so a low number there is substantially measuring the absence of anything to embed rather than a change of speaker. Gating screams at a high threshold burns regenerations on something the threshold cannot fix.
Two more non-verbal traps:
tokens defaults to the word count and a scream's text ("Aaaahh—! Kh—kh—!") has almost none, so the model produces ~5 tokens and stops after 0.3 s. Use ~12.5 tokens per intended second and raise max_new_frames to match.mode="continuation", prefix = anchor + ~4 s tailtext cumulative; decode not trimmed; prefix passed as codec codes from a torch tensorGENERAL voice description byte-identical across clipsbatch < candidates