harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError
ElevenLabs audio exceeds the 50 MB limit
Error message
ElevenLabs audio exceeds the 50 MB limit
What it means
ElevenLabsMusicError raised by _stream_audio while downloading the generated track: cumulative bytes crossed MAX_GENERATED_AUDIO_BYTES (50 MB, app/services/elevenlabs_music.py:24). The download is chunked at 1 MB precisely so an abnormally large or endless response is cut off early instead of filling the disk. The temp audio file (created via mkstemp in the output dir) is left for the caller's cleanup path.
Source
Thrown at app/services/elevenlabs_music.py:281
"ElevenLabs video proxy is empty or exceeds the 200 MB limit"
)
logger.info(
"ElevenLabs video proxy prepared: "
f"source={video_path}, size={proxy_size} bytes"
)
return proxy_path
def _stream_audio(response: requests.Response, temp_audio_path: str) -> int:
"""分块保存音频并限制最大体积,防止异常响应耗尽本机磁盘。"""
total_bytes = 0
with open(temp_audio_path, "wb") as output:
for chunk in response.iter_content(chunk_size=1024 * 1024):
if not chunk:
continue
total_bytes += len(chunk)
if total_bytes > MAX_GENERATED_AUDIO_BYTES:
raise ElevenLabsMusicError(
"ElevenLabs audio exceeds the 50 MB limit"
)
output.write(chunk)
output.flush()
os.fsync(output.fileno())
if total_bytes <= 0:
raise ElevenLabsMusicError("ElevenLabs returned no audio data")
return total_bytes
def _request_bgm(video_path: str, output_path: str, prompt: str) -> str:
"""请求 ElevenLabs 配乐,完整下载并通过 FFmpeg 校验后再原子发布。"""
output_dir = os.path.dirname(os.path.abspath(output_path))
os.makedirs(output_dir, exist_ok=True)
descriptor, temp_audio_path = tempfile.mkstemp(
prefix=".elevenlabs-music-",
suffix=Path(output_path).suffix or ".mp3",
dir=output_dir,View on GitHub (pinned to 1f9f19c202)
Solutions
- Retry once — oversized responses from a generation glitch are rare and transient.
- Shorten the source video / music prompt so the generated track is smaller (cost scales with duration).
- If it reproduces consistently, capture response headers (Content-Type/Content-Length) to see whether the API started returning WAV or duplicated bodies, and report upstream.
Defensive patterns
Strategy: retry
Try / catch
try:
generate_bgm(video_path, output_path, prompt)
except ElevenLabsMusicError as e:
if 'exceeds the 50 MB limit' in str(e):
time.sleep(3)
generate_bgm(video_path, output_path, shorter_prompt_or_trimmed_video) Prevention
- Keep source videos and prompts modest — generated track size scales with duration.
- Retry once before escalating; oversized responses are usually one-off glitches.
- If reproducible, inspect Content-Type/Length of the music response for API behavior changes.
When it happens
Trigger: The Music endpoint responding with an audio stream larger than 50 MB — e.g. an extremely long prompt-generated track, a WAV instead of compressed MP3, or a malformed/looping response body.
Common situations: Very long video durations producing long tracks; API behavior changes returning uncompressed audio; a proxy or retry layer duplicating the body.
Related errors
- ElevenLabs video proxy is empty or exceeds the 200 MB limit
- ElevenLabs returned no audio data
- failed to request ElevenLabs music: {exc}
- Sonilo audio exceeds the 30 MB limit
- {request_id}: invalid file path
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/7cc36f91cfb66b4b.
Report an issue: GitHub.