{"record":{"id":"ae7d44ebbdbc8bb6","repo":"babysor/MockingBird","slug":"either-voice-id-or-reference-audio-is-required","errorCode":null,"errorMessage":"Either --voice-id or --reference-audio is required.","messagePattern":"Either --voice-id or --reference-audio is required\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/speak/scripts/noiz_tts.py","lineNumber":102,"sourceCode":"        data[\"similarity_enh\"] = \"true\"\n    if save_voice:\n        data[\"save_voice\"] = \"true\"\n    if duration is not None:\n        data[\"duration\"] = str(duration)\n\n    files = None\n    if reference_audio:\n        if not reference_audio.exists():\n            raise FileNotFoundError(f\"Reference audio not found: {reference_audio}\")\n        files = {\n            \"file\": (\n                reference_audio.name,\n                reference_audio.open(\"rb\"),\n                \"application/octet-stream\",\n            )\n        }\n    elif not voice_id:\n        raise ValueError(\"Either --voice-id or --reference-audio is required.\")\n\n    try:\n        resp = requests.post(\n            url,\n            headers={\"Authorization\": api_key},\n            data=data,\n            files=files,\n            timeout=timeout,\n        )\n    finally:\n        if files and files[\"file\"][1]:\n            files[\"file\"][1].close()\n\n    if resp.status_code != 200:\n        raise RuntimeError(\n            f\"/text-to-speech failed: status={resp.status_code}, body={resp.text}\"\n        )\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/babysor/MockingBird/blob/28dc5e14f12d7c754612af2fde8e78a4b03f8616/skills/speak/scripts/noiz_tts.py#L84-L120","documentation":"ValueError raised by synthesize() when neither voice_id nor reference_audio is supplied. The Noiz TTS backend needs either a preset voice identifier or an uploaded reference audio clip to know which voice to synthesize with.","triggerScenarios":"Calling synthesize(voice_id=None, reference_audio=None) — e.g. invoking the CLI with neither --voice-id nor --reference-audio.","commonSituations":"User assumes there is a default voice, or an env var/flag that was expected to supply the voice id is unset or empty string.","solutions":["Pass a valid --voice-id from the service's voice list","Or pass --reference-audio pointing to an existing audio file","Check that environment-variable indirection for voice id is actually set (not empty string)"],"exampleFix":"# before\nsynthesize(..., voice_id=None, reference_audio=None)\n# after\nsynthesize(..., voice_id=os.environ[\"NOIZ_VOICE_ID\"], reference_audio=None)","handlingStrategy":"validation","validationCode":"if not (voice_id or reference_audio):\n    sys.exit('Either --voice-id or --reference-audio is required.')","typeGuard":"def has_voice_source(voice_id, reference_audio) -> bool:\n    return bool(voice_id) or bool(reference_audio)","tryCatchPattern":"try:\n    synthesize(...)\nexcept ValueError as e:\n    if 'required' in str(e):\n        synthesize(..., voice_id=os.environ['NOIZ_VOICE_ID'])\n    else:\n        raise","preventionTips":["Enforce mutual-requirement at arg parsing","Source voice id from a validated env var","Fail fast before any HTTP traffic"],"tags":["validation","required-parameter","voice","noiz-tts"],"backgroundTag":"missing-required-parameter","analyzedSha":"28dc5e14f12d7c754612af2fde8e78a4b03f8616","analyzedAt":"2026-08-27T02:26:53.589Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}