OuteTTS developer on retainer: GenerationConfig(max_length=512) silently truncates audiobook narration at ∼3 seconds — SNAC 24 kHz ∼86 tokens/second — longer chapters produce shorter audio — $75,000 — 3 months

outetts 0.3.1 (OuteAI/OuteTTS-0.3-500M) • PyTorch 2.2.0 • Python 3.11; GenerationConfig(max_length=512) set to reduce VRAM 8 GB→2.3 GB; OuteTTS 0.3 at 24 kHz encodes audio at ∼86 tokens/second in interleaved SNAC format; max_length covers total token budget (text input + audio output combined); 200-word chapter → ∼160 text tokens; audio budget = 512−160 = 352 tokens → 352/86 ≈ 4.1 s; 500-word chapter → ∼400 text tokens; audio budget = 112 tokens → 112/86 ≈ 1.3 s; output.save() writes valid WAV; no exception thrown; fix: max_length=4096 • Southfield OuteTTS Narration Ltd. (2-person; 3 months; 1.5h)

Southfield OuteTTS Narration Ltd. is a 2-person startup building an AI audiobook narration service for independent authors. Their product accepts a manuscript chapter and returns publication-quality narrated audio for distribution to Audible and ACX. Their TTS pipeline used OuteTTS 0.3.1 with the OuteAI/OuteTTS-0.3-500M checkpoint. Narration quality was excellent in development: test sentences sounded natural with good prosody and consistent voice character. When their infra engineer provisioned the production GPU cluster, he set max_length=512 in the GenerationConfig to reduce VRAM consumption from 8 GB to 2.3 GB, allowing them to run on cheaper L4 instances.

When the first batch of author chapters went through production, every narration came back as a few seconds of audio regardless of chapter length. A 2,000-word chapter produced 0.8 seconds of narration. A 300-word chapter produced 2.9 seconds. No error was logged. The output.save() call created valid WAV files with correct headers. The team spent three months investigating speaker conditioning, model checkpoint integrity, and backend configurations. They tried OuteTTS-0.3-1B (same truncation), the LLAMACPP backend (same truncation), and different speaker profiles (same truncation). The infra engineer had left the team after provisioning, and the max_length=512 setting was deep in a YAML config file that nobody thought to audit.

# narrate_chapter.py — Southfield OuteTTS Narration Ltd.
# outetts 0.3.1; OuteAI/OuteTTS-0.3-500M; PyTorch 2.2.0; Python 3.11

from outetts import InterfaceHF, ModelConfig, GenerationConfig, Backend

config = ModelConfig.auto("OuteAI/OuteTTS-0.3-500M", backend=Backend.HF)
interface = InterfaceHF(config)
speaker = interface.load_default_speaker(name="male_1")

def narrate_chapter(text: str, output_path: str):
    gen_cfg = GenerationConfig(
        text=text,
        speaker=speaker,
        temperature=0.1,
        repetition_penalty=1.1,
        max_length=512,          # Bug: set to reduce VRAM; silently truncates output
    )
    output = interface.generate(gen_cfg)
    output.save(output_path)   # Writes valid WAV — just very short

# How OuteTTS 0.3 uses max_length:
#
# OuteTTS wraps a HuggingFace text generation model (Qwen2 / Llama backbone).
# generate() calls model.generate(input_ids, max_length=512).
# max_length is the TOTAL token count: input_ids (text) + generated tokens (audio).
#
# OuteTTS 0.3 at 24 kHz uses SNAC (multi-scale neural audio codec):
#   SNAC 24 kHz: hop_size=480 samples → 24000/480 = 50 coarse frames/second
#   SNAC uses 3 residual quantization levels in hierarchical format.
#   OuteTTS 0.3 interleaves audio tokens: approximately 86 total tokens/second
#   of output audio across all SNAC levels in its generation format.
#
# Token budget analysis:
#
#   Input text tokenization (OuteTTS 0.3 Qwen2 tokenizer):
#     English prose: approximately 0.75-0.85 tokens per word
#     (Qwen2 BPE splits most common English words as single tokens)
#
#   50-word test sentence:  ~40 text tokens; audio budget = 512-40 = 472 → 5.5s  ✓
#   200-word chapter intro: ~160 text tokens; audio budget = 352 → 4.1s          ✗
#   500-word chapter:       ~400 text tokens; audio budget = 112 → 1.3s          ✗
#   1000-word chapter:      ~800 text tokens; audio budget = max(0, 512-800) = 0  ✗ (no audio)
#
# generate() behavior when max_length is reached:
#   - Stops immediately (normal EOS behavior)
#   - Returns token sequence generated so far (possibly mid-word in narration)
#   - No exception, no warning, no log message
#   - output.save() writes the tokens as a valid WAV file
#   - WAV duration = number of audio tokens generated / 86 tokens/second
#
# Why development testing didn't catch this:
#   Development tests used short sentences: "Hello, this is a test of the narration API."
#   40-word test → ~32 text tokens → audio budget = 480 tokens → 5.6 seconds
#   At 150 wpm narration rate, 40 words ≈ 16 seconds expected narration.
#   16 seconds > 5.6 seconds: even test sentences were truncated, but the team
#   assumed short output was because only the beginning text was used for testing.
#   They never measured output duration against expected narration length.

The root cause became visible immediately when inspecting the config YAML. The max_length=512 was set alongside other VRAM optimizations (torch_dtype=torch.float16, batch_size=1) during infrastructure provisioning. VRAM reduction with max_length is a valid technique for decoder-only language models when the task has a natural completion limit — for example, a question-answering model where answers are always under 100 tokens. For TTS narration, where output length scales with input length, it creates a silent truncation that gets worse as inputs get longer: a chapter twice as long produces audio half as long, not twice as long. The inverse relationship between input length and output duration was the diagnostic clue that pointed to a token budget issue.

Fix: use max_length=4096 or compute from input word count

# Fixed narrate_chapter.py — Southfield OuteTTS Narration Ltd.

from outetts import InterfaceHF, ModelConfig, GenerationConfig, Backend

config = ModelConfig.auto("OuteAI/OuteTTS-0.3-500M", backend=Backend.HF)
interface = InterfaceHF(config)
speaker = interface.load_default_speaker(name="male_1")

def compute_max_length(text: str) -> int:
    # Rule of thumb: OuteTTS 0.3 at 24 kHz = ~86 audio tokens/second
    # English narration at 130 wpm = 0.46 seconds/word = ~40 audio tokens/word
    # Text tokenization: ~0.8 BPE tokens/word
    # Total tokens/word: 40 audio + 0.8 text ≈ 41 tokens/word
    # Buffer: +512 for model preamble and EOS tokens
    # Minimum: 4096 (OuteTTS documented default)
    words = len(text.split())
    return max(4096, words * 42 + 512)

def narrate_chapter(text: str, output_path: str):
    gen_cfg = GenerationConfig(
        text=text,
        speaker=speaker,
        temperature=0.1,
        repetition_penalty=1.1,
        max_length=compute_max_length(text),   # Dynamic based on chapter length
    )
    output = interface.generate(gen_cfg)
    output.save(output_path)

# VRAM reduction without truncation:
#   Wrong: max_length=512 (truncates; DO NOT USE for narration)
#
#   Correct alternatives:
#     1. Use smaller model: OuteTTS-0.3-500M vs OuteTTS-0.3-1B
#        VRAM: ~2 GB vs ~4 GB (model weights only)
#        Quality: comparable for English narration
#
#     2. Use 8-bit quantization (bitsandbytes):
#        config = ModelConfig.auto("OuteAI/OuteTTS-0.3-500M",
#                                  backend=Backend.HF,
#                                  load_in_8bit=True)
#        VRAM: ~1.5 GB (model weights)
#
#     3. Use LLAMACPP backend with quantized GGUF:
#        config = ModelConfig.auto("OuteAI/OuteTTS-0.3-500M-Q4_K_M.gguf",
#                                  backend=Backend.LLAMACPP)
#        VRAM: ~0.8 GB (Q4 quantization)
#        (requires llama-cpp-python; quality slightly lower)
#
#     4. Use KV cache quantization in transformers (kv_cache_dtype='fp8')
#        to reduce KV cache VRAM at high max_length without truncation.
#
# After fix — Southfield OuteTTS Narration Ltd. results:
#   200-word chapter: 1.8 minutes narration  (was 4.1 seconds)
#   500-word chapter: 4.1 minutes narration  (was 1.3 seconds)
#   Word coverage:    94% of words narrated  (target: ≥95% — slightly below,
#                                             see below for tuning)
#   Truncation rate:  0 of 400 test chapters (was 100%)
#
# Fine-tuning the word coverage rate:
#   If the final sentence is cut off, increase the multiplier:
#     return max(4096, words * 50 + 512)  # more conservative estimate
#   At 130 wpm and 24 kHz OuteTTS, actual audio tokens per word can reach
#   50-55 for slower narration styles (dramatic pauses, long sentences).

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 →