Skip to content

Fix UnboundLocalError: multitalk_audio_stride referenced before assignment in WanVideoSampler#2032

Open
kylinjg wants to merge 1 commit into
kijai:mainfrom
kylinjg:fix/multitalk-audio-stride-unbound
Open

Fix UnboundLocalError: multitalk_audio_stride referenced before assignment in WanVideoSampler#2032
kylinjg wants to merge 1 commit into
kijai:mainfrom
kylinjg:fix/multitalk-audio-stride-unbound

Conversation

@kylinjg

@kylinjg kylinjg commented Jun 13, 2026

Copy link
Copy Markdown

Problem

WanVideoSampler raises an UnboundLocalError on any run that does not pass multitalk_embeds (i.e. the large majority of workflows — standard T2V/I2V, VACE, Fun-Control, etc.):

UnboundLocalError: cannot access local variable 'multitalk_audio_stride' where it is not associated with a value
  File "custom_nodes/ComfyUI-WanVideoWrapper/nodes_sampler.py", line 822, in process
    if multitalk_audio_stride is not None:

Root cause

multitalk_audio_stride is only bound inside the if multitalk_embeds is not None: branch:

multitalk_audio_stride = multitalk_embeds.get("audio_stride", None)

but it is later read unconditionally:

if multitalk_audio_stride is not None:
    audio_stride = multitalk_audio_stride

When multitalk_embeds is None, the name is never assigned, so the later read throws.

Fix

Initialize multitalk_audio_stride = None alongside the other MultiTalk locals (multitalk_audio_embeds, audio_emb_slice, audio_features_in), so the unconditional read is always safe. One line, no behavior change for the MultiTalk path.

Reproduction

Run any VACE / T2V / I2V workflow through WanVideoSampler without a MultiTalk embed connected → error before this patch, works after.

…nment

multitalk_audio_stride is only assigned inside the `if multitalk_embeds is
not None` block, but is read unconditionally later in WanVideoSampler.process.
Any sampler run without multitalk_embeds (standard T2V/I2V, VACE, Fun-Control,
etc.) raises:
  UnboundLocalError: cannot access local variable 'multitalk_audio_stride'

Initialize it to None alongside the other multitalk locals.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant