Skip to content

Commit bf01579

Browse files
committed
Merge branch 'master' into dr-support-pip-cm
2 parents ab1a79a + 42974a4 commit bf01579

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

comfy_api/latest/_ui.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import av
1010
import numpy as np
1111
import torch
12-
import torchaudio
12+
try:
13+
import torchaudio
14+
TORCH_AUDIO_AVAILABLE = True
15+
except ImportError:
16+
TORCH_AUDIO_AVAILABLE = False
1317
from PIL import Image as PILImage
1418
from PIL.PngImagePlugin import PngInfo
1519

@@ -302,6 +306,8 @@ def save_audio(
302306

303307
# Resample if necessary
304308
if sample_rate != audio["sample_rate"]:
309+
if not TORCH_AUDIO_AVAILABLE:
310+
raise Exception("torchaudio is not available; cannot resample audio.")
305311
waveform = torchaudio.functional.resample(waveform, audio["sample_rate"], sample_rate)
306312

307313
# Create output with specified format

nodes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,12 +1232,12 @@ def repeat(self, samples, amount):
12321232
s = samples.copy()
12331233
s_in = samples["samples"]
12341234

1235-
s["samples"] = s_in.repeat((amount, 1,1,1))
1235+
s["samples"] = s_in.repeat((amount,) + ((1,) * (s_in.ndim - 1)))
12361236
if "noise_mask" in samples and samples["noise_mask"].shape[0] > 1:
12371237
masks = samples["noise_mask"]
12381238
if masks.shape[0] < s_in.shape[0]:
1239-
masks = masks.repeat(math.ceil(s_in.shape[0] / masks.shape[0]), 1, 1, 1)[:s_in.shape[0]]
1240-
s["noise_mask"] = samples["noise_mask"].repeat((amount, 1,1,1))
1239+
masks = masks.repeat((math.ceil(s_in.shape[0] / masks.shape[0]),) + ((1,) * (masks.ndim - 1)))[:s_in.shape[0]]
1240+
s["noise_mask"] = samples["noise_mask"].repeat((amount,) + ((1,) * (samples["noise_mask"].ndim - 1)))
12411241
if "batch_index" in s:
12421242
offset = max(s["batch_index"]) - min(s["batch_index"]) + 1
12431243
s["batch_index"] = s["batch_index"] + [x + (i * offset) for i in range(1, amount) for x in s["batch_index"]]

0 commit comments

Comments
 (0)