{"record":{"id":"1803dcb096d2f7f3","repo":"fishaudio/fish-speech","slug":"reference-audio-and-reference-text-must-be-giv","errorCode":null,"errorMessage":"--reference_audio and --reference_text must be given the same number of values, got {len(ref_audios)} audio(s) and {len(ref_texts)} text(s).","messagePattern":"--reference_audio and --reference_text must be given the same number of values, got (.+?) audio\\(s\\) and (.+?) text\\(s\\)\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"tools/api_client.py","lineNumber":150,"sourceCode":"        type=str,\n        default=\"YOUR_API_KEY\",\n        help=\"API key for authentication\",\n    )\n\n    return parser.parse_args()\n\n\nif __name__ == \"__main__\":\n    args = parse_args()\n\n    idstr: str | None = args.reference_id\n    # priority: ref_id > [{text, audio},...]\n    if idstr is None:\n        ref_audios = args.reference_audio or []\n        ref_texts = args.reference_text or []\n\n        if len(ref_audios) != len(ref_texts):\n            raise SystemExit(\n                \"--reference_audio and --reference_text must be given the same number \"\n                f\"of values, got {len(ref_audios)} audio(s) and {len(ref_texts)} text(s).\"\n            )\n\n        byte_audios = []\n        for ref_audio in ref_audios:\n            audio_bytes = audio_to_bytes(ref_audio)\n            if audio_bytes is None:\n                raise SystemExit(f\"Reference audio file not found: {ref_audio}\")\n            byte_audios.append(audio_bytes)\n\n        ref_texts = [read_ref_text(ref_text) for ref_text in ref_texts]\n    else:\n        byte_audios = []\n        ref_texts = []\n        pass  # in api.py\n\n    data = {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/tools/api_client.py#L132-L168","documentation":"tools/api_client.py validates that --reference_audio and --reference_text argument lists have equal length before building the request; mismatch triggers SystemExit with a count summary.","triggerScenarios":"Running api_client.py with, e.g., two --reference_audio flags but one --reference_text (or omitting the texts for extra audios).","commonSituations":"Voice-cloning requests with multiple reference clips where transcripts were forgotten; shell loops that pass mismatched lists.","solutions":["Supply exactly one --reference_text per --reference_audio, in the same order","Use --reference_id instead if you registered the pair server-side","Drop extra audios you don't have transcripts for"],"exampleFix":"# before\n--reference_audio a.wav b.wav --reference-text \"first\"\n# after\n--reference_audio a.wav b.wav --reference-text \"first\" \"second\"","handlingStrategy":"validation","validationCode":"if len(args.reference_audio or []) != len(args.reference_text or []):\n    # fix input before invoking the client\n    args.reference_text += [\"\"] * (len(args.reference_audio) - len(args.reference_text))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair audio/text via argparse nargs='+' in one option or zip them","Prefer --reference_id for registered references"],"tags":["api-client","cli","voice-cloning"],"backgroundTag":"argument-count-mismatch","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}