{"record":{"id":"bdf62bab97186321","repo":"calesthio/OpenMontage","slug":"advanced-lip-sync-requires-at-least-2000ms-of-crop","errorCode":null,"errorMessage":"advanced_lip_sync requires at least 2000ms of cropped audio","messagePattern":"advanced_lip_sync requires at least 2000ms of cropped audio","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/avatar/kling_lip_sync.py","lineNumber":563,"sourceCode":"                value = default\n            face_item[key] = int(value)\n\n        nested_end = face_item.get(\"sound_end_time\")\n        top_level_end = inputs.get(\"sound_end_time\")\n        if (\n            nested_end is not None\n            and top_level_end is not None\n            and int(nested_end) != int(top_level_end)\n        ):\n            raise ValueError(\n                \"Conflicting sound_end_time values between top-level input and face_choose[0]\"\n            )\n        sound_end = nested_end if nested_end is not None else top_level_end\n        if sound_end is None:\n            raise ValueError(\"advanced_lip_sync requires sound_end_time\")\n        face_item[\"sound_end_time\"] = int(sound_end)\n        if face_item[\"sound_end_time\"] - face_item[\"sound_start_time\"] < 2000:\n            raise ValueError(\"advanced_lip_sync requires at least 2000ms of cropped audio\")\n\n        for key in (\"sound_volume\", \"original_audio_volume\"):\n            nested = face_item.get(key)\n            top_level = inputs.get(key)\n            if nested is not None and top_level is not None and float(nested) != float(top_level):\n                raise ValueError(\n                    f\"Conflicting {key} values between top-level input and face_choose[0]\"\n                )\n            value = nested if nested is not None else top_level\n            if value is not None:\n                face_item[key] = float(value)\n\n    @staticmethod\n    def _face_choose_result_metadata(\n        face_choose: list[dict[str, Any]],\n    ) -> list[dict[str, Any]]:\n        metadata: list[dict[str, Any]] = []\n        for item in face_choose:","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/avatar/kling_lip_sync.py#L545-L581","documentation":"Raised by KlingLipSyncTool._copy_timing_fields on the advanced lip-sync path when sound_end_time - sound_start_time < 2000 ms. Kling's advanced lip-sync API rejects cropped audio segments shorter than 2 seconds, so the tool enforces the floor before sending the request.","triggerScenarios":"advanced_lip_sync with sound_start_time=0 and sound_end_time=1500; or face_choose[0] = {'sound_start_time': 4000, 'sound_end_time': 5500}. Defaults matter too: if sound_start_time defaults to 0, sound_end_time must be >= 2000.","commonSituations":"Trying to lip-sync a single short word or a 1-second SFX cue; computing the crop window from a transcript where a spoken phrase lasted under 2s.","solutions":["Extend the crop window so end - start >= 2000 ms (pad with silence if the speech is shorter)","Shift sound_start_time closer to sound_end_time if you accidentally left it at 0 while the audio lives later in the file","If the clip genuinely must be <2s, use the non-advanced lip-sync path or pad the audio file itself"],"exampleFix":"# before\nface = {\"sound_start_time\": 0, \"sound_end_time\": 1500}\n\n# after\nface = {\"sound_start_time\": 0, \"sound_end_time\": 2000}","handlingStrategy":"validation","validationCode":"face_item = (inputs.get(\"face_choose\") or [{}])[0]\nstart = int(face_item.get(\"sound_start_time\") or inputs.get(\"sound_start_time\") or 0)\nend = face_item.get(\"sound_end_time\") if face_item.get(\"sound_end_time\") is not None else inputs.get(\"sound_end_time\")\nif end is None or int(end) - start < 2000:\n    raise ValueError(\"crop window must be >= 2000ms\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Budget at least 2s of audio per lip-sync call","Pad short voice lines with silence to reach 2000ms","Double-check sound_start_time defaults to 0 — end must exceed it by 2000"],"tags":["kling","lip-sync","timing","minimum-duration"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}