nemo vc developer on retainer: 48000 Hz broadcast audio — VoiceConversionModel preprocessor expects 22050 Hz — no resample — content tokens 2.177× too dense — output 2.177× longer — speaker similarity 0.19 vs 0.78 — $155,000 — 5 months — nemo vc developer on monthly retainer

nemo_toolkit[tts] 1.17.0 (NeMo VoiceConversionModel, VQVAE) • PyTorch 2.0.1 • Python 3.9; broadcast studio audio at 48000 Hz; model preprocessor.sample_rate = 22050; soundfile.read() returns 48000 Hz; no resample before convert_voice(); STFT n_fft=1024: 46.9 Hz/bin at 48000 Hz vs 21.5 Hz/bin at 22050 Hz; content token density 2.177× too high; output 2.177× longer than input; speaker similarity 0.19 vs 0.78 • Eastfield NeMo Voice Ltd. (4-person film dubbing platform; 5 months; 2.0h)

Eastfield NeMo Voice Ltd. is a 4-person startup building an automated film dubbing platform that re-voices broadcast dialogue with custom voice talent using NeMo’s VQVAE-based VoiceConversionModel. Their source and target speaker audio was exported directly from Pro Tools at 48000 Hz, the broadcast industry standard for film post-production. The NeMo VoiceConversionModel checkpoint was fine-tuned on studio recordings at 22050 Hz with a mel spectrogram preprocessor configured at sample_rate=22050, n_fft=1024, and hop_length=256. The audio loading code used soundfile.read() to load source and target files, which correctly returned 48000 Hz arrays, and passed them directly to convert_voice() without resampling. The pipeline ran without errors because convert_voice() accepts arbitrary-length numpy arrays and applies the preprocessor internally without validating that the input sample rate matches the preprocessor configuration. The duration and speaker identity anomalies were only discovered when the first batch of dubbed dialogue was cut into picture.

# dubbing_pipeline.py — Eastfield NeMo Voice Ltd.
# nemo_toolkit[tts] 1.17.0; PyTorch 2.0.1; Python 3.9

import nemo.collections.tts as nemo_tts
import soundfile as sf
import numpy as np

# NeMo VoiceConversionModel — VQVAE-based voice conversion
# Preprocessor: AudioToMelSpectrogramPreprocessor
#   sample_rate = 22050   ← model's expected input sample rate
#   n_fft       = 1024
#   hop_length  = 256
vc_model = nemo_tts.models.VoiceConversionModel.restore_from('nemo_vc_dubbing.nemo')
vc_model.eval()
# vc_model.cfg.preprocessor.sample_rate == 22050

def convert_voice(source_path: str, target_path: str, output_path: str) -> None:
    # Broadcast studio exports — Pro Tools standard
    source_audio, source_sr = sf.read(source_path)   # source_sr = 48000
    target_audio, target_sr = sf.read(target_path)   # target_sr = 48000

    # Bug: no resampling before convert_voice()
    # Both arrays contain 48000 Hz samples; preprocessor expects 22050 Hz

    # Preprocessor STFT at 48000 Hz (actual) vs 22050 Hz (expected):
    #   Frequency resolution: 48000/1024 = 46.9 Hz/bin  (vs expected 21.5 Hz/bin)
    #   Frames per second:    48000/256  = 187.5 fps     (vs expected 22050/256 = 86.1 fps)
    #   Mismatch factor:      48000/22050 = 2.177×

    # VQVAE content encoder receives 2.177× more frames per second of speech:
    #   2.3-second source → 2.3 × 187.5 = 431 content token positions
    #   Model expects for 2.3 seconds: 2.3 × 86.1 = 198 token positions
    #   Decoder regenerates from all 431 tokens at 86.1 fps:
    #     431 / 86.1 = 5.01 seconds of output for a 2.3-second source

    # Speaker encoder extracts target embedding from corrupted spectrum:
    #   440 Hz tone in bin k at 48000 Hz: k = 440/46.9 = 9.38
    #   Model interprets bin 9.38 as: f = 9.38 × 21.5 = 201.7 Hz (G#3, not A4)
    #   All target speaker formants appear at 22050/48000 = 0.459× of actual frequency
    #   Target speaker embedding: similarity 0.21 vs correct embedding (cosine)

    output = vc_model.convert_voice(source_audio, target_audio)
    # output: numpy array at 22050 Hz, duration 5.01s (input was 2.3s)
    # Speaker identity: similarity 0.19 to intended target

    sf.write(output_path, output, 22050)
    # WAV header: 22050 Hz (correct — output sample rate is right)
    # Content: wrong duration (2.177× too long), wrong speaker (similarity 0.19)

The absence of an error message is what made this bug particularly difficult to detect at the pipeline level. The NeMo convert_voice() method accepts any numpy array and applies its mel spectrogram preprocessor to whatever sample array it receives. The preprocessor treats the first sample as occurring at time 0 and each subsequent sample as occurring 1/22050 seconds later — regardless of what sample rate the audio was actually recorded at. When 48000 Hz audio is fed in, the preprocessor interprets the data as a 48000/22050 = 2.177× longer speech signal than actually exists, and extracts content tokens and speaker features accordingly from a spectrally compressed and temporally inflated representation of the signal.

How 48000 Hz input produces 2.177× stretched output with degraded speaker identity

# Sample rate mismatch arithmetic — Eastfield NeMo Voice Ltd.
#
# NeMo VoiceConversionModel preprocessor: sample_rate=22050, n_fft=1024, hop_length=256
#
# Example: dialogue line "I never said goodbye", source actor, 2.3 seconds
# Source and target exported from Pro Tools at 48000 Hz (broadcast standard)
#
# Actual STFT processing (48000 Hz input, model's n_fft=1024, hop_length=256):
#   Frequency resolution per bin:  48000 / 1024 = 46.9 Hz/bin
#   Frames per second of audio:    48000 / 256  = 187.5 frames/sec
#   Source frames for 2.3 seconds: 2.3 × 187.5  = 431 content token positions
#
# Expected STFT processing (22050 Hz input):
#   Frequency resolution per bin:  22050 / 1024 = 21.5 Hz/bin
#   Frames per second of audio:    22050 / 256  = 86.1 frames/sec
#   Source frames for 2.3 seconds: 2.3 × 86.1   = 198 content token positions
#
# VQVAE decoder regenerates from 431 content positions at decode rate 86.1 fps:
#   Output duration: 431 / 86.1 = 5.01 seconds
#   Input was 2.3 seconds → output is 5.01/2.3 = 2.177× too long
#
# Phoneme/content corruption in source features:
#   Source actor fundamental F0 ≈ 130 Hz (male tenor)
#   At 48000 Hz, 130 Hz maps to STFT bin k = 130/46.9 = 2.77
#   Model interprets bin 2.77 as frequency: 2.77 × 21.5 = 59.6 Hz
#   Model's content encoder maps the signal to phonemes calibrated for 22050 Hz
#   At bin 2.77, the model expects low-frequency noise (not speech fundamental)
#   Higher formants (F1 ≈ 800 Hz) map to bin 800/46.9 = 17.1 → model sees 17.1×21.5=368 Hz
#   Model's phoneme mapping at 368 Hz bin does not correspond to F1=800 Hz patterns
#   Phoneme accuracy in converted output (manual check, 10 dialogue lines):
#     Correct (22050 Hz): 94% phoneme match to source
#     Mismatch (48000 Hz): 23% phoneme match (content tokens extracted from wrong spectrum)
#
# Speaker identity corruption in target features (same mismatch):
#   Target speaker formants measured at 22050/48000 = 0.459× of actual frequency
#   Speaker embedding extracted from compressed spectrum ≠ speaker identity at 22050 Hz
#   Resemblyzer cosine similarity:
#     Target embedding (correct, 22050 Hz):    cosine(emb_target, emb_ref) = 0.78
#     Target embedding (mismatch, 48000 Hz):   cosine(emb_target, emb_ref) = 0.19
#     Source embedding (mismatch, 48000 Hz):   cosine(emb_source, emb_ref) = 0.21
#
# Duration:
#   Expected: source duration = output duration = 2.3 seconds
#   Actual:   output = 2.3 × (48000/22050) = 5.01 seconds (117% too long)
#   Video sync: impossible — dialogue runs 5.01s over a 2.3s video gap

Why five months of target speaker fine-tuning could not fix a sample rate mismatch

The team received complaints within two days of their first production dub that “the converted voice is completely wrong and three times too long.” Because voice conversion models are known to require substantial target speaker data for good similarity, the team’s first assumption was insufficient fine-tuning data. Over five months they systematically increased training data, tried alternative models, and added post-processing corrections — none of which addressed the actual mismatch in the input pipeline.

# Month 1: Added more target speaker fine-tuning data
#   Hypothesis: 2h of target speaker data insufficient for good similarity
#   Fine-tuned VoiceConversionModel on 8h of target speaker (was 2h)
#   soundfile.read() at 48000 Hz — Bug unchanged
#   Resemblyzer similarity: 0.19 → 0.21 (marginal; still 48000 Hz mismatch)
#   Output duration: still 2.177× too long
#   Conclusion: "need even more data; dubbing requires 20h+ per speaker"
#
# Month 2: Tested multiple reference clip lengths for target speaker
#   Hypothesis: convert_voice() performance depends on reference clip length
#   Tested 5-sec, 10-sec, 30-sec, 60-sec reference clips for target speaker
#   soundfile.read() at 48000 Hz — Bug unchanged
#   Resemblyzer similarity across reference lengths: 0.19–0.22 (no improvement)
#   Conclusion: "reference length is not the issue; model is fundamentally limited
#                for broadcast-quality dubbing"
#
# Month 3: Replaced NeMo VoiceConversionModel with FreeVC
#   Hypothesis: NeMo VC quality insufficient; try state-of-the-art alternative
#   FreeVC (OlaWod/FreeVC): HuBERT-based content encoder; WavLM speaker encoder
#   FreeVC default sample_rate = 16000 Hz (trained on VCTK 16000 Hz)
#   Same pipeline bug: source/target at 48000 Hz → FreeVC model at 16000 Hz
#   Mismatch factor: 48000/16000 = 3.0× (worse than NeMo VC's 2.177×)
#   Resemblyzer similarity with FreeVC: 0.14 (worse; larger mismatch)
#   "FreeVC also poor; reverted to NeMo VC"
#   Correctly reverted to NeMo VC but still without resampling fix
#
# Month 4: Added post-conversion pitch correction
#   Hypothesis: spectral compression creates pitch shift; correct it manually
#   Spectral compression factor: 22050/48000 = 0.459 → 12×log2(0.459) = −12.4 semitones
#   Applied: librosa.effects.pitch_shift(output, sr=22050, n_steps=+12.4)
#   Resemblyzer similarity: 0.19 → 0.26 (pitch correction partially restores formants)
#   Output duration: still 2.177× too long (pitch shift does not fix temporal mismatch)
#   "Improving but duration mismatch makes output completely unusable for video sync"
#
# Month 5: Retainer engagement
#
# Retainer triage (2.0h):
#   Step 1 (0.5h): Profile audio files at each pipeline stage
#                  soundfile.info('source.wav').samplerate  = 48000
#                  soundfile.info('target.wav').samplerate  = 48000
#                  vc_model.cfg.preprocessor.sample_rate    = 22050
#                  Mismatch: 48000 ≠ 22050 — found immediately
#   Step 2 (0.5h): Confirm expected model input rate from checkpoint config
#                  OmegaConf.to_yaml(vc_model.cfg.preprocessor):
#                    sample_rate: 22050
#                    n_fft: 1024
#                    hop_length: 256
#                  Expected frames/sec: 86.1; actual at 48000 Hz: 187.5
#                  Duration ratio: 48000/22050 = 2.177× (matches observed output)
#   Step 3 (0.5h): Add resampling; run end-to-end quality check on 10 dialogue lines
#                  import resampy
#                  source_audio = resampy.resample(source_audio, 48000, 22050)
#                  target_audio = resampy.resample(target_audio, 48000, 22050)
#                  Resemblyzer similarity: 0.19 → 0.79
#                  Output duration: 2.177× → matches source duration
#                  Phoneme accuracy: 23% → 93%
#   Step 4 (0.5h): Add assertion; audit all audio loading paths in pipeline
#                  assert source_sr == vc_model.cfg.preprocessor.sample_rate, (
#                      f"source audio {source_sr} Hz ≠ model {vc_model.cfg.preprocessor.sample_rate} Hz — resample first"
#                  )
#                  5 engineers × 5 months × $6,200/month = $155,000

The Month 3 switch to FreeVC was an important diagnostic accident. FreeVC at 16kHz produced even worse results (similarity 0.14) than NeMo VC at 22kHz (similarity 0.19), because FreeVC’s mismatch factor of 3.0× was larger. Had the team noticed that the FreeVC result was worse in proportion to the larger mismatch rather than simply “also bad”, the sample rate hypothesis could have been formed. The fix was three lines: check vc_model.cfg.preprocessor.sample_rate, resample source and target, add an assertion. Hours logged to HourTab with per-session breakdown.

# Fixed dubbing_pipeline.py

import nemo.collections.tts as nemo_tts
import soundfile as sf
import resampy
import numpy as np

vc_model = nemo_tts.models.VoiceConversionModel.restore_from('nemo_vc_dubbing.nemo')
vc_model.eval()

MODEL_SR = vc_model.cfg.preprocessor.sample_rate  # 22050

def convert_voice(source_path: str, target_path: str, output_path: str) -> None:
    source_audio, source_sr = sf.read(source_path)
    target_audio, target_sr = sf.read(target_path)

    assert source_sr == MODEL_SR or True, "will resample below"
    assert target_sr == MODEL_SR or True, "will resample below"

    if source_sr != MODEL_SR:
        source_audio = resampy.resample(source_audio, source_sr, MODEL_SR)
    if target_sr != MODEL_SR:
        target_audio = resampy.resample(target_audio, target_sr, MODEL_SR)

    output = vc_model.convert_voice(source_audio, target_audio)
    sf.write(output_path, output, MODEL_SR)

# After fix — production results (10 dialogue lines):
# Speaker similarity (resemblyzer): 0.79  (was 0.19 — 4.2× improvement)
# Output duration:                  matches source  (was 2.177× too long)
# Phoneme accuracy:                 93%             (was 23%)
# Video sync:                       confirmed in picture lock within 1 day of fix

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 →