soxr developer on retainer: quality='QQ' linear interpolation omits anti-aliasing filter — speech energy above Nyquist aliases into mel spectrogram; Whisper WER doubles to 8.2% — quality='VHQ' fix — 3 weeks — soxr developer on monthly retainer
soxr 0.3.7 (python-soxr, libsoxr Python bindings) • Python 3.9; soxr.resample(audio_mono, 48000, 16000, quality='QQ') in a batch podcast transcription pipeline • Northfield Soxr Ltd. (podcast transcription service, 50,000 episodes/month; intake 48kHz stereo WAV; convert to 16kHz mono float32 before Whisper-large-v3 inference; developer selected quality='QQ' for throughput — 3× faster than VHQ on a 48-core server; QQ = Quick Quality = linear interpolation, no anti-aliasing FIR filter; for 48kHz→16kHz factor-3 downsampling: Nyquist at 8kHz; speech fricative energy 8–24kHz folds back into 0–8kHz passband: 9kHz→7kHz, 10kHz→6kHz, 12kHz→4kHz; aliased energy adds phantom mel bin activations in bins 60–80 (5–8kHz); Whisper mel spectrogram: 80 bins 0–8kHz; sibilant phoneme representation corrupted; word error rate on 500-utterance sibilant-heavy test set: 8.2%; same test set with quality='VHQ': 4.1%; fix: quality='VHQ' — Kaiser window FIR anti-aliasing filter; WER 8.2%→4.1%; sibilant word accuracy recovered; 2.0h retainer engagement
Northfield Soxr Ltd. built the backend for a podcast transcription service that processed 50,000 episodes per month on behalf of podcast networks and indie creators. The pipeline ran 48kHz stereo WAV files from the ingestion queue, converted them to 16kHz mono float32 NumPy arrays using soxr, and fed the resampled audio to a Whisper-large-v3 model for automatic speech recognition. The service launched with quality='HQ' (the soxr default), producing word error rates consistent with Whisper benchmarks on clean speech (around 4% on well-recorded podcast audio). Three months post-launch, an engineering lead benchmarked the resampling stage and observed that switching from quality='HQ' to quality='QQ' cut the soxr processing time from 2.1 seconds to 0.7 seconds per episode on the production server — a 3× speedup that would halve the total transcription latency per episode. The change was deployed. Within two weeks, the team began receiving customer complaints about transcript quality on spoken words like “this,” “speech,” “fish,” and “thanks” — sibilant-rich words that appeared correct before the deployment. A soxr retainer developer was engaged to diagnose the regression.
The developer ran a controlled WER benchmark on a 500-utterance test set containing a representative mix of podcast dialogue. The quality='QQ' pipeline produced a WER of 8.2%; reverting to quality='HQ' produced 4.3%; and quality='VHQ' produced 4.1%. The developer then compared the mel spectrograms produced by the QQ and VHQ resampling paths for a sentence containing multiple sibilants: “She sells seashells by the seashore.” The QQ spectrogram showed elevated energy in mel bins 60–80 (approximately 5–8kHz) that was absent in the VHQ spectrogram. The root cause was well-documented in the soxr source: quality='QQ' implements linear interpolation between adjacent samples with no anti-aliasing filter stage. When downsampling by factor 3 (48kHz→16kHz), every frequency component above the output Nyquist (8kHz) aliases into the passband: a 9kHz component folds to 7kHz (16000 − 9000), a 10kHz component folds to 6kHz, a 12kHz component folds to 4kHz, and so on. Human speech fricatives — /s/, /ʃ/, /f/, /v/, /θ/ — have significant spectral energy from 4kHz to 10kHz; the components above 8kHz, when aliased, land squarely in the mid-frequency range where vowels and voiced consonants are encoded. Whisper’s mel spectrogram uses 80 triangular bins covering 0–8kHz on a mel scale; bins 60–80 cover roughly 5–8kHz and are normally dominated by sibilant fricative energy. The aliased components added ghost energy to these same bins for utterances without sibilants, and subtracted true sibilant energy from its correct location by interfering constructively or destructively depending on phase. The fix was a one-line change: quality='QQ' → quality='VHQ'. The throughput cost — from 0.7s to 2.1s per episode — was absorbed by adding two additional CPU cores to the soxr worker pool, leaving the total pipeline latency within the agreed SLA.
The annotated quality comparison and anti-aliasing validation:
# Northfield Soxr Ltd. — soxr 0.3.7 quality='QQ' anti-aliasing omission
# soxr 0.3.7; Python 3.9
# Pipeline: 48kHz stereo WAV → 16kHz mono float32 → Whisper-large-v3
# Problem: quality='QQ' (linear interpolation) has no anti-aliasing filter
# 8–24kHz speech energy aliases into 0–8kHz; mel spectrogram corrupted
# Fix: quality='VHQ' (Kaiser window FIR anti-aliasing filter)
import numpy as np
import soxr
ORIG_SR = 48000
TARGET_SR = 16000 # Whisper requires 16kHz
NYQUIST_OUT = TARGET_SR // 2 # 8000 Hz
# ── BUGGY pipeline ─────────────────────────────────────────────────────────
def resample_buggy(audio_stereo: np.ndarray, sr: int = ORIG_SR) -> np.ndarray:
"""
BUG: quality='QQ' (Quick Quality) = linear interpolation.
No anti-aliasing filter before factor-3 decimation.
Frequencies 8–24kHz alias into 0–8kHz passband.
For speech: /s/ energy at 8–9kHz → aliases to 7–8kHz (overlaps /ʃ/ region).
/f/ energy at 9–10kHz → aliases to 6–7kHz (overlaps /v/ vowel region).
"""
# Stereo (N, 2) → mono (N,)
audio_mono = audio_stereo.mean(axis=1).astype(np.float32)
# BUG: quality='QQ' — 3x faster but no anti-aliasing for factor-3 downsample
resampled = soxr.resample(audio_mono, sr, TARGET_SR, quality='QQ')
return resampled
# ── FIXED pipeline ──────────────────────────────────────────────────────────
def resample_fixed(audio_stereo: np.ndarray, sr: int = ORIG_SR) -> np.ndarray:
"""
FIX: quality='VHQ' (Very High Quality) = Kaiser window FIR anti-aliasing.
Low-pass filter cuts frequencies above ~7.2kHz (slight rolloff margin below
8kHz Nyquist) before factor-3 decimation.
Aliasing abolished: mel spectrogram bins 60–80 show only true speech energy.
WER 8.2% → 4.1% on 500-utterance sibilant-heavy test set.
"""
audio_mono = audio_stereo.mean(axis=1).astype(np.float32)
# FIX: quality='VHQ' — Kaiser window FIR, high stopband attenuation
resampled = soxr.resample(audio_mono, sr, TARGET_SR, quality='VHQ')
return resampled
# ── Anti-aliasing validation ────────────────────────────────────────────────
def check_aliasing_energy(audio_resampled: np.ndarray,
check_band_hz: tuple = (7000, 8000),
sr: int = TARGET_SR) -> float:
"""
Measure energy in a frequency band of the resampled audio.
For a pure-tone input at 9kHz (above Nyquist), QQ will show energy at
7kHz (alias); VHQ will show near-zero energy (filtered out before downsample).
Returns: mean power in check_band_hz (lower is better for alias-free output).
"""
fft = np.fft.rfft(audio_resampled)
freqs = np.fft.rfftfreq(len(audio_resampled), d=1.0 / sr)
band_mask = (freqs >= check_band_hz[0]) & (freqs <= check_band_hz[1])
band_energy = np.mean(np.abs(fft[band_mask]) ** 2)
return float(band_energy)
# ── Demonstration: 9kHz test tone (should be silent after anti-aliasing) ───
def demo_aliasing():
"""
Input: 1-second 9kHz sine tone at 48kHz (above 8kHz Nyquist for 16kHz output).
After correct anti-aliasing: 9kHz tone should be absent in 16kHz output.
With QQ (no anti-aliasing): 9kHz → 7kHz alias visible in output.
"""
duration = 1.0
t = np.linspace(0, duration, int(ORIG_SR * duration), endpoint=False)
tone_9khz = np.sin(2 * np.pi * 9000 * t).astype(np.float32)
tone_stereo = np.stack([tone_9khz, tone_9khz], axis=1)
out_qq = resample_buggy(tone_stereo)
out_vhq = resample_fixed(tone_stereo)
# QQ: alias lands at 16000 - 9000 = 7000 Hz — energy present in output
energy_qq = check_aliasing_energy(out_qq, check_band_hz=(6500, 7500))
# VHQ: 9kHz filtered before decimation — near-zero energy in output
energy_vhq = check_aliasing_energy(out_vhq, check_band_hz=(6500, 7500))
print(f"9kHz tone aliasing test:")
print(f" QQ alias energy at 7kHz: {energy_qq:.4f} (high = aliasing present)")
print(f" VHQ alias energy at 7kHz: {energy_vhq:.6f} (near-zero = anti-aliased)")
print()
print("Root cause: soxr quality='QQ' (Quick Quality) = linear interpolation")
print(" No anti-aliasing FIR filter before factor-3 decimation")
print(" Speech energy 8–24kHz folds into 0–8kHz passband")
print(" Whisper mel spectrogram bins 60–80 (5–8kHz) show aliased noise")
print(" Sibilant phoneme representations corrupted: WER 8.2%")
print()
print("Fix: quality='VHQ' — Kaiser window FIR anti-aliasing filter")
print(" Frequencies above ~7.2kHz attenuated before decimation")
print(" Mel spectrogram shows only true speech energy")
print(" WER 8.2% → 4.1% on 500-utterance sibilant test set; 2.0h")
demo_aliasing()
How soxr’s quality presets differ in anti-aliasing protection, and when 'QQ' is acceptable vs. when it corrupts the downstream signal
soxr exposes five quality presets — 'QQ', 'LQ', 'MQ', 'HQ', 'VHQ' — that trade processing speed against filter quality. 'QQ' (Quick Quality) uses linear interpolation with no dedicated anti-aliasing filter stage: it is correct only when the input signal is already band-limited to below the output Nyquist, or when aliasing artifacts are acceptable. 'LQ' through 'VHQ' all apply FIR low-pass filters of increasing tap count and stopband attenuation before decimation, with 'VHQ' using a Kaiser window design that achieves stopband attenuation typically exceeding 90 dB — meaning frequencies above the cutoff are attenuated by a factor of over 30,000 in amplitude. For downsampling factor 3 (48kHz→16kHz), the speed ordering on a modern CPU is roughly: QQ (fastest, ~1×) < LQ (~1.5×) < MQ (~2×) < HQ (~3×) < VHQ (~3.5×) relative to QQ. 'QQ' is an appropriate choice for: live audio monitoring where human perception of aliasing is masked by other noise; resampling audio that has already been low-pass filtered upstream (e.g., a 16kHz microphone signal being resampled to 8kHz for telephony); and format conversion for visualization or waveform display where aliasing is visually negligible. 'QQ' is not appropriate for: feeding audio into mel spectrogram extraction used by ASR, speaker recognition, or audio classification models (mel filterbanks are extremely sensitive to energy distribution across frequency bins); resampling for mixing or mastering (aliasing introduces audible distortion artifacts); or any pipeline where the downstream component was trained on data resampled with high-quality anti-aliasing. The Northfield team’s mistake — switching from 'HQ' to 'QQ' in a production ASR pipeline without an ASR-level regression test — illustrates the disconnect between audio-layer benchmarks (throughput in seconds per episode) and application-layer benchmarks (WER). The fix added a WER gate to the soxr quality-change CI check: any PR that modifies the quality parameter must show no regression beyond 0.3 percentage points of WER on the held-out test set before it can merge. The retainer engagement was 2.0h: 0.25h triage (customer complaints isolated to sibilant-rich words; WER benchmark reveals 8.2% vs expected 4.1%; deployment timeline correlated with quality='QQ' change); 0.75h root cause (soxr QQ implementation confirmed as linear interpolation; 9kHz tone aliasing test demonstrates 7kHz alias in QQ output, absent in VHQ output; mel spectrogram comparison shows aliased energy in bins 60–80); 0.5h fix (quality='VHQ' deployed; WER benchmark confirms 4.1%; throughput analysis confirms two additional CPU cores absorb the 3× soxr slowdown within SLA); 0.5h validation (500-utterance test set WER 4.1%; sibilant word accuracy restored; CI WER gate added). Hours logged to HourTab with per-session breakdown.
Related retainer posts
- resampy developer on retainer — resampy 0.4.3; Python 3.9; podcast audio normalization 15,000 episodes/month; soundfile returns (N, 2) stereo; resampy.resample default axis=-1 targets channel axis (length 2) not time axis (length N); audio plays 1.088× speed; fix: axis=0 — 3 weeks
- librosa developer on retainer — librosa 0.10.x; Python 3.11; audio classification 10K environmental sounds; melspectrogram(fmax=8000) truncates frequency content above 8kHz; glass breaking and bird call features lost; val_accuracy 0.61; fix: remove fmax; 0.61→0.79 — 3 weeks
- sounddevice developer on retainer — sounddevice 0.4.7; Python 3.9; keyword spotting on 50 kiosks; InputStream callback indata view into PortAudio C buffer reused each callback; queue.put(indata) stale pointer; VAD false trigger 23%; fix: indata.copy() — 3 weeks
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 →