Panniantong/Agent-Reach · error · TranscribeError
audio chunks total {total_chunk_bytes} bytes; safety limit i
Error message
audio chunks total {total_chunk_bytes} bytes; safety limit is {limit_mib:g} MiB What it means
Raised when the sum of all chunk sizes exceeds MAX_TOTAL_CHUNK_BYTES (96 MiB) after per-chunk size validation passes. Even when each chunk is under the 24 MiB Whisper limit, the aggregate upload budget (cost/time guard) is capped at 96 MiB per transcribe() call. It fires before any upload, so no API spend has occurred.
Source
Thrown at agent_reach/transcribe.py:475
if compressed.stat().st_size <= SIZE_LIMIT_BYTES:
chunks = [compressed]
else:
chunks = chunk_audio(compressed, work_dir)
if len(chunks) > MAX_CHUNKS:
max_minutes = MAX_CHUNKS * CHUNK_SECONDS // 60
raise TranscribeError(
f"audio produced {len(chunks)} chunks; safety limit is "
f"{MAX_CHUNKS} (~{max_minutes} minutes)"
)
chunk_sizes = [
_require_size_at_most(chunk, SIZE_LIMIT_BYTES, f"chunk {chunk.name}")
for chunk in chunks
]
total_chunk_bytes = sum(chunk_sizes)
if total_chunk_bytes > MAX_TOTAL_CHUNK_BYTES:
limit_mib = MAX_TOTAL_CHUNK_BYTES / (1024 * 1024)
raise TranscribeError(
f"audio chunks total {total_chunk_bytes} bytes; "
f"safety limit is {limit_mib:g} MiB"
)
pieces: List[str] = []
for chunk in chunks:
text = _transcribe_with_fallback(chunk, order, cfg)
pieces.append(text.strip())
return "\n".join(p for p in pieces if p)
def _transcribe_with_fallback(chunk: Path, order: List[str], config: Config) -> str:
"""Try each provider in order; return first success or raise the last error."""
last_err: Optional[Exception] = None
for p in order:
if not _provider_key(p, config):
# Skip silently — caller already validated at least one is configured.
continueView on GitHub (pinned to 93ae1d18c3)
Solutions
- Reduce source length: trim with yt-dlp --download-sections or ffmpeg and transcribe parts separately
- Re-encode the source at a lower bitrate (e.g. ffmpeg -b:a 48k mono flac/opus) before calling transcribe()
- Check that ffmpeg compression is actually succeeding in your environment (doctor verifies ffmpeg presence)
Example fix
# before
text = transcribe("huge_recording.wav") # chunks total > 96 MiB
# after — pre-compress to speech-friendly bitrate
# ffmpeg -i huge_recording.wav -ac 1 -b:a 32k small.opus
text = transcribe("small.opus") Defensive patterns
Strategy: validation
Validate before calling
from agent_reach.transcribe import MAX_TOTAL_CHUNK_BYTES # 96 MiB
def compressed_size_ok(path: str) -> bool:
import os
return os.path.getsize(path) <= MAX_TOTAL_CHUNK_BYTES Try / catch
from agent_reach.transcribe import transcribe, TranscribeError
try:
text = transcribe(src)
except TranscribeError as e:
if "chunks total" in str(e):
src = recompress_mono_low_bitrate(src) # ffmpeg -ac 1 -b:a 32k
text = transcribe(src)
else:
raise Prevention
- Pre-encode speech audio to mono, low-bitrate opus/flac before transcribe()
- Remember both caps: per-chunk 24 MiB, aggregate 96 MiB, count 24 chunks
- Check compressed output size, not source size — compression ratio decides
When it happens
Trigger: Calling transcribe() on audio where chunk_audio produces e.g. 5 chunks of ~20 MiB each (100 MiB total) — each passes the per-chunk SIZE_LIMIT_BYTES check but the sum exceeds MAX_TOTAL_CHUNK_BYTES. Typical for high-bitheadroom audio that compresses poorly.
Common situations: High-bitrate music-heavy or noise-heavy sources (podcasts with music beds, concert recordings); WAV/FLAC sources converted at conservative compression settings; long audio near but under the 4-hour chunk-count cap.
Related errors
- audio produced {len(chunks)} chunks; safety limit is {MAX_CH
- audio duration exceeds safety limit of {max_minutes} minutes
- chunk segment duration must be positive
- ffmpeg produced no chunks
- polish response exceeds 32 MiB limit
AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14).
Data as JSON: /api/errors/b66aac71a73753c7.
Report an issue: GitHub.