tortoise-tts developer on retainer: torchaudio.load() returns 44100 Hz conditioning clips — tortoise.utils.audio.load_audio(path, 22050) required — speaker similarity 0.29 vs 0.73 — 8,000 user voice clones sound generic — $180,000 — 7 months — tortoise-tts developer on monthly retainer

tortoise-tts 2.4.3 • PyTorch 2.0.1 • Python 3.10; torchaudio.load(ref_path) returns 44100 Hz studio WAV; tortoise mel spectrogram uses hop_length=256, sample_rate=22050; at 44100 Hz: each frame covers 5.8 ms instead of 11.6 ms; conditioning encoder sees double-speed compressed voice representation; conditioning vector out-of-distribution; speaker similarity (ECAPA-TDNN) 0.29 vs 0.73; 8,000 beta users rate their voice clone as “sounds nothing like me”; 7 months of conditioning architecture experiments; $180,000; fix: from tortoise.utils.audio import load_audio; waveform = load_audio(ref_path, 22050) • Northfield Tortoise TTS Ltd. (4-person voice cloning platform; 7 months; 2.0h)

Northfield Tortoise TTS Ltd. is a 4-person startup building a voice cloning service for podcasters and independent audiobook narrators: users submit a 10-second voice reference clip and receive a personalized TTS voice that generates any text in their voice. Their backend used tortoise-tts’s TextToSpeech API with user-submitted conditioning clips. The voice loading code in the first production deployment was:

# voice_clone.py (tortoise-tts 2.4.3)
import torchaudio
import torch
from tortoise.api import TextToSpeech

tts = TextToSpeech()

def clone_voice(ref_path: str, text: str) -> torch.Tensor:
    # Load user reference clip
    waveform, sr = torchaudio.load(ref_path)
    # ref_path: user-submitted studio WAV, typically 44100 Hz, 24-bit
    # waveform: [1, T_at_44100hz]  sr: 44100

    # Pass directly as conditioning voice
    voice_samples = [waveform]   # <-- BUG: 44100 Hz; tortoise expects 22050 Hz
    gen = tts.tts_with_preset(
        text,
        voice_samples=voice_samples,
        preset='fast',
    )
    return gen.squeeze(0).cpu()

The engineer modeled the voice loading code on examples that used torchaudio.load() for other audio tasks. The tortoise-tts documentation and the TextToSpeech.tts_with_preset() docstring do not explicitly state that voice_samples must be at 22050 Hz — this requirement is documented in tortoise/utils/audio.py’s load_audio() function, which is the official helper for conditioning clip loading. The API accepted a 44100 Hz tensor without raising an exception; both 44100 Hz and 22050 Hz tensors are valid torch.Tensor objects.

How 44100 Hz conditioning breaks the mel spectrogram

Tortoise’s conditioning pipeline computes mel spectrograms of the reference clips with fixed parameters defined in tortoise/utils/audio.py:

# tortoise/utils/audio.py (tortoise-tts 2.4.3)
# Mel spectrogram parameters — fixed for all conditioning audio
SAMPLE_RATE = 22050
N_FFT = 4096
HOP_LENGTH = 256
WIN_LENGTH = 1024
N_MELS = 100

# At correct 22050 Hz input:
# - Frame duration: 256 / 22050 = 11.6 ms per frame
# - Frequency coverage: 0 to 11025 Hz (Nyquist of 22050 Hz)
# - 10-second clip → 22050×10/256 = 862 spectrogram frames

# At wrong 44100 Hz input (torchaudio.load from studio WAV):
# - Frame duration: 256 / 44100 = 5.8 ms per frame  ← half the expected duration
# - Frequency coverage: 0 to 22050 Hz (Nyquist of 44100 Hz)
# - 10-second clip → 44100×10/256 = 1,723 frames  ← twice as many frames
# - Each frame represents half the expected phoneme context
# - Mel bins map to twice the expected frequency range

The conditioning encoder — a small convolutional network trained on 22050 Hz spectrograms at 11.6 ms per frame — received spectrograms where every temporal pattern was compressed to half its true duration. A 100 ms vowel formant trajectory (8.6 frames at correct rate) appeared as 17.2 frames. The encoder’s convolutional receptive fields, designed to capture phoneme-length segments at 11.6 ms per frame, now captured half-phoneme segments at 5.8 ms per frame. The resulting conditioning latent vector was in an out-of-distribution region of the encoder’s output space — it did not encode the speaker’s pitch, timbre, or prosodic signature accurately.

# Diagnostic: compare conditioning latents at different sample rates
from tortoise.utils.audio import load_audio
import torchaudio

# Correct: load at 22050 Hz via tortoise helper
waveform_22k = load_audio('ref.wav', 22050)   # resamples to 22050 Hz

# Bug: raw torchaudio.load — may be 44100 Hz for studio recordings
waveform_raw, sr_raw = torchaudio.load('ref.wav')
print(f"Raw sample rate: {sr_raw}")   # → 44100 (for studio WAV)

# Speaker similarity evaluation (ECAPA-TDNN cosine similarity):
# voice_samples=[waveform_22k] → speaker similarity: 0.72
# voice_samples=[waveform_raw] → speaker similarity: 0.29

# The difference: 0.72 - 0.29 = 0.43 (massive degradation)
# Similarity < 0.5 → generated voice sounds "generic" to human listeners

Seven months of conditioning architecture experiments

The team received 8,000 user registrations in the first two months of beta. Of those, 7,900 (98.75%) gave the voice clone a 1-star rating with comments including “sounds nothing like me,” “sounds like a generic American voice,” and “did not clone my voice at all.” The team attributed the failure to insufficient reference audio and started a series of conditioning architecture improvements:

# Seven months of interventions (voice_samples still using 44100 Hz raw waveforms)

# Month 1: more reference clips per user
# 1 clip → 10 clips (users prompted to record 10 × 10-second sentences)
# Speaker similarity: 0.29 → 0.31  (+0.02)

# Month 2: 'standard' preset (more samples, more diffusion steps)
# preset='fast' → preset='standard'
# 0.31 → 0.33  (+0.02)

# Month 3: conditioning encoder fine-tuning on user data
# Fine-tune last 3 layers of conditioning_encoder on 500 user clips
# 0.33 → 0.35  (+0.02)

# Month 4: voice conversion pre-stage
# Convert reference to a "canonical" acoustic space before conditioning
# 0.35 → 0.38  (+0.03)

# Month 5: higher-quality audio requirement
# Require 48kHz microphone recording; reject uploads below SNR threshold
# 0.38 → 0.40  (+0.02)
# (Note: 48kHz clips were ALSO passed raw at 48000 Hz — still wrong rate)
# This helped slightly because 48kHz has better high-frequency content

# Month 6: tortoise fine-tuning on user voices
# Individual model fine-tune per user (10 clips, 50 steps)
# 0.40 → 0.41  (+0.01, expensive: 2 GPU-min per user)

# Month 7: voice conversion intermediate stage
# Full VC pipeline before conditioning
# 0.41 → 0.43  (+0.02)

# CEILING: 0.43  (target: 0.73, human threshold for perceived similarity: ~0.60)
# All improvements genuine but ceiling far below target

The retainer consultant identified the sample rate issue in 2.0 hours: 0.5h to audit the conditioning voice loading code, trace the data flow through torchaudio.load(), and confirm the native sample rate of user-submitted audio was 44100 Hz; 0.5h to read tortoise/utils/audio.py and confirm SAMPLE_RATE = 22050 and the load_audio() helper; 0.5h to change the loading code, re-evaluate speaker similarity on 500 test pairs, and confirm the metric improved to 0.71; 0.5h to audit all audio loading paths in the codebase, add the sample rate assertion, implement the similarity check in the registration flow, and document the load_audio() requirement. Hours logged to HourTab with per-session breakdown.

# Fixed voice_clone.py

from tortoise.api import TextToSpeech
from tortoise.utils.audio import load_audio   # use the official helper
import torch

tts = TextToSpeech()

def clone_voice(ref_path: str, text: str) -> torch.Tensor:
    # load_audio() resamples to 22050 Hz regardless of input sample rate
    # handles: 44100 Hz studio WAV, 48000 Hz video audio, 16000 Hz speech WAV
    waveform = load_audio(ref_path, 22050)   # was: torchaudio.load(ref_path)
    # waveform: [1, T_at_22050hz]

    voice_samples = [waveform]
    gen = tts.tts_with_preset(
        text,
        voice_samples=voice_samples,
        preset='fast',
    )
    return gen.squeeze(0).cpu()

# Assertion for new audio loading code (add to registration validation):
def validate_conditioning_clip(ref_path: str) -> float:
    import soundfile as sf
    info = sf.info(ref_path)
    if info.samplerate not in (22050, 44100, 48000, 16000):
        raise ValueError(f"Unexpected sample rate {info.samplerate} in {ref_path}")
    # Always use load_audio() — it handles resampling
    waveform = load_audio(ref_path, 22050)
    # Verify the resampled audio is at 22050 Hz by checking tensor length
    duration = waveform.shape[-1] / 22050
    assert 5 <= duration <= 30, f"Conditioning clip duration {duration:.1f}s outside 5–30s range"
    return duration

# After fix and re-evaluation on 500 test pairs:
# Speaker similarity (ECAPA-TDNN): 0.71  (was: 0.29 with raw 44100 Hz load)
# User 5-star rating rate: 72%  (was: 1.25% — the 100 users who happened to submit 22050 Hz)
# Production speaker similarity threshold: >0.60 required at registration

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 →