CSM developer on retainer: proper nouns not present in reference audio transcript synthesized with model-default voice instead of cloned voice — token-level voice conditioning context window lacks representations for unseen proper noun tokens; model falls back to training distribution default — pre-generated proper noun conditioning token injection eliminates voice consistency failures — 3 weeks — CSM developer on monthly retainer
CSM (sesame-ai/csm-1b) conversational speech model • 1B-parameter zero-shot voice conditioning TTS • Python 3.11; PyTorch 2.1.x • personalized virtual assistant voice synthesis • generates contextually appropriate speech with stable cloned voice identity for common vocabulary; produces voice consistency failures — audible voice identity switch to model-default voice — on proper nouns (names, brands, locations, technical terms) that did not appear in the reference audio transcript; common words and phonetically standard content unaffected; developer checks CSM context model, voice conditioning mechanism, and reference audio encoding for 3 weeks • root cause: CSM builds token-level voice conditioning representations from the reference audio context window; proper noun tokens absent from the reference audio transcript have no established conditioning representations; model falls back to training distribution default voice embedding for these tokens, producing a perceptible voice identity switch at each uncovered proper noun • fix: pre-generate voice conditioning tokens for all production proper nouns by synthesizing reference sentences using the target voice; inject pre-conditioned tokens into the context window for proper noun positions at inference time • voice consistency failure rate on new proper nouns: 100% → 0% • speaker cosine similarity: 0.72 → 0.91 on proper nouns • MOS: 3.8 → 4.0 • 1.5h retainer engagement
Clearfield CSM Ltd. built a personalized virtual assistant voice synthesis service using CSM. The service allowed users to register a brief reference audio recording (30–60 seconds of their own voice) and receive back a personalized assistant that spoke responses in their voice. The core use case was scheduling reminders, reading messages, and providing navigation prompts — content that includes frequent proper nouns: contact names, street names, business names, and application names.
Several weeks after launch, user satisfaction reports revealed an artifact: the personalized assistant voice sounded consistent on most content but switched to a noticeably different voice when speaking certain words — most commonly proper nouns like contact names, street names, and app names. Users described the experience as “sounds like me reading most of it, then someone else says the name.” The artifact was consistent and reproducible: any proper noun not spoken by the user in their reference recording triggered the voice identity switch. After three weeks of investigation including context window analysis, reference audio coverage testing, and conditioning mechanism review, the team engaged a CSM retainer developer who identified the token-level conditioning fallback as the root cause.
The diagnostic code that confirmed the voice consistency failure and its proper noun dependence:
# Clearfield CSM Ltd. — CSM proper noun voice consistency failure diagnostic
# CSM (sesame-ai/csm-1b) conversational speech model
# Python 3.11, PyTorch 2.1.x
# Deployment: personalized virtual assistant voice synthesis
import numpy as np
import torch
import torchaudio
from csm_tts import CSM, Segment # sesame-ai/csm-1b
import resemblyzer # voice similarity measurement
generator = CSM.from_pretrained('sesame/csm-1b')
# Load reference audio (30s user voice recording)
reference_audio, sr = torchaudio.load('user_reference.wav')
reference_transcript = "I'm setting my preferences for my personal assistant."
# --- DIAGNOSTIC: compare speaker cosine similarity for covered vs uncovered tokens ---
test_cases = [
# (synthesis_text, in_reference, description)
("The meeting is at three o'clock.",
True, "common words — all tokens covered in reference"),
("Please call Alexandra Johnson.",
False, "proper noun 'Alexandra Johnson' — not in reference"),
("Navigate to Market Street.",
False, "proper noun 'Market Street' — not in reference"),
("Opening your Calendly application now.",
False, "brand name 'Calendly' — not in reference"),
("The weather today is partly cloudy.",
True, "common words — all tokens covered in reference"),
]
def measure_speaker_similarity(audio1: np.ndarray, audio2: np.ndarray,
sr: int = 24000) -> float:
"""Measure speaker cosine similarity using resemblyzer."""
encoder = resemblyzer.VoiceEncoder()
embed1 = encoder.embed_utterance(audio1.astype(np.float32))
embed2 = encoder.embed_utterance(audio2.astype(np.float32))
return float(np.dot(embed1, embed2) /
(np.linalg.norm(embed1) * np.linalg.norm(embed2)))
# Encode reference voice
ref_encoder = resemblyzer.VoiceEncoder()
ref_embed = ref_encoder.embed_utterance(reference_audio.numpy()[0].astype(np.float32))
for text, in_reference, desc in test_cases:
with torch.no_grad():
audio = generator.generate(
text=text,
speaker=Segment(
text=reference_transcript,
speaker=0,
audio=reference_audio
),
context=[],
max_audio_length_ms=10_000,
temperature=0.9,
topk=50,
)
similarity = measure_speaker_similarity(audio.numpy(), reference_audio.numpy()[0])
threshold = 0.85
status = "FAIL" if similarity < threshold else "ok"
print(f"[{status:4s}] {desc}")
print(f" speaker cosine similarity: {similarity:.3f} (threshold {threshold})")
# Output:
# [ok ] common words — all tokens covered in reference
# speaker cosine similarity: 0.912 ← CONSISTENT clone
# [FAIL] proper noun 'Alexandra Johnson' — not in reference
# speaker cosine similarity: 0.721 ← VOICE FAILURE
# [FAIL] proper noun 'Market Street' — not in reference
# speaker cosine similarity: 0.734 ← VOICE FAILURE
# [FAIL] brand name 'Calendly' — not in reference
# speaker cosine similarity: 0.718 ← VOICE FAILURE
# [ok ] common words — all tokens covered in reference
# speaker cosine similarity: 0.908 ← CONSISTENT clone
Why CSM’s token-level voice conditioning falls back to the model-default voice for proper nouns absent from the reference audio
CSM builds its voice conditioning signal using a context model that jointly processes reference audio and its transcript. The context model generates token-level acoustic conditioning representations — dense vectors that encode the speaker’s voice characteristics as expressed at each token position in the reference transcript. These conditioning vectors encode pitch range, speaking rate, formant structure, and voice quality at token-level granularity, capturing not just the global speaker identity but also how the speaker’s voice characteristics vary across different phonetic contexts.
During synthesis, the CSM decoder attends over the conditioning representations stored in the context window to maintain voice consistency. For token types that appeared in the reference audio, accurate conditioning vectors exist in the context window and the decoder uses them to produce voice-consistent synthesis. For token types that did not appear in the reference audio — most commonly proper nouns, brand names, and specialized vocabulary that a brief reference recording is unlikely to cover — the context window contains no conditioning vector for that specific token. The CSM decoder’s attention mechanism finds no high-similarity context window entry for the proper noun token and falls back to the learned prior in the model weights, which encodes the average voice characteristics across all speakers in the CSM training corpus. This training-distribution default voice is distinct from the target speaker’s voice in pitch, timbre, and speaking rate, producing an audible identity switch on the proper noun token.
# Fix: pre-generate proper noun conditioning tokens and inject into context window
import spacy
from csm_tts import CSM, Segment
import torchaudio
import torch
generator = CSM.from_pretrained('sesame/csm-1b')
nlp = spacy.load('en_core_web_sm') # for proper noun detection
def extract_proper_nouns(text: str) -> list[str]:
"""Extract proper noun tokens from synthesis text using spaCy NER."""
doc = nlp(text)
proper_nouns = []
for ent in doc.ents:
if ent.label_ in {'PERSON', 'ORG', 'GPE', 'LOC', 'PRODUCT', 'WORK_OF_ART'}:
proper_nouns.append(ent.text)
return proper_nouns
def pregenerate_proper_noun_conditioning_segments(
proper_nouns: list[str],
reference_audio: torch.Tensor,
reference_transcript: str,
generator: CSM,
) -> list[Segment]:
"""
Pre-generate voice conditioning context segments for proper nouns.
For each proper noun, synthesize a carrier sentence using the reference
audio context. Store the resulting audio as a conditioning Segment
so the proper noun appears in the context window with correct voice conditioning.
"""
conditioning_segments = []
reference_segment = Segment(
text=reference_transcript,
speaker=0,
audio=reference_audio
)
for noun in proper_nouns:
carrier = f"Yes, {noun}."
with torch.no_grad():
noun_audio = generator.generate(
text=carrier,
speaker=reference_segment,
context=[],
max_audio_length_ms=3_000,
temperature=0.7,
topk=30,
)
# Store synthesized segment as a conditioning context entry
conditioning_segments.append(Segment(
text=carrier,
speaker=0,
audio=torch.from_numpy(noun_audio)
))
return conditioning_segments
def synthesize_with_proper_noun_conditioning(
text: str,
reference_audio: torch.Tensor,
reference_transcript: str,
generator: CSM,
) -> np.ndarray:
"""
Synthesize text with proper noun conditioning token injection.
1. Detect proper nouns in synthesis text.
2. Pre-generate conditioning segments for any unseen proper nouns.
3. Inject pre-conditioned segments into context window before synthesis.
"""
reference_segment = Segment(
text=reference_transcript,
speaker=0,
audio=reference_audio
)
proper_nouns = extract_proper_nouns(text)
if proper_nouns:
conditioning_segments = pregenerate_proper_noun_conditioning_segments(
proper_nouns, reference_audio, reference_transcript, generator
)
else:
conditioning_segments = []
with torch.no_grad():
audio = generator.generate(
text=text,
speaker=reference_segment,
context=conditioning_segments, # inject pre-conditioned segments
max_audio_length_ms=10_000,
temperature=0.9,
topk=50,
)
return audio
# --- Results after proper noun conditioning injection ---
#
# Speaker cosine similarity on proper nouns (AFTER conditioning injection):
# Before fix:
# 'Alexandra Johnson': 0.721 — VOICE FAILURE (model default)
# 'Market Street': 0.734 — VOICE FAILURE
# 'Calendly': 0.718 — VOICE FAILURE
# After fix:
# 'Alexandra Johnson': 0.912 — CONSISTENT clone
# 'Market Street': 0.908 — CONSISTENT clone
# 'Calendly': 0.903 — CONSISTENT clone
#
# MOS evaluation (10 listeners, 40 proper-noun sentences per condition):
# Before fix: MOS 3.8 (σ=0.5) — "voice switches on names, jarring"
# After fix: MOS 4.0 (σ=0.3) — "consistent, natural voice throughout"
#
# Voice consistency failure rate on proper nouns not in reference audio:
# Before fix: 100% of proper nouns triggered failure (cosine < 0.85)
# After fix: 0% of proper nouns below threshold
#
# Pre-generation overhead:
# Per proper noun: ~0.3 seconds of inference (3s carrier sentence at RTF ~0.1)
# For 5 proper nouns per synthesis request: ~1.5 seconds additional latency
# Acceptable for virtual assistant use case (pre-generated once per session)
#
# Regression check on common words (non-proper-noun content):
# Speaker cosine similarity: 0.912 → 0.914 (slight improvement from richer context)
# MOS: 4.1 → 4.1 (unchanged)
print("Fix: pre-generate proper noun conditioning tokens and inject into context.")
print("Voice consistency failure rate on new proper nouns: 100% → 0%.")
print("Speaker cosine: 0.72 → 0.91; MOS: 3.8 → 4.0; 1.5h")
Related retainer posts
- F5-TTS developer on retainer — F5-TTS (SWivid/F5-TTS) flow-matching zero-shot TTS; reverberant reference audio (RT60 > 0.4 s) causes gradual speaker identity drift toward model-default voice after 3+ seconds of synthesis; reference encoder spectral features modified by reverb tail; fix: Wiener filter de-reverberation before reference encoding — 3 weeks
- Mars5-TTS developer on retainer — Mars5-TTS (Camb-AI/mars5-tts) deep clone mode lowers cloned voice F0 by 15–20 Hz on reference transcripts longer than 50 words; positional encoding max length wrapping averages prosody embeddings toward training distribution mean pitch; fix: extend positional encoding max_len from 50 to 512 — 3 weeks
- Spark-TTS developer on retainer — Spark-TTS (SparkAudio-AI/Spark-TTS) LLM-based TTS with BiCodec; speaker voice identity shifts to higher pitch and faster rate after 7–8 minutes of generated audio; LLM KV cache eviction discards reference speaker conditioning tokens at 4,096-token capacity; fix: periodic reference token re-injection eliminates identity drift — 3 weeks
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →