Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions LongCat/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,31 @@ def linear_interp(features, output_len):
offset += w.shape[-1]
out_audio = {"waveform": mixed, "sample_rate": sr}

return (multitalk_embeds, out_audio, num_frames)
# Calculate actual frames based on audio duration
actual_num_frames = num_frames
if len(audio_outputs) > 0:
if multi_audio_type == "para":
# For parallel mode, use the longest audio duration
max_audio_duration = max([ao["waveform"].shape[-1] / sr for ao in audio_outputs])
actual_frames_from_audio = int(max_audio_duration * fps)
else: # "add"
# For sequential mode, use the total audio duration
total_audio_duration = sum([ao["waveform"].shape[-1] / sr for ao in audio_outputs])
actual_frames_from_audio = int(total_audio_duration * fps)

# Use the smaller of requested frames or actual audio frames
actual_num_frames = min(num_frames, actual_frames_from_audio)

if actual_frames_from_audio < num_frames:
log.info(f"[LongCat] Audio duration ({actual_frames_from_audio} frames) is shorter than requested ({num_frames} frames). Using {actual_num_frames} frames.")

# Debug: log final mixed audio length and mode
total_samples_raw = sum([ao["waveform"].shape[-1] for ao in audio_outputs])
log.info(f"[LongCat] total raw duration = {total_samples_raw/sr:.3f}s")
log.info(f"[LongCat] multi_audio_type={multi_audio_type} | final waveform shape={out_audio['waveform'].shape} | length={out_audio['waveform'].shape[-1]} samples | seconds={out_audio['waveform'].shape[-1]/sr:.3f}s (expected {'sum' if multi_audio_type=='add' else 'max'} of raw)")


return (multitalk_embeds, out_audio, actual_num_frames)


NODE_CLASS_MAPPINGS = {
Expand All @@ -305,4 +329,4 @@ def linear_interp(features, output_len):
NODE_DISPLAY_NAME_MAPPINGS = {
"WanVideoLongCatAvatarExtendEmbeds": "WanVideo LongCat Avatar Extend Embeds",
"LongCatAvatarWhisperEmbeds": "LongCat Avatar Whisper Embeds (v1.5)",
}
}