{"record":{"id":"8ef655595f6f0718","repo":"harry0703/MoneyPrinterTurbo","slug":"elevenlabs-music-prompt-exceeds-1000-characters","errorCode":null,"errorMessage":"ElevenLabs music prompt exceeds 1000 characters","messagePattern":"ElevenLabs music prompt exceeds 1000 characters","errorType":"exception","errorClass":"ElevenLabsMusicError","httpStatus":null,"severity":"error","filePath":"app/services/elevenlabs_music.py","lineNumber":388,"sourceCode":"    if not get_api_key():\n        raise ElevenLabsMusicError(\"ElevenLabs API key is required\")\n    if not os.path.isfile(video_path):\n        raise ElevenLabsMusicError(\"ElevenLabs input video does not exist\")\n    try:\n        duration = float(video_duration)\n    except (TypeError, ValueError) as exc:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs video duration is invalid\"\n        ) from exc\n    if not math.isfinite(duration) or duration <= 0:\n        raise ElevenLabsMusicError(\"ElevenLabs video duration is invalid\")\n    if duration > MAX_VIDEO_DURATION_SECONDS:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs supports videos up to 600 seconds\"\n        )\n    prompt = str(prompt or \"\").strip()\n    if len(prompt) > MAX_PROMPT_LENGTH:\n        raise ElevenLabsMusicError(\n            \"ElevenLabs music prompt exceeds 1000 characters\"\n        )\n\n    proxy_path = \"\"\n    try:\n        proxy_path = _create_video_proxy(video_path)\n        return _request_bgm(proxy_path, output_path, prompt)\n    except ElevenLabsMusicError:\n        raise\n    except OSError as exc:\n        raise ElevenLabsMusicError(\n            f\"ElevenLabs local file operation failed: {exc}\"\n        ) from exc\n    finally:\n        _remove_file(proxy_path)\n","sourceCodeStart":370,"sourceCodeEnd":404,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/elevenlabs_music.py#L370-L404","documentation":"Prompt-length guard in generate_bgm: the stripped prompt exceeds MAX_PROMPT_LENGTH (1000 characters). Sent as form data alongside the video, an oversized prompt would be rejected by ElevenLabs after the whole video upload.","triggerScenarios":"generate_bgm called with a prompt whose .strip() length exceeds 1000 chars — typically a whole video description or concatenated per-scene prompts instead of a short style description.","commonSituations":"Reusing the full video script/subject text as the music prompt, LLM-generated prompts without a length budget, or prompts in CJK where token-to-char limits are easy to blow past.","solutions":["Truncate or summarize the prompt to well under 1000 chars — a music style description rarely needs more than a few sentences","If the prompt is LLM-generated, add a length constraint to the generation instruction","Validate prompt length in the UI/task layer so the user gets feedback before render time"],"exampleFix":"# before\nmusic_prompt = full_video_script  # thousands of chars\ngenerate_bgm(video, out, duration, music_prompt)\n\n# after\nmusic_prompt = full_video_script[:1000] if len(full_video_script) > 1000 else full_video_script\ngenerate_bgm(video, out, duration, music_prompt)","handlingStrategy":"validation","validationCode":"from app.services.elevenlabs_music import MAX_PROMPT_LENGTH\n\nprompt = prompt.strip()[:MAX_PROMPT_LENGTH]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep music prompts to short style descriptions, not full scripts","Enforce the 1000-char limit in the WebUI input field"],"tags":["validation","prompt","limit"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}