{"record":{"id":"8d10dd7f3f881b82","repo":"Comfy-Org/ComfyUI","slug":"second-audio-encoder-output-must-be-provided-if-tw","errorCode":null,"errorMessage":"Second audio encoder output must be provided if two masks are used.","messagePattern":"Second audio encoder output must be provided if two masks are used\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_wan.py","lineNumber":1522,"sourceCode":"    def execute(cls, mode: DCValues, model, model_patch, positive, negative, vae, width, height, length, audio_encoder_output_1, motion_frame_count,\n                start_image=None, previous_frames=None, audio_scale=None, clip_vision_output=None, audio_encoder_output_2=None, mask_1=None, mask_2=None) -> io.NodeOutput:\n\n        if previous_frames is not None and previous_frames.shape[0] < motion_frame_count:\n            raise ValueError(\"Not enough previous frames provided.\")\n\n        if mode[\"mode\"] == \"two_speakers\":\n            audio_encoder_output_2 = mode[\"audio_encoder_output_2\"]\n            mask_1 = mode[\"mask_1\"]\n            mask_2 = mode[\"mask_2\"]\n\n        if audio_encoder_output_2 is not None:\n            if mask_1 is None or mask_2 is None:\n                raise ValueError(\"Masks must be provided if two audio encoder outputs are used.\")\n\n        ref_masks = None\n        if mask_1 is not None and mask_2 is not None:\n            if audio_encoder_output_2 is None:\n                raise ValueError(\"Second audio encoder output must be provided if two masks are used.\")\n            ref_masks = torch.cat([mask_1, mask_2])\n\n        latent = torch.zeros([1, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())\n        if start_image is not None:\n            start_image = comfy.utils.common_upscale(start_image[:length].movedim(-1, 1), width, height, \"bilinear\", \"center\").movedim(1, -1)\n            image = torch.ones((length, height, width, start_image.shape[-1]), device=start_image.device, dtype=start_image.dtype) * 0.5\n            image[:start_image.shape[0]] = start_image\n\n            concat_latent_image = vae.encode(image[:, :, :, :3])\n            concat_mask = torch.ones((1, 1, latent.shape[2], concat_latent_image.shape[-2], concat_latent_image.shape[-1]), device=start_image.device, dtype=start_image.dtype)\n            concat_mask[:, :, :((start_image.shape[0] - 1) // 4) + 1] = 0.0\n\n            positive = node_helpers.conditioning_set_values(positive, {\"concat_latent_image\": concat_latent_image, \"concat_mask\": concat_mask})\n            negative = node_helpers.conditioning_set_values(negative, {\"concat_latent_image\": concat_latent_image, \"concat_mask\": concat_mask})\n\n        if clip_vision_output is not None:\n            positive = node_helpers.conditioning_set_values(positive, {\"clip_vision_output\": clip_vision_output})\n            negative = node_helpers.conditioning_set_values(negative, {\"clip_vision_output\": clip_vision_output})","sourceCodeStart":1504,"sourceCodeEnd":1540,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_wan.py#L1504-L1540","documentation":"The mirror-image guard of the two-speaker check: if both mask_1 and mask_2 are provided but there is no second audio encoder output, the masks have nothing to pair with, so the node raises before torch.cat([mask_1, mask_2]). Exactly one pair of (masks, audio streams) mismatched inputs is disallowed.","triggerScenarios":"Connecting mask_1 and mask_2 while audio_encoder_output_2 is None and the mode is not 'two_speakers' (the mode branch would have populated it); partially converted workflows where masks remain from a two-speaker setup but the second audio input was removed.","commonSituations":"Downgrading a two-speaker workflow to single speaker by deleting the second audio loader but leaving the masks wired; testing masks independently.","solutions":["Connect the second audio encoder output when both masks are used","Or disconnect mask_1/mask_2 for single-speaker generation","Ensure mask inputs and audio inputs always come in pairs (2 masks <-> 2 audio streams)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if mask_1 is not None or mask_2 is not None:\n    assert audio_encoder_output_2 is not None, \"two masks need a second audio stream\"\n    if mask_1 is None or mask_2 is None:\n        raise ValueError(\"masks must come as a pair\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When downgrading to single speaker, disconnect masks and second audio together","Keep a checklist of paired inputs for two-speaker workflows"],"tags":["wan","audio-video","two-speakers","masks"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}