resemble enhance developer on retainer: enhance() returns out_sr=44100 — torchaudio.save(output_path, out_wav, 16000) hardcoded from prior Whisper pipeline — audio 2.756× too slow — pitch −17.5 semitones — $80,000 — 3 months — resemble enhance developer on monthly retainer

resemble-enhance v0.0.1 (ResembleAI, Oct 2023) • PyTorch 2.0.1 • Python 3.10; enhance(dwav, sr=16000, device='cuda') returns out_sr=44100; torchaudio.save(output_path, out_wav, 16000) hardcoded from prior Whisper ASR pipeline; 44100 Hz PCM written with 16000 Hz WAV header; playback 2.756× too slow; pitch −17.5 semitones (12 × log⊂2;(16000/44100)); enhanced speech sounds like slowed-down drone; DNSMOS OVR 2.1 → 3.8 after fix; fix: torchaudio.save(output_path, out_wav.unsqueeze(0), out_sr) • Northfield Resemble Voice Ltd. (2-person podcast enhancement API startup; 3 months; 1.5h)

Northfield Resemble Voice Ltd. is a 2-person startup building an automated podcast audio enhancement API. Their product takes raw podcast recordings — often captured on laptop microphones, in noisy home offices, or over Zoom — and applies speech enhancement to improve clarity before distribution. Their initial pipeline used OpenAI Whisper for ASR, which processes audio at 16000 Hz. All audio saving in the pipeline used torchaudio.save(output_path, wav, 16000) throughout. When they integrated resemble-enhance as a preprocessing step before transcription, they inserted a call to enhance(dwav, sr=16000, device='cuda') and saved the output with the existing save call that hardcoded 16000 as the sample rate. The enhance() function returns a tuple (out_wav, out_sr) where out_sr is always 44100 regardless of input sample rate — resemble-enhance is a super-resolution model that upsamples all input to 44100 Hz. The team saved the 44100 Hz output with a 16000 Hz WAV header. Every “enhanced” file played back at 2.756× too slow, with the speakers sounding like they were speaking from deep underwater. Clients reported the product as “completely broken.”

# enhance_pipeline.py — Northfield Resemble Voice Ltd.
# resemble-enhance v0.0.1; PyTorch 2.0.1; Python 3.10

import torch
import torchaudio
from resemble_enhance.enhancer.inference import enhance

device = 'cuda' if torch.cuda.is_available() else 'cpu'

def process_podcast_episode(input_path: str, output_path: str):
    # Load input audio — typically 16kHz from Zoom or Teams recordings
    dwav, sr = torchaudio.load(input_path)
    # sr = 16000 (Zoom export, also compatible with Whisper ASR)
    # dwav shape: [1, T_16k]

    # Enhance audio using resemble-enhance
    # enhance() always outputs at 44100 Hz regardless of input sr
    out_wav, out_sr = enhance(dwav.squeeze(0), sr, device, run_args=None)
    # out_sr = 44100  ← resemble-enhance super-resolution output is always 44100 Hz
    # out_wav shape: [T_44k]  (T_44k = T_16k × 44100/16000 = T_16k × 2.756)

    # Bug: hardcoded 16000 from prior Whisper ASR pipeline
    # torchaudio.save(path, wav, sample_rate) writes sample_rate into WAV header
    # out_wav contains 44100 Hz PCM; header will say 16000 Hz
    torchaudio.save(
        output_path,
        out_wav.unsqueeze(0),
        16000   # Bug: should be out_sr (44100); 16000 is the INPUT rate, not OUTPUT rate
    )
    # WAV file on disk:
    #   Header: samplerate = 16000  ← WRONG (matches prior Whisper pipeline)
    #   PCM data: 44100 samples per second of audio  ← CORRECT (resemble-enhance output)
    #
    # Media player reads header: samplerate = 16000
    # Consumes 16000 samples per second of wall time
    # 44100 samples per second of audio → needs 44100/16000 = 2.756 seconds to play 1 second
    # Speed: 16000/44100 = 0.363× (2.756× too slow)
    # Pitch: 12 × log2(16000/44100) = 12 × (−1.463) = −17.5 semitones
    #
    # 200 Hz (G3) speaker voice → perceived at 200 × 0.363 = 72.6 Hz (deep bass drone)
    # 3kHz consonants → perceived at 3000 × 0.363 = 1089 Hz (muffled low frequency)
    # Complete loss of intelligibility at normal playback speed

The error is structurally identical to saving AudioGen output (16000 Hz) with a 44100 Hz header, but reversed in direction: AudioGen causes audio that is 2.756× too fast, while resemble-enhance used this way causes audio that is 2.756× too slow. In both cases, the fundamental issue is that the audio saving code assumes the output sample rate matches the input, but the model internally changes the sample rate. The resemble-enhance case is particularly easy to miss because the pipeline’s prior components (Whisper, standard speech processing) all operated at 16000 Hz, making 16000 feel like a safe constant throughout the codebase.

How 44100 Hz output saved with a 16000 Hz header produces 2.756× playback slowdown and −17.5 semitone pitch shift

# Sample rate mismatch arithmetic — Northfield Resemble Voice Ltd.
#
# resemble-enhance model:
#   Input: dwav at sr=16000 Hz (Zoom recording, 16kHz)
#   Output: out_wav at out_sr=44100 Hz (always; super-resolution)
#
# Saving code:
#   torchaudio.save(output_path, out_wav.unsqueeze(0), 16000)
#   WAV header samplerate = 16000  ← wrong (matches INPUT, not OUTPUT)
#   PCM data = 44100 Hz actual content
#
# Example: 1 hour podcast episode
#   Input duration:  3600 seconds
#   Input samples:   3600 × 16000 = 57,600,000 samples
#   Output samples:  3600 × 44100 = 158,760,000 samples (resemble-enhance upsampled)
#
#   WAV header says samplerate = 16000
#   Media player reads: 158,760,000 samples ÷ 16000 samples/sec = 9922.5 seconds = 2.756 hours
#   Actual content:     158,760,000 samples ÷ 44100 samples/sec = 3600 seconds (1 hour)
#
#   Speed factor: 16000 / 44100 = 0.363× (2.756× too slow)
#
#   Pitch shift formula:
#     Δf = 12 × log2(claimed_rate / actual_rate)
#        = 12 × log2(16000 / 44100)
#        = 12 × log2(0.3628)
#        = 12 × (−1.463)
#        = −17.54 semitones ≈ −17.5 semitones
#
#   Voice frequency examples:
#     F0 male speech:    120 Hz (B2)  → perceived  120 × 0.363 = 43.5 Hz (F1) — sub-bass drone
#     F0 female speech:  220 Hz (A3)  → perceived  220 × 0.363 = 79.9 Hz (E2) — very low bass
#     Consonant burst:  3000 Hz       → perceived 3000 × 0.363 = 1089 Hz (C6 ≈ high piano)
#     Sibilants:        6000 Hz       → perceived 6000 × 0.363 = 2178 Hz (C7)
#
#   Comparison with AudioGen case (see audiogen-developer-retainer):
#     AudioGen: 16000 Hz output saved with 44100 Hz header → 2.756× TOO FAST, +17.5 semitones
#     Resemble: 44100 Hz output saved with 16000 Hz header → 2.756× TOO SLOW, −17.5 semitones
#     Both: speed ratio 44100/16000 = 2.756; pitch |Δf| = 17.5 semitones; direction reversed
#
#   DNSMOS P.835 (automated speech quality prediction):
#     WAV header mismatch (2.756× slow, −17.5 semitones): DNSMOS OVR = 2.1
#     Correct save (out_sr=44100 header):                  DNSMOS OVR = 3.8
#     (Enhancement itself is correct — only the WAV header causes the perceived degradation)

Why three months of resemble-enhance parameter tuning could not fix a WAV header

The team correctly identified that something in the enhancement step was causing the audio to degrade. Because they could hear the problem (slow, deep drone) but could not identify its source from listening alone, they methodically iterated through every configurable parameter in enhance() for three months.

# Month 1: Varied nfe and tau parameters
#   Hypothesis: enhancement ODE solver configuration producing bad output
#   Tested nfe (number of function evaluations): 8, 16, 32 (default), 64
#     All produce same 44100 Hz out_wav; all saved with 16000 Hz header; all 2.756× slow
#     "More nfe made no difference to quality" (expected — root cause is not in solver)
#   Tested tau (temperature): 0.1, 0.3, 0.5 (default), 0.7, 0.9
#     All same result — tau controls enhancement strength, not output sample rate
#   Tested denoising=True vs denoising=False
#     Both return out_sr=44100; both saved at 16000 Hz header; both 2.756× slow
#   Conclusion: "Parameter tuning has zero effect; resemble-enhance may be broken"
#
# Month 2: Tried different input preprocessing and hardware
#   Hypothesis: Zoom export format incompatible with resemble-enhance
#   Tried AAC → WAV conversion at 16kHz (ffmpeg): same result
#   Tried 44100 Hz input (torchaudio.load returns 44100 Hz):
#     out_sr still 44100; now saved with 16000 Hz header; still 2.756× slow
#     "Even 44100 Hz input produces wrong output" (correct — the save is always wrong)
#   Tried CPU inference (device='cpu'): same result (expected — same math, different device)
#   Hypothesis: CUDA version causing numerical issues
#   Tried on different GPU (A100 vs RTX 3090): same result
#   Conclusion: "resemble-enhance produces fundamentally incorrect output for our use case"
#
# Month 3: Tried alternative enhancement models
#   Switched to DeepFilterNet (deepfilternet2 from PyPI)
#   DeepFilterNet enhances at 48000 Hz (or 16000 Hz in DeepFilterNet 2 depending on model)
#   Pipeline saved DeepFilterNet output with same hardcoded 16000 Hz: same type of error
#   For 48000 Hz DeepFilterNet output saved at 16000: 48000/16000 = 3× too slow
#   "Even the alternative is broken" (the pipeline's save step was always wrong)
#   Switched back to resemble-enhance; engaged retainer
#
# Retainer triage (1.5h):
#   Step 1 (0.3h): Add print statements to pipeline
#                  print(f"Input sr:  {sr}")         → 16000
#                  print(f"Output out_sr: {out_sr}")  → 44100
#                  print(f"Save sr:   {save_sr}")     → 16000
#                  "out_sr=44100 but saving at 16000" — mismatch found
#   Step 2 (0.3h): Verify WAV header on existing enhanced file
#                  torchaudio.info('enhanced.wav').sample_rate → 16000  ← wrong header
#                  out_wav.shape[0] / out_sr = 44100 Hz samples / 44100 = X seconds
#                  out_wav.shape[0] / 16000 = X × 2.756 seconds ← matches observed length
#   Step 3 (0.5h): Fix save call; re-process 5 test episodes; play back
#                  torchaudio.save(output_path, out_wav.unsqueeze(0), out_sr)
#                  Playback: correct speed; correct pitch
#                  DNSMOS OVR: 2.1 → 3.8
#   Step 4 (0.4h): Add assertion; audit all save paths in codebase
#                  assert save_sr == out_sr, (
#                      f"save_sr={save_sr} ≠ out_sr={out_sr}; "
#                      f"resemble-enhance always outputs at 44100 Hz"
#                  )
#                  2 engineers × 3 months × $13,333/month = $80,000

Month 3’s trial of DeepFilterNet contained a near-miss that revealed the true root cause, though it was not recognized at the time. DeepFilterNet 2’s output at 48000 Hz, saved with 16000 as the sample rate, produced audio that was 3× too slow (48000/16000 = 3.0×) — a different ratio than resemble-enhance’s 2.756×. The team concluded that DeepFilterNet was “even more broken” and switched back. If they had instead compared the ratios — 2.756 for resemble-enhance, 3.0 for DeepFilterNet — they would have recognized that both numbers equal the model’s output sample rate divided by 16000. That recognition would have pointed directly to the WAV header. The fix was replacing 16000 with out_sr in torchaudio.save(). Hours logged to HourTab with per-session breakdown.

# Fixed enhance_pipeline.py

import torch
import torchaudio
from resemble_enhance.enhancer.inference import enhance

device = 'cuda' if torch.cuda.is_available() else 'cpu'

def process_podcast_episode(input_path: str, output_path: str):
    dwav, sr = torchaudio.load(input_path)

    # enhance() always returns out_sr=44100 (super-resolution to 44.1kHz)
    out_wav, out_sr = enhance(dwav.squeeze(0), sr, device, run_args=None)

    # Assert output sample rate before saving — catches future model version changes
    assert out_sr == 44100, (
        f"resemble-enhance out_sr={out_sr}; expected 44100; update pipeline if model changed"
    )

    torchaudio.save(
        output_path,
        out_wav.unsqueeze(0),
        out_sr   # ← FIX: use out_sr (44100), not hardcoded 16000
    )

# After fix — podcast enhancement results (Northfield Resemble Voice Ltd.):
# Playback speed:     1.0×          — was 0.363× (2.756× too slow)
# Pitch shift:        0 semitones   — was −17.5 semitones
# DNSMOS OVR:         3.8           — was 2.1
# DNSMOS SIG:         3.9 (speech signal quality)
# DNSMOS BAK:         3.8 (background noise suppression)
# Output sample rate: 44100 Hz      — was 16000 Hz header on 44100 Hz content
# Root cause:         enhance() out_sr=44100; torchaudio.save(16000) hardcoded from
#                     prior Whisper ASR pipeline (Whisper uses 16kHz input)

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 →