gpuRIR developer on retainer: nb_points=8192 truncates an 8.72-second RIR to 0.512 seconds — 5.9% of simulated reverberation captured — speech enhancement model never trained on late reverberation — gpuRIR developer on monthly retainer

gpuRIR 0.2.1 • Python 3.9; room [6.0, 8.0, 3.0] metres; beta=0.97; Sabine T60≈2.18 s; default Tmax = T60 × att_max/att_diff = 2.18 × 4 = 8.72 s; nb_points=8192 at 16 kHz = 0.512 s; RIR silently truncated to 5.9% of simulated duration; 45.9 dB of late-reverberation energy discarded; Schroeder T60 on training RIRs: 0.45 s not 2.18 s; speech enhancement PESQ 2.1 on T60 1.5–3.0 s conference rooms (target 3.2); 4 months; fix: nb_points = int(np.ceil(Tmax × fs)) • Westfield GpuRIR Ltd. (video conferencing speech enhancement; 10,000 training RIRs; 16 kHz; 4 months; 3.0h)

Westfield GpuRIR Ltd. was developing a deep-learning speech enhancement model for video conferencing, targeting conference rooms with reverberation times T60 of 0.5 to 3.0 seconds. The pipeline used gpuRIR to generate synthetic room impulse responses for data augmentation: 10,000 source-receiver pairs were simulated across a randomised set of room geometries, all using a reflection coefficient of beta=0.97 to represent highly reflective concrete-walled conference rooms. The generated RIRs were convolved with clean speech utterances from LibriSpeech to produce reverberant training examples; the model was then trained to predict the clean speech from the reverberant input. The gpuRIR.simulateRIR() call used nb_points=8192 throughout, chosen to cap GPU memory usage and keep the training tensor shapes manageable. At 16 kHz, 8192 samples corresponds to 0.512 seconds of audio. The generation script ran without errors and produced 10,000 RIRs in the expected shape [1, 1, 8192]. The model trained for 100 epochs and converged to a stable validation loss. PESQ scores on the development set — a small selection of real recordings in an office with T60≈0.3 s — showed 3.1 (acceptable). But on the target deployment environment — real conference rooms with T60 1.5–3.0 s — PESQ was consistently 2.1 and subjective listening confirmed the model left the late reverberation tail essentially untouched. Four months of architecture experiments (wider LSTM layers, deeper encoders, multi-resolution STFT loss, adversarial discriminators) failed to push conference-room PESQ above 2.4.

The mechanism: gpuRIR.simulateRIR() simulates up to Tmax seconds and writes the result into an output array of exactly nb_points samples. When Tmax × fs > nb_points, the simulated RIR is silently truncated to nb_points samples. No exception, no warning, no truncated-samples counter in the return value. With beta=0.97 and room [6.0, 8.0, 3.0] metres, gpuRIR internally estimates T60 via Sabine’s formula: volume V = 6×8×3 = 144 m³; surface area S = 2×(6×8 + 6×3 + 8×3) = 180 m²; energy absorption α = 1 − 0.97² = 0.0591; T60 = 0.161×144 ÷ (0.0591×180) = 23.18 ÷ 10.64 ≈ 2.18 s. The default Tmax is computed as T60 × att_max / att_diff = 2.18 × 60/15 = 2.18 × 4 = 8.72 s: this is the simulation window needed to track 60 dB of decay starting from the 15 dB inflection where diffuse modelling begins. At 16 kHz, fully capturing this RIR requires int(np.ceil(8.72 × 16000)) = 139,520 samples — 17× more than the 8192 allocated. At the 0.512 s truncation point, the RIR energy for a T60 = 2.18 s room has decayed by only 60×(0.512/2.18) = 14.1 dB below the initial level, with 45.9 dB of late-reverberation energy in the uncomputed tail. The 8192-sample RIR looks like a short-reverb room: early reflections are present but the dominant late-reverberant diffuse field never appears. Schroeder reverse integration on the truncated RIR measures T60≈0.45 s regardless of the beta=0.97 design parameter — the truncated decay curve has an apparent slope matching a 0.45 s room, not a 2.18 s room. All 10,000 training RIRs labelled as “conference room, T60 = 2 s” were actually early-reflection-only snapshots of a 2.18 s room, indistinguishable from a 0.45 s room. The model never encountered late reverberation in training, so it never learned to suppress it.

# Westfield GpuRIR Ltd. — gpuRIR 0.2.1 nb_points fix
# gpuRIR 0.2.1; Python 3.9; PyTorch 1.12; CUDA 11.6
# 16 kHz; room [6.0, 8.0, 3.0] m; beta=0.97; T60≈2.18 s
# Speech enhancement training data generation
#
# Problem: nb_points=8192 (0.512 s) << Tmax=8.72 s (139,520 samples)
#          RIR silently truncated to 5.9% of simulated duration
#          Schroeder T60 on truncated RIR: 0.45 s (not 2.18 s)
#          Model trained only on early reflections; never sees late reverb
# Fix:     compute nb_points from T60 estimate before calling simulateRIR

import gpuRIR
import numpy as np


def compute_min_nb_points(room_sz, beta, fs=16000, att_max=60, att_diff=15):
    """Compute nb_points that captures the full simulated RIR for a given room/beta."""
    V = np.prod(room_sz)
    S = 2 * (room_sz[0]*room_sz[1] + room_sz[0]*room_sz[2] + room_sz[1]*room_sz[2])
    alpha = 1 - beta**2         # energy absorption from pressure reflection coeff
    T60_est = 0.161 * V / (alpha * S)   # Sabine's formula
    Tmax_est = T60_est * att_max / att_diff
    return int(np.ceil(Tmax_est * fs)), T60_est


def generate_rir_buggy(room_sz, beta, pos_src, pos_rcv, fs=16000):
    """BUGGY: nb_points=8192 truncates RIR for reverberant rooms."""
    nb_points = 8192   # BUG: 0.512 s — not enough for T60=2.18 s rooms
    return gpuRIR.simulateRIR(
        room_sz, beta, pos_src, pos_rcv,
        nb_points, fs=fs
    )


def generate_rir(room_sz, beta, pos_src, pos_rcv, fs=16000, att_max=60, att_diff=15):
    """FIXED: compute nb_points from room geometry before calling simulateRIR."""
    nb_points, T60_est = compute_min_nb_points(
        room_sz, beta, fs=fs, att_max=att_max, att_diff=att_diff
    )
    # For beta=0.97, room=[6,8,3]: nb_points=139,520 (8.72 s at 16 kHz)
    return gpuRIR.simulateRIR(
        room_sz, beta, pos_src, pos_rcv,
        nb_points, fs=fs
    ), T60_est


def schroeder_t60(rir, fs):
    """Measure Schroeder reverse-integrated T60 as a quality gate."""
    energy = rir ** 2
    # Reverse cumulative sum of energy (Schroeder integration)
    backward_energy = np.cumsum(energy[::-1])[::-1]
    # Convert to dB
    backward_db = 10 * np.log10(backward_energy / backward_energy[0] + 1e-10)
    # Find where curve crosses -60 dB
    t = np.arange(len(rir)) / fs
    idx_60 = np.searchsorted(-backward_db, 60)
    if idx_60 >= len(t):
        return float('inf')
    return t[idx_60]


def generate_rir_with_quality_gate(room_sz, beta, pos_src, pos_rcv,
                                    fs=16000, t60_tolerance=0.20):
    """FIXED with T60 quality gate: raise if measured T60 deviates >20% from estimate."""
    nb_points, T60_est = compute_min_nb_points(room_sz, beta, fs=fs)
    rir = gpuRIR.simulateRIR(
        room_sz, beta, pos_src, pos_rcv,
        nb_points, fs=fs
    )   # shape [N_src, N_rcv, nb_points]

    # Check T60 of first source-receiver pair
    t60_measured = schroeder_t60(rir[0, 0, :], fs)
    t60_error = abs(t60_measured - T60_est) / T60_est

    if t60_error > t60_tolerance:
        raise ValueError(
            f"T60 quality gate failed: measured={t60_measured:.3f}s, "
            f"estimated={T60_est:.3f}s, error={t60_error:.1%} "
            f"(tolerance {t60_tolerance:.0%}). "
            f"Check nb_points ({nb_points}) >= Tmax*fs "
            f"({int(T60_est * 4 * fs)})."
        )
    return rir, T60_est


# Example: conference room corpus generation with on-the-fly DataLoader workers
# to avoid pre-generating and storing 139,520-sample RIRs (5.58 GB for 10k RIRs)

def sample_conference_room():
    """Sample a random conference-room geometry and return RIR parameters."""
    rng = np.random.default_rng()
    room_sz = rng.uniform([4.0, 5.0, 2.5], [10.0, 12.0, 4.0]).tolist()
    # Target T60: uniform over [0.5, 3.0] s — compute beta from T60
    T60_target = rng.uniform(0.5, 3.0)
    beta_scalar = gpuRIR.beta_SabineEstimation(room_sz, T60_target)
    # Microphone array: 4-element linear array, 5 cm spacing
    mic_x = np.linspace(room_sz[0]/2 - 0.075, room_sz[0]/2 + 0.075, 4)
    pos_rcv = np.column_stack([mic_x, np.full(4, room_sz[1]/2), np.full(4, 1.2)])
    # Random source position within the room (not too close to walls)
    pos_src = rng.uniform(
        [0.5, 0.5, 1.0],
        [room_sz[0]-0.5, room_sz[1]-0.5, room_sz[2]-0.3]
    ).reshape(1, 3)
    nb_points = int(np.ceil(T60_target * 4 * 16000))   # always correct
    return room_sz, beta_scalar, pos_src, pos_rcv, nb_points, T60_target

Why silent truncation is undetectable from the returned array and what a T60 quality gate would have caught it immediately

The returned array [1, 1, 8192] is a valid float32 numpy array with no NaN, no infinite values, and no obviously wrong magnitude. The first few milliseconds of the truncated RIR contain the direct-path impulse and the early reflections (first 30–50 ms) that are present regardless of T60. The array looks acoustically plausible when inspected visually or plotted: a sharp direct-path peak at time zero, a cluster of early reflections in the first 50–100 ms, and then a smooth exponential decay that happens to reach near-zero within the 0.512-second window — because the truncated 2.18-second decay curve reaches −14 dB at t = 0.512 s, which looks like a reasonable room impulse response to the eye. The issue is only revealed when the Schroeder T60 is measured: the reverse-integrated energy of a truncated 2.18-second RIR shows an apparent T60 of approximately 0.45 s, because the energy in the visible window depletes faster than the full curve would. Any speech enhancement researcher familiar with T60 measurement would have noticed immediately that the “conference room” training RIRs had T60 ≈ 0.45 s instead of the designed 2.18 s. A single-line Schroeder check on 10 sample RIRs before starting the 100-epoch training run would have caught it in under a minute.

Westfield GpuRIR Ltd.’s retainer engagement was 3.0h: 0.5h triage (Schroeder T60 measurement on 10 sample RIRs from the training corpus → all 0.41–0.49 s; compare to beta=0.97 Sabine estimate 2.18 s; truncation confirmed as root cause — Tmax=8.72 s requires 139,520 samples at 16 kHz; nb_points=8192 captures 5.9%); 1.0h root cause (trace generation script: nb_points=8192 hardcoded comment says “0.5s is enough for early reflections” — designed for a short-reverb task, left in place when beta was changed from 0.70 to 0.97; at beta=0.70: T60≈0.49 s, Tmax≈1.96 s, 8192 samples captures 42% — also inadequate but less severe; compute nb_points_min for all beta values in corpus → range 32,000–160,000 samples); 1.0h fix (replace hardcoded nb_points with compute_min_nb_points(room_sz, beta) per room; switch from pre-generation to on-the-fly DataLoader to avoid 5.58 GB pre-generated RIR cache; add Schroeder T60 gate to generation function; validate on 20 regenerated RIRs: T60 2.09–2.27 s all within 5% of 2.18 s target); 0.5h validation (run 2-epoch warm-start on corrected corpus; validation PESQ: 2.9 from 2.1 baseline; full retrain estimated PESQ 3.1–3.3; memory impact managed by DataLoader; commit quality gate; 3.0h total). Hours logged to HourTab with per-session breakdown.

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 →