so-vits-svc developer on retainer: cluster_ratio=1.0 in inference — k-means centroids trained on unprocessed songs (voice+instruments mix) — 50% instrument timbre in every output frame — speaker similarity 0.41 vs 0.84 — $175,000 — 5 months — so-vits-svc developer on monthly retainer

so-vits-svc 4.1 (svc-develop-team/so-vits-svc) • PyTorch 2.0.1 • Python 3.10; cluster_ratio=1.0 hardcoded in every inference call; k-means cluster model built from raw streaming downloads — no vocal isolation — ~50% of centroid vectors encode instrument timbres; VITS decoder replaces HuBERT features entirely with nearest centroid; each output frame mixes target voice with instrument timbre; fix: cluster_ratio=0 • Westfield SoVITS Covers Ltd. (5-person AI music cover platform; 5 months; 1.5h)

Westfield SoVITS Covers Ltd. is a 5-person startup building an AI music cover generation platform. Users upload a vocal recording; the platform converts their voice to a licensed target artist voice — either aria-soprano (speaker index 0) or luna-mezzo (speaker index 1). The team trained a custom so-vits-svc 4.1 multi-speaker model on 20 minutes each of two target voice datasets sourced directly from streaming services: they downloaded raw songs, not isolated vocal stems. The model’s config.json correctly lists "spk": {"aria_soprano": 0, "luna_mezzo": 1}. As part of the training pipeline, they also built a k-means cluster model using the same audio. When the cluster model is used at inference with cluster_ratio=1.0, the VITS decoder replaces the HuBERT content features extracted from the input voice with the nearest k-means centroid. The theory is correct — a good cluster model smooths timbre variation for more stable output. The flaw was invisible: the training audio used to build those centroids was never vocally isolated.

# inference.py — Westfield SoVITS Covers Ltd. production pipeline
# so-vits-svc 4.1; PyTorch 2.0.1; Python 3.10

from so_vits_svc_fork.inference.main import infer

def run_cover_generation(
    input_path: str,
    output_path: str,
    speaker: str = "aria_soprano"
) -> None:
    infer(
        input_path=input_path,
        output_path=output_path,
        speaker=speaker,                 # "aria_soprano" or "luna_mezzo"
        model_path="models/multi_spk/G_200000.pth",
        config_path="models/multi_spk/config.json",
        cluster_model_path="models/cluster/kmeans_10000.pt",
        cluster_ratio=1.0,              # ← PROBLEM: full centroid replacement
                                        #   cluster model trained on raw songs
                                        #   (voice + background instruments mixed)
                                        #   ~50% of centroids encode instrument timbres
        noise_scale=0.4,
        f0_method="pm",
        db_thresh=-40,
        pad_seconds=0.5,
        chunk_seconds=30,
        absolute_thresh=False,
    )

# Results on 1,500 AI cover generation jobs (100 test conversions per speaker × 15 batches):
# User complaint #1: "Output sounds like voice mixed with background piano — not clean"
# User complaint #2: "Aria sometimes sounds like a violin, not a singer"
# User complaint #3: "Luna-mezzo has guitar overtones bleeding into the voice"
# Speaker similarity cosine (aria_soprano): 0.41  ← expected: 0.84
# Speaker similarity cosine (luna_mezzo):   0.40  ← expected: 0.83
# Naturalness MOS: 2.1  ← expected: 4.0
# Root cause: cluster_ratio=1.0 replaces HuBERT features with contaminated centroids

The k-means cluster model was built by extracting HuBERT content features from the training audio and running k-means clustering to produce 10,000 centroids. When cluster_ratio=1.0, inference replaces each HuBERT frame vector with its nearest centroid. This is the designed behavior — but the correctness of this replacement depends entirely on the quality of the centroids. Because the training audio was never passed through a stem separator, every frame of training audio contained a mixture of vocal signal and backing instruments. HuBERT’s feature extraction does not isolate voice: it encodes whatever acoustic content is present. With roughly 50% of the acoustic energy in each training frame coming from background instruments (kick drum, bass line, piano chords, guitar), approximately half of the resulting 10,000 centroid vectors encode instrument timbres rather than vocal phoneme characteristics. At inference with cluster_ratio=1.0, each input voice frame is assigned its nearest centroid — and that centroid has a coin-flip chance of representing an instrument timbre rather than a voice timbre.

How contaminated centroids corrupt every output frame at cluster_ratio=1.0

# K-means cluster model contamination analysis
# Training audio: 20 min × 2 speakers = 40 min of raw streaming songs
# No vocal isolation applied — voice + instruments mixed throughout
#
# HuBERT feature extraction on mixed audio:
#   HuBERT encodes acoustic content of whatever is present in the signal
#   Frame energy composition (estimated from raw pop song):
#     Vocal energy fraction:      ~50%  (varies by passage; choruses higher, verses lower)
#     Instrument energy fraction: ~50%  (bass, drums, guitar, piano, strings)
#
# K-means clustering result (10,000 centroids):
#   Centroid vectors in cluster space:
#     Vocal-dominant centroids:      ~5,000  (phoneme-like: vowels, consonants, vibrato)
#     Instrument-dominant centroids: ~5,000  (piano attack, string sustain, drum transient)
#
# At inference with cluster_ratio=1.0:
#   Input: clean isolated voice frame (user upload is a voice-only recording)
#   HuBERT extracts content vector h ∈ R^768 from input voice frame
#   Nearest centroid lookup: c = argmin_k ||h - centroid_k||
#   Because ~50% of centroids encode instrument timbres, there is ~50% probability
#   that the nearest centroid c encodes an instrument timbre rather than a vocal timbre
#
#   VITS decoder receives c (not h) as content input at cluster_ratio=1.0
#   Output frame timbre = target speaker identity × centroid c content
#   If c is an instrument centroid: output = "aria_soprano singing a piano chord"
#   If c is a vocal centroid:       output = "aria_soprano singing the phoneme"
#
# Measured quality degradation:
#   Speaker similarity cosine: 0.41 vs 0.84 expected
#   Naturalness MOS:           2.1  vs 4.0  expected
#   Perceptual description:    voice sounds like a mix of human voice and instruments
#     — sustained vowels carry string/piano overtone character
#     — transient consonants sometimes map to drum-attack centroids
#     — overall timbre is unstable, shifting between vocal and instrumental character

Why five months of retraining and parameter tuning could not fix contaminated centroids

The team received user complaints about instrument sounds bleeding into the voice and attributed the problem to insufficient training data or incorrect model parameters. Each month they ran a systematic intervention — but every intervention left the contaminated cluster model in place and cluster_ratio=1.0 unchanged. None of the modified parameters control what the cluster centroids encode.

# Month 1: Retrain with 40 minutes (doubled dataset — same raw streaming songs, no isolation)
#   Similarity: 0.42  MOS: 2.1
#   Reason no improvement: 2× more mixed-audio frames → 2× more instrument centroids
#   Doubling contaminated data does not improve centroid quality
#
# Month 2: Change slice_db from -40 to -30 (removes more silence; keeps only louder frames)
#   Similarity: 0.41  MOS: 2.0
#   Reason no improvement: louder frames still contain voice+instruments; db_thresh
#   filters silence, not instrument content — centroid contamination unchanged
#
# Month 3: Change noise_scale from 0.4 to 0.6 (adds variation to VITS synthesis)
#   Similarity: 0.40  MOS: 2.0
#   Reason no improvement: noise_scale perturbs the latent z in VITS synthesis;
#   it does not change which centroid is selected — contaminated centroids still used
#
# Month 4: Change f0_method from pm to crepe (pitch extraction)
#   Similarity: 0.41  MOS: 2.1
#   Reason no improvement: f0_method affects pitch (F0) extraction accuracy;
#   timbre contamination comes from the content features (HuBERT → centroid path),
#   which is independent of pitch extraction — same contaminated centroids used
#
# Month 5: Change cluster_ratio from 1.0 to 0.9 (slight reduction in centroid weight)
#   Similarity: 0.43  MOS: 2.1
#   Slight improvement: 0.9 × centroid + 0.1 × HuBERT_feature
#   10% clean HuBERT signal partially offsets contamination — but contaminated centroids
#   still dominate; team interpreted as "marginal noise, not the core problem" and stopped
#   MISSED: this was the first result showing the cluster model was the culprit
#
# Month 6 (would have been): Full rebuild with vocal isolation
#   Not attempted — retainer engagement requested instead
#
# Retainer triage (1.5h):
#   Step 1 (0.5h): Run inference with cluster_ratio=0 on 10 test inputs
#                  → similarity 0.82; MOS 3.9 — immediately high quality
#                  Confirms: cluster model is the entire problem; HuBERT features are fine
#   Step 2 (0.5h): Inspect cluster model training script → find raw streaming downloads
#                  used directly; no Demucs or other stem separation applied
#                  Confirm: centroids built from voice+instruments mix
#   Step 3 (0.5h): Document fix options:
#                  Option A (immediate): cluster_ratio=0 — bypasses cluster model entirely
#                  Option B (long-term): separate training audio with Demucs, rebuild
#                  k-means from vocals-only HuBERT features, then cluster_ratio=0.1–0.3

The retainer consultant identified the contaminated cluster model in 1.5 hours: 0.5h to run a one-line change — setting cluster_ratio=0 — on 10 test inputs and observe speaker similarity jump from 0.41 to 0.82 and MOS from 2.1 to 3.9; 0.5h to inspect the cluster model training script and confirm that the raw streaming downloads (voice+instruments) were fed directly to HuBERT without any stem separation preprocessing; 0.5h to document two remediation paths (immediate: set cluster_ratio=0 and deploy; long-term: re-separate training audio with Demucs, extract HuBERT features from vocals-only stems, rebuild k-means, then use cluster_ratio=0.1 for modest timbre smoothing from clean centroids). The month-5 observation of similarity improving from 0.41 to 0.43 at cluster_ratio=0.9 had been the clearest signal available — a monotone improvement as the centroid weight decreased toward zero — but the team had interpreted the 0.02-point similarity gain as noise rather than as evidence that the cluster model was the contamination source. Hours logged to HourTab with per-session breakdown.

# Fixed inference.py — Option A (immediate deployment fix)

from so_vits_svc_fork.inference.main import infer

def run_cover_generation(
    input_path: str,
    output_path: str,
    speaker: str = "aria_soprano"
) -> None:
    infer(
        input_path=input_path,
        output_path=output_path,
        speaker=speaker,
        model_path="models/multi_spk/G_200000.pth",
        config_path="models/multi_spk/config.json",
        cluster_model_path="models/cluster/kmeans_10000.pt",
        cluster_ratio=0.0,              # ← FIX: bypass contaminated cluster model entirely
                                        #   uses raw HuBERT content features (clean)
                                        #   cluster_model_path is ignored when ratio=0
        noise_scale=0.4,
        f0_method="pm",
        db_thresh=-40,
        pad_seconds=0.5,
        chunk_seconds=30,
        absolute_thresh=False,
    )

# --- Long-term fix (Option B): rebuild cluster model from isolated vocals ---
# Step 1: Separate training audio into vocal stems
#   from demucs.api import Separator
#   separator = Separator(model="htdemucs")
#   separator.separate_audio_file("raw_songs/aria_soprano_set.wav")
#   # outputs: vocals.wav, drums.wav, bass.wav, other.wav
#
# Step 2: Build k-means cluster model from vocals-only HuBERT features
#   python cluster/train_cluster.py \
#     --data_dir separated/vocals/ \
#     --output models/cluster/kmeans_10000_clean.pt \
#     --n_clusters 10000
#
# Step 3: Use clean cluster model with modest cluster_ratio
#   cluster_model_path="models/cluster/kmeans_10000_clean.pt",
#   cluster_ratio=0.1,  # slight timbre smoothing; centroids now encode vocal phonemes only

# After fix — Option A (cluster_ratio=0, contaminated cluster bypassed):
# Speaker similarity cosine (aria_soprano): 0.82  vs 0.41 pre-fix
# Speaker similarity cosine (luna_mezzo):   0.81  vs 0.40 pre-fix
# Naturalness MOS: 3.9  vs 2.1 pre-fix
# All 1,500 historical jobs reprocessed: similarity 0.82; MOS 3.9

Related retainer posts


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 →