← Manual hub

Keeping one voice across clips while the emotion changes

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.


0. The short version

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.


1. Why plain reference conditioning is not enough

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)

Four mechanics that each cost a debugging cycle

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 tensora numpy array fails on .unsqueeze()
text must be cumulativethe words already spoken and the words still to come, so the model knows where in the script it is
the decode returns only the continuationmeasured: 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.

2. Anchor + tail — do not chain

The obvious thing is to feed each clip the whole previous clip. It is measurably wrong, for two separate reasons:

clip 2clip 3clip 4
chained from the full previous clip0.6910.6920.280
anchor + 4 s tail0.7770.7870.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.

3. Getting the emotion to actually change

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.

4. Prompting for identity — two free levers

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.

5. Enforce identity — do not merely rank it

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.

thresholdvalueaction
spk_target0.58no candidate reaches it → generate the clip again with fresh seeds and merge the candidate pools
vc_threshold0.45attempt voice conversion to the anchor as a repair
spk_floor0.40reject 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.

Voice conversion is a repair, not a default

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)

5b. Calibrating the identity threshold — what the numbers actually are

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?

ECAPA cannot support a high threshold

Among the 170 pairs judged to be the SAME speaker:

median ECAPA similarity0.632
share below a 0.68 floor55 %
share below a 0.82 target84 %
highest score reached by a genuinely DIFFERENT speaker0.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.

The same is true of every other embedding we tried

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):

embeddingwhat it isAUCmedian (same)max (different)same-speaker below that max
ECAPA-TDNNstandard speaker verification, VoxCeleb0.8470.6320.82184 %
VoiceNet time-independent18 of our own perceptual dims (age, gender, register, pitch range, brightness, fullness, harmonicity, metallic, roughness, smoothness, warmth, 6× resonance)0.8140.4090.52774 %
WavLM timbreOrange/Speaker-wavLM-tbr, compares timbre only0.7940.7460.94395 %
VoiceCLAPthe raw encoder, never trained for identity0.7700.6720.71161 %

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.

Ranking on identity is fine. Gating on it is not.

This distinction is easy to miss and it changes what you build:

Recommendations

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.

6. Seeds — a trap worth knowing about

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:

7. Joining the clips

8. The non-verbal exception

Everything in §5 stops working on screams, sobs and non-verbal agony. Measured, splitting the same run by clip type:

nmean similaritybelow 0.55
spoken clips440.8160 %
non-verbal clips80.61038 %

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:

9. Checklist