noisereduce developer on retainer: 2-second speech ducking at every music-speech transition — time_constant_s=2.0 noise floor estimate lags 2 s behind transitions — first 2 s of each speech segment 8–12 dB over-attenuated — time_constant_s=0.1 fix — 3 weeks — noisereduce developer on monthly retainer

noisereduce (timsainburg/noisereduce) 2.0.1 • Python 3.9; STFT-based spectral gating noise reduction library; reduce_noise(y, sr, stationary=False) estimates time-varying noise floor using a first-order IIR filter with time_constant_s=2.0 (default); noise floor estimate follows signal energy with 2 s exponential lag • podcast post-production cleanup service (3,000 episodes/month: interview podcasts, narrative shows with music beds; each episode has ∼20 music-speech transitions — intro/outro music, underscoring music beds, music stingers); audible “ducking” artifact on first 2 s of every speech segment that follows a music section — at music→speech transition, IIR noise floor estimate remains at music-band amplitude for ∼2 s while actual signal switches to quieter speech; noise floor overestimates speech energy by 8–12 dB; spectral mask over-attenuates speech in those bands; first 2 s of speech sounds thin, distant, or muffled; 20 × 2 s = 40 s ducked speech per episode; listener MOS on transition segments: 2.9; 15 listener complaints/month about “swallowed words at music transitions” • developer investigates noisereduce non-stationary noise floor tracking, IIR filter time-constant behavior at content transitions, and spectral gating mask over-attenuation for 3 weeks • root cause: time_constant_s=2.0 first-order IIR low-pass filter has exponential decay constant 2 s; at music→speech transition the noise floor estimate decays toward speech-level energy with half-life ∼1.4 s; for 2 s after transition, noise floor estimate exceeds actual speech energy in broadband; spectral gating subtracts excess noise estimate from speech, zeroing or heavily attenuating speech-band STFT bins; fix: time_constant_s=0.1; noise floor estimate converges to speech level within 100 ms (<200 ms perceptual ducking threshold; imperceptible); ducked speech: 40 s → ∼2 s per episode; MOS: 2.9 → 4.2; listener complaints: 0; 1.5h retainer engagement

Westfield Noisereduce Ltd. had built an automated podcast post-production cleanup service that processed 3,000 episodes per month, applying noisereduce to remove HVAC hum, room tone, and ambient background noise from recorded content before distribution. The pipeline used noisereduce.reduce_noise(y=audio, sr=sr, stationary=False, prop_decrease=0.9) with all other parameters at their defaults, including time_constant_s=2.0. For pure-speech episodes — interview podcasts and commentary recorded in quiet home studios — the noise reduction performed well: HVAC hum and fan noise were cleanly removed, and listener MOS improved from 3.6 to 4.3 on those episode types. When the service added narrative podcast clients who used music beds under their speech (10–30 second intro and outro music segments, 2–5 second music stingers between sections), listeners began reporting that the host’s voice was “swallowed” or “muffled” for a few seconds after each music transition. Listener complaints reached 15 per month. A noisereduce retainer developer was engaged to diagnose why the noise reduction pipeline that worked well for pure-speech content was producing ducking artifacts specifically at music-speech transitions.

The developer’s investigation generated STFT spectrograms of the noisereduce output at three representative music-speech transitions from a 60-minute narrative episode, overlaid with the internal noise floor estimate tracked by the IIR filter. The pattern was clear: at each point where music stopped and speech began, the noise floor estimate (a smoothed version of the STFT magnitude envelope) remained at the music-band amplitude level for approximately 1.5–2.5 seconds while the actual signal had transitioned to speech at 8–12 dB lower amplitude. During this window, noisereduce’s spectral mask was subtracting a noise floor that exceeded the actual speech energy in multiple frequency bands, producing 8–12 dB over-attenuation of those bands — the audible ducking effect. The developer verified the mechanism: noisereduce 2.0.1’s non-stationary mode implements noise floor tracking using a first-order IIR filter, where the smoothing coefficient is derived from time_constant_s and the STFT hop length. With time_constant_s=2.0, the filter has an exponential time constant of 2.0 seconds and a half-life of approximately 1.4 seconds; for a typical music bed at −18 dBFS transitioning to speech at −28 dBFS, the noise floor estimate takes approximately 2 seconds to decay 10 dB to the speech-energy level. Setting time_constant_s=0.1 reduced the IIR time constant to 100 milliseconds; the noise floor estimate converged to speech-level energy within approximately 100 milliseconds after the music-to-speech transition, well below the 200 ms perceptual threshold for voice ducking. Listener MOS on the 20-episode transition test set improved from 2.9 to 4.2, and listener complaints dropped to zero in the first post-fix month.

The diagnostic code that confirmed the IIR lag at music-speech transitions and the corrected pipeline:

# Westfield Noisereduce Ltd. — noisereduce 2.0.1 time_constant_s ducking diagnostic
# noisereduce (timsainburg/noisereduce) 2.0.1; Python 3.9
# Deployment: podcast post-production cleanup, 3,000 episodes/month
# Problem: time_constant_s=2.0 → 2s speech ducking at every music-speech transition
# Fix: time_constant_s=0.1 → noise floor converges in 100ms (imperceptible)

import numpy as np
import librosa
import noisereduce as nr
import soundfile as sf

def denoise_buggy(path_in: str, path_out: str) -> None:
    """
    Original implementation — default time_constant_s=2.0.
    Causes 2-second speech ducking at every music-to-speech transition.
    """
    y, sr = librosa.load(path_in, sr=None, mono=False)
    y_reduced = nr.reduce_noise(
        y=y,
        sr=sr,
        stationary=False,
        prop_decrease=0.9,
        # time_constant_s=2.0 (default) — IIR noise floor lag = 2s
    )
    out = y_reduced.T if y_reduced.ndim == 2 else y_reduced
    sf.write(path_out, out, sr)

def denoise_fixed(path_in: str, path_out: str) -> None:
    """
    Fixed implementation — time_constant_s=0.1.
    Noise floor estimate converges to speech level within 100ms of transition.
    """
    y, sr = librosa.load(path_in, sr=None, mono=False)
    y_reduced = nr.reduce_noise(
        y=y,
        sr=sr,
        stationary=False,
        prop_decrease=0.9,
        time_constant_s=0.1,  # 100ms IIR time constant — transitions in <200ms
    )
    out = y_reduced.T if y_reduced.ndim == 2 else y_reduced
    sf.write(path_out, out, sr)

def measure_transition_ducking(path: str, transition_times_s: list,
                                window_s: float = 2.5) -> list:
    """
    Measure per-band energy in the first window_s seconds after each transition.
    Returns list of dicts with pre-transition vs post-transition energy for
    both buggy (time_constant_s=2.0) and fixed (time_constant_s=0.1) versions.
    """
    y, sr = librosa.load(path, sr=None, mono=True)
    n_fft = 1024
    hop   = 256

    # Noise-reduced with buggy and fixed settings
    y_buggy = nr.reduce_noise(y=y, sr=sr, stationary=False,
                               prop_decrease=0.9)  # default time_constant_s=2.0
    y_fixed = nr.reduce_noise(y=y, sr=sr, stationary=False,
                               prop_decrease=0.9, time_constant_s=0.1)

    # STFT magnitude for original and both denoised versions
    S_orig  = np.abs(librosa.stft(y,       n_fft=n_fft, hop_length=hop))
    S_buggy = np.abs(librosa.stft(y_buggy, n_fft=n_fft, hop_length=hop))
    S_fixed = np.abs(librosa.stft(y_fixed, n_fft=n_fft, hop_length=hop))

    results = []
    for t_trans in transition_times_s:
        frame_trans  = int(t_trans * sr / hop)
        frame_window = int(window_s * sr / hop)

        # Mean energy in speech window after transition
        window_buggy = S_buggy[:, frame_trans : frame_trans + frame_window]
        window_fixed  = S_fixed[:,  frame_trans : frame_trans + frame_window]
        window_orig   = S_orig[:,   frame_trans : frame_trans + frame_window]

        energy_buggy_db = 20.0 * np.log10(np.mean(window_buggy) + 1e-9)
        energy_fixed_db  = 20.0 * np.log10(np.mean(window_fixed)  + 1e-9)
        energy_orig_db   = 20.0 * np.log10(np.mean(window_orig)   + 1e-9)

        ducking_buggy_db = energy_buggy_db - energy_orig_db  # negative = attenuated
        ducking_fixed_db  = energy_fixed_db  - energy_orig_db

        results.append({
            "transition_at_s": t_trans,
            "orig_energy_db":  round(energy_orig_db,  1),
            "buggy_energy_db": round(energy_buggy_db, 1),
            "fixed_energy_db":  round(energy_fixed_db,  1),
            "ducking_buggy_db": round(ducking_buggy_db, 1),  # e.g. -9.3 dB
            "ducking_fixed_db":  round(ducking_fixed_db,  1),  # e.g. -0.4 dB
        })
    return results

# --- Run transition ducking audit ---

import pathlib

episode = "/episodes/ep_042_narrative_with_music.wav"
# Known music-to-speech transition times in this episode (seconds)
transitions_s = [15.2, 42.8, 118.4, 165.0, 203.7,
                  248.1, 311.6, 356.9, 401.2, 445.0]

print("noisereduce 2.0.1 — music-speech transition ducking audit")
print(f"Episode: {pathlib.Path(episode).name}")
print(f"Transitions: {len(transitions_s)} music-to-speech boundaries")
print("=" * 70)

results = measure_transition_ducking(episode, transitions_s, window_s=2.5)
for r in results:
    print(f"  t={r['transition_at_s']:.1f}s  "
          f"orig={r['orig_energy_db']:+.1f}dB  "
          f"buggy={r['buggy_energy_db']:+.1f}dB ({r['ducking_buggy_db']:+.1f}dB)  "
          f"fixed={r['fixed_energy_db']:+.1f}dB ({r['ducking_fixed_db']:+.1f}dB)")

mean_ducking_buggy = np.mean([r["ducking_buggy_db"] for r in results])
mean_ducking_fixed  = np.mean([r["ducking_fixed_db"]  for r in results])
print()
print(f"Mean ducking (buggy time_constant_s=2.0): {mean_ducking_buggy:.1f} dB")
print(f"Mean ducking (fixed time_constant_s=0.1):  {mean_ducking_fixed:.1f} dB")
print()
print("Root cause: time_constant_s=2.0 → IIR noise floor lags 2s at transitions")
print("  Music bed → speech: noise floor stays at music-level for ~2s")
print("  Spectral gating over-attenuates speech by 8-12 dB for first 2s")
print("  20 transitions × 2s ducking = 40s muffled speech per episode")
print()
print("Fix: time_constant_s=0.1 → noise floor converges in 100ms")
print("  Ducking artifact: 2s → 100ms per transition (imperceptible)")
print("  MOS on transition segments: 2.9 → 4.2")
print("  Listener complaints: 15/month → 0")
print("  Retainer engagement: 1.5h")

How the noisereduce IIR noise floor filter creates ducking at music-speech transitions and when to use short vs long time constants

noisereduce 2.0.1’s non-stationary mode tracks the time-varying noise floor by applying a first-order IIR (exponential moving average) low-pass filter to the per-frequency-bin STFT magnitude envelope. At each STFT frame, the noise floor estimate for bin k is updated as: noise_floor[k] = alpha * noise_floor[k] + (1 - alpha) * |STFT[k]|, where alpha is a smoothing coefficient derived from time_constant_s and the STFT hop length. A larger time_constant_s gives a larger alpha (closer to 1.0), making the noise floor estimate change more slowly — more robust to momentary loud sounds but slower to react to sustained level changes. A smaller time_constant_s gives a smaller alpha, making the estimate track rapid changes but more susceptible to momentary transients raising the noise floor estimate and briefly over-attenuating quieter content that follows.

The practical tradeoff for podcast post-production: time_constant_s=2.0 works well for pure-speech recordings where the noise floor is stationary HVAC or fan noise that changes slowly (or not at all); the 2-second lag prevents any momentary cough, breath, or word-onset from temporarily spiking the noise floor estimate. For content with music beds, however, music is the primary high-energy event — not noise — and the 2-second lag causes the noise floor to “remember” the music energy for 2 seconds after it stops, over-attenuating the lower-energy speech that follows. The fix of time_constant_s=0.1 is appropriate for this content type because music-to-speech transitions are abrupt (the music stops and speech starts within a single audio frame) rather than gradual; the 100ms convergence window is fast enough to follow the transition while still smoothing over individual STFT frames (a 1024-point FFT at 44100 Hz with hop_length=256 has a frame duration of ∼5.8ms; at 100ms time constant, the IIR averages approximately 17 frames, suppressing frame-to-frame variation while reacting to 100ms-scale transitions). For deployments that process both pure-speech and music-with-speech content in the same pipeline, time_constant_s=0.1 is the safer default: it introduces no perceptible artifact at music transitions, and the minor increase in noise floor reactivity for pure-speech content is imperceptible at typical HVAC noise levels.

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 →