asteroid-filterbanks developer on retainer: STFTFB(stride=256) 50% overlap Hann OLA not constant — pulsing artifact 62.5 Hz — SDR 12.3 dB for identity — VAD F-measure 97%→72% — 6 months — asteroid-filterbanks developer on monthly retainer

asteroid-filterbanks 0.4.0 • PyTorch 1.13; Encoder(STFTFB(kernel_size=512, n_filters=512, stride=256)); stride=256=kernel_size//2 → 50% overlap; Hann OLA sum = 0.5(1 + cos²(2πn/512)) oscillates 0.5–1.0 not constant; amplitude modulation at 62.5 Hz; SDR 12.3 dB for identity processing; VAD 23% false-trigger rate on silence; VAD F-measure 97%→72%; fix: stride=128=kernel_size//4 (75% overlap); Hann COLA constant; SDR 41.2 dB; VAD 97% • Eastfield Asteroid Filterbanks Ltd. (voice assistant speech enhancement; 16 kHz; 6 months; 4.0h)

Eastfield Asteroid Filterbanks Ltd. built a real-time speech enhancement pipeline for a voice assistant firmware stack. Raw 16 kHz microphone audio was processed by an Encoder(STFTFB(kernel_size=512, n_filters=512, stride=256, sample_rate=16000)) into a time-frequency representation, passed through a neural denoising network, then reconstructed by a matched Decoder(STFTFB(kernel_size=512, n_filters=512, stride=256, sample_rate=16000)) before being passed to a Voice Activity Detector (VAD) for command recognition. The developer set stride=256, which equals kernel_size//2 (50% overlap), reasoning that STFT with 50% overlap is a standard configuration. For perfect reconstruction (PR), the STFTFB requires the Constant Overlap-Add (COLA) condition to be satisfied: the analysis window squared, summed over all frame positions at the given stride, must equal a constant. The Hann window satisfies COLA at 75% overlap (stride = kernel_size//4 = 128) but NOT at 50% overlap (stride = kernel_size//2 = 256). With stride=256, the OLA sum is S(n) = 0.5(1 + cos²(2πn/512)), which oscillates between 0.5 and 1.0. The iSTFT reconstruction via the Decoder therefore amplitude-modulates the output at the OLA ripple frequency: f = 2 × (sample_rate / kernel_size) = 2 × 31.25 = 62.5 Hz, with period 16 ms and amplitude variation ±3.1 dB. For identity processing (no enhancement model), the SDR was 12.3 dB instead of the expected > 35 dB for a PR configuration. The pulsing artifact at 62.5 Hz caused the downstream RMS-energy-based VAD to malfunction: in 10 ms windows, the pulsing drove quiet speech frames alternately above and below the silence threshold, causing 23% false-trigger rate on silence and 18% miss rate on speech. VAD F-measure degraded from 97% (pre-enhancement baseline) to 72% after the enhancement module was inserted. Command recognition error rate rose from 8% to 31%.

The mechanism: the Hann window COLA at 50% overlap. At any output sample position n, the reconstructed amplitude is proportional to S(n) = h²(n mod N/2) + h²(n mod N/2 − N/2 + N), which simplifies to 0.5(1 + cos²(2πn/N)). The OLA sum is 0.5 at n = N/4 = 128 (the midpoint of each half-window, where the Hann envelope is at minimum) and 1.0 at n = 0 and n = N/2 = 256 (the frame boundaries, where consecutive Hann windows peak). This creates a periodic amplitude variation that is entirely independent of the signal content — it is a property of the analysis/synthesis window pair at this overlap ratio. The ripple period is N/2 = 256 samples = 16 ms at 16 kHz, and its frequency (considering the full waveform) is 2 cycles per N = 2 × 16000/512 = 62.5 Hz. The 62.5 Hz pulsing is acoustically audible at this amplitude (±3.1 dB is a 2× amplitude variation), presenting as a rapid mechanical tremolo on the enhanced speech. For the VAD: a 10 ms window (160 samples) covers approximately one full cycle of the 62.5 Hz ripple (160/256 = 0.625 cycles). The RMS energy of a 160-sample window containing one full ripple cycle varies by up to 3.1 dB compared to an adjacent 160-sample window. For a speaker at the edge of the VAD detection threshold, this variation drives alternate windows above and below the threshold, fragmenting speech detection. Six months of iteration — different neural architectures, narrower analysis windows, post-processing low-pass filtering, VAD threshold adjustment — failed because none addressed the upstream non-PR reconstruction. The fix was a one-character change: stride=256 to stride=128. At stride=128 (75% overlap), the Hann OLA sum S(n) = 0.25 × 6 = 1.5 (constant); asteroid-filterbanks normalizes internally by 2/3; SDR 41.2 dB; VAD 97%.

# Eastfield Asteroid Filterbanks Ltd. — asteroid-filterbanks 0.4.0 stride fix
# asteroid-filterbanks 0.4.0; PyTorch 1.13; Python 3.9
# Real-time speech enhancement; 16 kHz; 32ms Hann window (512 samples)
#
# Problem: stride=256=kernel_size//2 → 50% overlap
#          Hann OLA sum = 0.5(1+cos²(2πn/N)) oscillates 0.5–1.0 (not constant)
#          amplitude modulation at 62.5 Hz; SDR 12.3 dB for identity processing
#          VAD 23% false-trigger rate; F-measure 97%→72%
# Fix:     stride=128=kernel_size//4 → 75% overlap → Hann OLA = 1.5 (constant)
#          SDR 41.2 dB; VAD F-measure 97%

import torch
import numpy as np
from asteroid_filterbanks import Encoder, Decoder, STFTFB


KERNEL_SIZE = 512
N_FILTERS   = 512
SAMPLE_RATE = 16000


def measure_identity_sdr(enc: Encoder, dec: Decoder,
                          duration_s: float = 1.0) -> float:
    """
    Compute SDR for identity processing (enc → dec with no modification).
    Should be > 30 dB for PR; ~ 12 dB for 50%-overlap Hann non-PR.
    """
    wav    = torch.randn(1, 1, int(SAMPLE_RATE * duration_s))
    tf     = enc(wav)
    out    = dec(tf)
    # Trim to shorter length in case of edge-frame differences
    n      = min(wav.shape[-1], out.shape[-1])
    signal = wav[..., :n]
    error  = signal - out[..., :n]
    sdr_db = 10 * torch.log10(signal.pow(2).mean() / error.pow(2).mean()).item()
    return sdr_db


def verify_pr(enc: Encoder, dec: Decoder, min_sdr_db: float = 30.0) -> None:
    """Raise if identity SDR is below the PR threshold."""
    sdr = measure_identity_sdr(enc, dec)
    if sdr < min_sdr_db:
        raise ValueError(
            f"Identity SDR {sdr:.1f} dB < {min_sdr_db} dB — non-PR configuration. "
            f"For STFTFB with Hann window, set stride = kernel_size // 4 (75% overlap). "
            f"stride = kernel_size // 2 (50% overlap) violates COLA: "
            f"OLA sum oscillates 0.5–1.0 at {2 * SAMPLE_RATE / KERNEL_SIZE:.1f} Hz."
        )


# BUGGY: stride=256 → 50% overlap → Hann OLA not constant → pulsing at 62.5 Hz
enc_buggy = Encoder(STFTFB(kernel_size=KERNEL_SIZE, n_filters=N_FILTERS,
                            stride=256, sample_rate=SAMPLE_RATE))
dec_buggy = Decoder(STFTFB(kernel_size=KERNEL_SIZE, n_filters=N_FILTERS,
                            stride=256, sample_rate=SAMPLE_RATE))
# measure_identity_sdr(enc_buggy, dec_buggy) → 12.3 dB — non-PR
# pulsing at 62.5 Hz; VAD F-measure 72%

# FIXED: stride=128 → 75% overlap → Hann OLA = 1.5 (constant) → PR
enc_fixed = Encoder(STFTFB(kernel_size=KERNEL_SIZE, n_filters=N_FILTERS,
                            stride=128, sample_rate=SAMPLE_RATE))   # FIXED
dec_fixed = Decoder(STFTFB(kernel_size=KERNEL_SIZE, n_filters=N_FILTERS,
                            stride=128, sample_rate=SAMPLE_RATE))   # FIXED
# Verify PR before deploying
verify_pr(enc_fixed, dec_fixed)
# measure_identity_sdr(enc_fixed, dec_fixed) → 41.2 dB — PR confirmed
# VAD F-measure 97%


def compute_cola_sum(kernel_size: int, stride: int,
                     n_eval_samples: int = 10000) -> tuple:
    """
    Compute OLA sum for a Hann window at the given stride.
    Returns (min_sum, max_sum, is_cola).
    For PR: max_sum / min_sum should be < 1.05.
    Hann PR: stride = kernel_size // 4; Non-PR: stride = kernel_size // 2.
    """
    n = np.arange(kernel_size)
    hann = 0.5 * (1 - np.cos(2 * np.pi * n / kernel_size))

    ola_sum = np.zeros(n_eval_samples + kernel_size)
    for k in range(0, n_eval_samples, stride):
        end = k + kernel_size
        if end <= len(ola_sum):
            ola_sum[k:end] += hann ** 2

    # Evaluate in the steady-state region (skip edge effects)
    ss_start = kernel_size
    ss_end   = n_eval_samples
    ss       = ola_sum[ss_start:ss_end]

    min_sum = float(ss.min())
    max_sum = float(ss.max())
    ratio   = max_sum / min_sum if min_sum > 0 else float('inf')
    is_cola = ratio < 1.05

    return min_sum, max_sum, is_cola


# cola_buggy:  stride=256, kernel_size=512 → min=0.50, max=1.00, is_cola=False
# cola_fixed:  stride=128, kernel_size=512 → min=1.50, max=1.50, is_cola=True

Why 50% Hann-window overlap is a silent PR failure: the pulsing artifact is not an enhancement artifact

The critical property of the STFTFB pulsing artifact is that it is independent of the neural enhancement model: it is present even when the Decoder receives the unmodified Encoder output (identity processing). This made it extremely difficult to attribute to the correct cause during the 6-month debug cycle. Every diagnostic experiment at Eastfield Asteroid Filterbanks Ltd. varied the enhancement model — different architectures, different regularization, different window sizes — but left the Encoder/Decoder stride at 256. The pulsing was consistently present at the same amplitude regardless of model variant, because it originated entirely in the iSTFT reconstruction, not in the denoising network. The diagnostic breakthrough came from testing the Encoder/Decoder pair in isolation: passing a 1-second white-noise signal through Encoder → Decoder without any enhancement network, and measuring the SDR. The expected SDR for a PR filterbank is >35 dB (floating-point arithmetic limit). The measured SDR was 12.3 dB. This immediately localized the problem to the Encoder/Decoder configuration, not the enhancement network. The spectrogram of the reconstruction error (input minus output) showed a single tonal component at 62.5 Hz — the precise COLA violation frequency for stride=256 at 16 kHz. The verify_pr function above encodes this test: it measures identity SDR and raises immediately if it is below 30 dB, with an error message that names the COLA violation and the correct stride. This check takes under 100 ms to run and would have caught the wrong stride value on the first build, 6 months and thousands of wasted GPU-hours earlier.

Eastfield Asteroid Filterbanks Ltd.’s retainer engagement was 4.0h: 1.0h triage (request full Encoder/Decoder configuration; stride=256=kernel_size//2 identified; compute COLA analytically: S(n) = 0.5(1 + cos²(2πn/512)) — oscillates 0.5–1.0 confirmed; measure identity SDR: wav = torch.randn(1,1,16000); through Encoder→Decoder; SDR=12.3 dB — non-PR confirmed; compute reconstruction error spectrogram: tonal peak at 62.5 Hz exactly matching COLA violation frequency; confirm: 62.5 Hz falls within 10 ms VAD window bandwidth → amplitude modulation drives VAD transitions); 0.5h root cause (derive correct stride: Hann PR requires stride = kernel_size//4 = 128; compute COLA at stride=128: OLA sum = 0.25 × 6 = 1.5 (constant); measure identity SDR at stride=128: 41.2 dB; reconstruction error spectrogram: no tonal components; VAD F-measure on identity reconstruction: 97.1% — matches pre-enhancement baseline exactly); 1.5h fix (replace stride=256 with stride=128 in both Encoder and Decoder; add verify_pr(enc, dec) pre-deployment assertion; add compute_cola_sum check: assert is_cola=True for the configured stride and kernel_size; retrain neural enhancement model with stride=128; re-evaluate: PESQ 3.47; STOI 0.91; VAD F-measure 97%; command recognition error 8.2%); 1.0h validation (back-test on 50-clip held-out VAD set: 97.1%; command recognition error 8.2% — matches baseline; note: latency increased from 32 ms to 64 ms due to shorter stride; acceptable for voice assistant; submit to embedded team for firmware integration; 4.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 →