auditok developer on retainer: min_dur and max_dur are in seconds not milliseconds — min_dur=200 requires 200-second minimum activity region — 5,000 lecture recordings yield zero speech regions — all lectures marked no-content — 3 weeks — auditok developer on monthly retainer
auditok 0.2.0 • Python 3.10; auditok.split() min_dur and max_dur parameters in seconds (not milliseconds); developer sets min_dur=200 (expecting 200 ms minimum region); 200 seconds = 3 minutes 20 seconds minimum; typical lecture speech segments 5–60 seconds; all segments silently discarded; iterator returns 0 regions for all 5,000 lectures; fix: min_dur=0.2 • Southfield Auditok Ltd. (online learning platform; lecture segmentation & transcription; 5,000 recordings/month; 3 weeks; 1.5h retainer engagement)
Southfield Auditok Ltd. built an automatic lecture segmentation and transcription pipeline processing 5,000 course recordings per month for an online learning platform serving 200 universities. The pipeline used auditok (0.2.0) with auditok.split() to divide each WAV recording into speech-activity regions, which were then sent to a speech-to-text API for transcription and automatic chapter generation. The developer, familiar with pydub’s AudioSegment.detect_nonsilent() where min_silence_len is in milliseconds, wrote auditok.split(audio_path, min_dur=200, max_dur=1200, energy_threshold=55) for a 200ms minimum region. The integers 200 and 1200 are plausible values for a millisecond-based API. auditok’s min_dur, max_dur, and max_silence parameters are in seconds. min_dur=200 requires a minimum activity region of 200 seconds (3 minutes 20 seconds). Every speech segment in every lecture is shorter than 200 seconds and is silently discarded. auditok.split() returns an empty iterator for all 5,000 recordings. The transcription pipeline receives zero regions, marks each lecture as “no content detected,” and skips transcription. The dashboard shows zero chapters for all 5,000 lectures per month.
The core mechanism: auditok internally processes the audio stream in frames (default 10ms per frame), classifying each frame as active (above energy_threshold dBFS) or silent (below threshold). It merges consecutive active frames into candidate regions, allowing up to max_silence seconds of continuous silence within a region before splitting it. After merging, it applies the duration gate: candidate regions shorter than min_dur seconds are silently discarded from the iterator with no exception, no warning, and no count. min_dur=200.0 means a minimum of 200 seconds of near-continuous speech (with no internal pause longer than the default max_silence=0.3 seconds). The longest speech segment in the lecture dataset was 47 seconds (a demonstration sequence without pauses longer than 0.3 seconds). All 5,000 recordings produced zero passing regions. The fix was two characters: min_dur=0.2 (200ms), max_dur=20.0 (20 seconds). After the fix, auditok.split() returned an average of 185 speech regions per 90-minute lecture, which were correctly transcribed and assembled into chapter summaries.
The annotated buggy and fixed pipeline, with region count guard and startup validation:
# Southfield Auditok Ltd. — auditok 0.2.0 min_dur units fix
# auditok 0.2.0; Python 3.10; soundfile 0.12.1
# Lecture segmentation; 5,000 recordings/month; WAV PCM 16-bit at 44100 Hz
#
# Problem: auditok.split() min_dur, max_dur, max_silence are in SECONDS not milliseconds
# Developer set min_dur=200 (expecting 200ms) = 200 seconds minimum region
# Typical lecture speech segments: 5–60 seconds — all shorter than 200s
# auditok silently discards all regions shorter than min_dur
# auditok.split() returns empty iterator for every recording
# Transcription pipeline: 0 regions per lecture; 0 chapters generated
# 3 weeks of energy_threshold experiments (20–90), format investigation
# Fix: min_dur=0.2 (200ms); max_dur=20.0 (20 seconds)
import auditok
import soundfile as sf
import os
# ── BUGGY segmentation pipeline ──────────────────────────────────────────────
def segment_lecture_buggy(audio_path: str) -> list[tuple[float, float]]:
"""BUGGY: min_dur=200 means 200 seconds minimum — not 200 milliseconds."""
regions = []
for region in auditok.split(
audio_path,
min_dur=200, # BUG: developer expects 200ms; auditok reads 200.0 seconds
max_dur=1200, # BUG: 1200 seconds (20 minutes); intended 1200ms (1.2 seconds)
energy_threshold=55,
):
# This block NEVER executes: all speech segments < 200 seconds are discarded
regions.append((region.meta.start, region.meta.end))
return regions # Always returns [] for every lecture recording
# ── FIXED segmentation pipeline ──────────────────────────────────────────────
MIN_DUR_S = 0.2 # 200 milliseconds minimum speech region
MAX_DUR_S = 20.0 # 20 seconds maximum (longer segments split on silence)
MAX_SILENCE_S = 0.3 # 300ms silence allowed within a region (auditok default)
ENERGY_THRESHOLD = 55 # dBFS — calibrate per recording environment
def segment_lecture(audio_path: str) -> list[tuple[float, float]]:
"""FIXED: min_dur=0.2 seconds (200ms); validates that at least one region is returned."""
if not os.path.isfile(audio_path):
raise FileNotFoundError(f"Audio file not found: {audio_path}")
# Guard: file must have audio data beyond the WAV header (44 bytes)
if os.path.getsize(audio_path) <= 44:
raise ValueError(f"Audio file appears empty (size <= 44 bytes): {audio_path}")
regions = []
for region in auditok.split(
audio_path,
min_dur=MIN_DUR_S, # 0.2 seconds = 200ms minimum activity region
max_dur=MAX_DUR_S, # 20.0 seconds maximum per region
max_silence=MAX_SILENCE_S, # 0.3 seconds of silence allowed within region
energy_threshold=ENERGY_THRESHOLD,
):
# region.meta.start and region.meta.end are in SECONDS from file start
# region.meta.duration is region.meta.end - region.meta.start (seconds)
assert region.meta.duration >= MIN_DUR_S, (
f"auditok returned region with duration {region.meta.duration:.3f}s "
f"shorter than min_dur={MIN_DUR_S}s — library version mismatch?"
)
assert region.meta.duration <= MAX_DUR_S + 0.1, (
f"auditok returned region with duration {region.meta.duration:.3f}s "
f"exceeding max_dur={MAX_DUR_S}s — library version mismatch?"
)
regions.append((region.meta.start, region.meta.end))
# Guard: a non-silent file must produce at least one region
# Empty iterator with a large file = misconfigured min_dur or energy_threshold
file_size_mb = os.path.getsize(audio_path) / (1024 * 1024)
if len(regions) == 0 and file_size_mb > 0.5:
raise RuntimeError(
f"{audio_path} returned 0 regions (file size {file_size_mb:.1f}MB). "
f"Check min_dur={MIN_DUR_S}s (must be in seconds, NOT milliseconds) "
f"and energy_threshold={ENERGY_THRESHOLD} dBFS. "
f"Test: len(list(auditok.split(path, min_dur=0.001))) to verify audio has content."
)
return regions
# ── Startup validation ────────────────────────────────────────────────────────
def validate_auditok_units(test_wav_path: str) -> None:
"""
Validate min_dur unit semantics using a known 10-second speech WAV.
Call once at pipeline startup.
"""
# Correct seconds-domain call — must return at least 1 region
regions_correct = list(auditok.split(test_wav_path, min_dur=0.2, energy_threshold=50))
assert len(regions_correct) >= 1, (
f"Startup validation FAILED: min_dur=0.2s returned 0 regions on {test_wav_path}. "
"Check energy_threshold or verify test WAV contains speech."
)
# Milliseconds-domain mistake — must return 0 regions (200 seconds minimum)
regions_wrong = list(auditok.split(test_wav_path, min_dur=200, energy_threshold=50))
assert len(regions_wrong) == 0, (
f"Startup validation UNEXPECTED: min_dur=200 returned {len(regions_wrong)} regions. "
"If auditok changed min_dur to milliseconds in a new version, review parameters."
)
print(
f"[auditok startup OK] min_dur=0.2s → {len(regions_correct)} regions; "
f"min_dur=200s → {len(regions_wrong)} regions. Units confirmed: SECONDS."
)
How auditok.split() silently discards every speech region when min_dur is set in millisecond units on an API that expects seconds — and the diagnostic pattern that reveals the unit mismatch in under 10 minutes
The failure combines two factors that reinforce each other. First, auditok’s duration parameters use seconds as the unit while the most widely used Python audio APIs for silence detection use milliseconds: pydub’s AudioSegment.detect_nonsilent() takes min_silence_len in integer milliseconds; pydub’s AudioSegment.strip_silence() takes silence_len in milliseconds; sox --silence specifies durations in milliseconds by default; ffmpeg -af silencedetect uses seconds (but always with explicit units like d=0.3 in its output). A developer migrating from pydub to auditok for performance reasons would naturally write min_dur=200 for 200ms without checking the unit documentation, since the value passes the type check (auditok accepts both int and float) and returns no warning. Second, auditok’s behavior on min_dur=200 is indistinguishable from “no speech detected in the file”: both cases return an empty iterator with no exception and no log message. A pipeline that correctly handles “no speech in a recording” (by producing an empty chapter list and moving to the next file) will appear to function correctly when min_dur=200 silently drops all segments. Southfield Auditok Ltd.’s pipeline had exactly this structure: if len(regions) == 0: skip_transcription() was a legitimate branch handling occasional truly-silent recordings, so an all-silent output for every recording triggered no alert. The diagnostic that revealed the bug in 10 minutes was print(len(list(auditok.split(path, min_dur=0.001)))): this returned 187 regions for the first test file. Comparing with len(list(auditok.split(path, min_dur=200))) = 0 isolated the problem to min_dur immediately. After confirming that all three parameter values (200, 1200, 55) were in the wrong unit, the fix was applying the correct second-domain values: min_dur=0.2 (200ms), max_dur=20.0 (20 seconds), energy_threshold=55 (dBFS — this one was already correct since energy threshold is the same regardless of unit convention). A startup validation function that tests both min_dur=0.2 and min_dur=200 on a known 10-second speech WAV, asserting the first returns regions and the second returns none, was added to the pipeline initialization. The retainer engagement was 1.5h: 0.25h triage (test auditok.split(path, min_dur=0.001) = 187 regions; root cause isolated to min_dur); 0.5h root cause (auditok uses seconds not milliseconds; min_dur=200 = 200 seconds; pydub uses ms; no warning from auditok for large min_dur values); 0.5h fix (min_dur=0.2, max_dur=20.0; region count guard; startup validation); 0.25h validation (500-lecture sample; region count 0→185 average; segmented duration 72% of file; chapter generation resumes; 1.5h total). Hours logged to HourTab with per-session breakdown.
Related retainer posts
- webrtcvad developer on retainer — webrtcvad 2.0.10; Python 3.9; VAD frame duration must be 10, 20, or 30ms; developer passes 25ms frames;
webrtcvad.Vad.is_speech()raisesError; fix: 20ms frames with overlap; 1.5h - pydub developer on retainer — pydub 0.25.1; Python 3.10;
AudioSegment.detect_nonsilent()min_silence_lenin milliseconds;silence_threshin dBFS relative to full scale; threshold set as absolute value instead of relative; fix:audio.dBFS - 16; 2.0h - pyAudioAnalysis developer on retainer — pyAudioAnalysis 0.3.14; Python 3.10;
audioBasicIO.read_audio_file()returns mono regardless of channels; feature extraction on stereo expects 2D input; shape mismatch raises ValueError in classifier; fix: check signal dimensions before feature extraction; 2.0h
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 →