Panniantong/Agent-Reach · error · TranscribeError
audio produced {len(chunks)} chunks; safety limit is {MAX_CH
Error message
audio produced {len(chunks)} chunks; safety limit is {MAX_CHUNKS} (~{max_minutes} minutes) What it means
Raised after download/compress/chunk when the audio splits into more than MAX_CHUNKS (24) chunks of 10 minutes each, i.e. roughly 4 hours of audio. This is a cost and time safety valve so a single call cannot transcribe arbitrarily long media. It fires before any chunk is uploaded, so no API spend occurs.
Source
Thrown at agent_reach/transcribe.py:464
work_dir.mkdir(parents=True, exist_ok=True)
src_path = Path(source)
if src_path.is_file():
audio = src_path
else:
audio = download_audio(source, work_dir)
_require_size_at_most(audio, MAX_SOURCE_BYTES, "source")
_require_duration_within_budget(audio)
compressed = compress_audio(audio, work_dir)
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)View on GitHub (pinned to 93ae1d18c3)
Solutions
- Trim or split the source externally (e.g. yt-dlp --download-sections or ffmpeg -ss/-t) and transcribe segments separately
- Point transcribe() at a shorter portion of the media instead of the full item
- If you own the deployment and accept the cost, raise MAX_CHUNKS in a fork — but prefer external splitting
- For xiaoyuzhou episodes, use the bundled scripts/transcribe_xiaoyuzhou.sh flow which handles episode lengths itself
Example fix
# before
text = transcribe("https://www.youtube.com/watch?v=LONG_LIVESTREAM") # 25 chunks > 24
# after — transcribe only the first 3 hours
# yt-dlp --download-sections "*0-3:00:00" -o seg.mp4 "<url>"
text = transcribe("seg.mp4") Defensive patterns
Strategy: validation
Validate before calling
from agent_reach.transcribe import MAX_AUDIO_SECONDS, MAX_CHUNKS, CHUNK_SECONDS
def duration_ok(seconds: float) -> bool:
return seconds <= MAX_AUDIO_SECONDS # 24 * 600 = 14400s Try / catch
from agent_reach.transcribe import transcribe, TranscribeError
try:
text = transcribe(url)
except TranscribeError as e:
if "safety limit is" in str(e) and "chunks" in str(e):
text = transcribe_in_parts(url, parts=4) # your own splitter
else:
raise Prevention
- Probe duration with ffprobe before calling transcribe() and reject >4h sources
- For long media, download once and transcribe time-sliced sections yourself
- Treat this error as a hard cap — retrying unchanged will always fail
When it happens
Trigger: Calling transcribe() on a source longer than MAX_AUDIO_SECONDS (24 * 600s = 14400s = 4 hours), or on audio that compresses poorly (e.g. already-compressed formats) so chunk_audio must split the oversized compressed file into many size-based segments exceeding 24.
Common situations: Transcribing long podcasts, livestream VODs, multi-hour talks, or audiobooks; feeding a high-bitrate source file where compression cannot get under SIZE_LIMIT_BYTES per 10-minute segment.
Related errors
- audio chunks total {total_chunk_bytes} bytes; safety limit i
- chunk segment duration must be positive
- ffmpeg produced no chunks
- audio duration exceeds safety limit of {max_minutes} minutes
- chunk generation safety limit is {MAX_CHUNKS}; segment durat
AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14).
Data as JSON: /api/errors/9d97534af74d06af.
Report an issue: GitHub.