We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 05df2df commit 42974a4Copy full SHA for 42974a4
comfy_api/latest/_ui.py
@@ -9,7 +9,11 @@
9
import av
10
import numpy as np
11
import torch
12
-import torchaudio
+try:
13
+ import torchaudio
14
+ TORCH_AUDIO_AVAILABLE = True
15
+except ImportError:
16
+ TORCH_AUDIO_AVAILABLE = False
17
from PIL import Image as PILImage
18
from PIL.PngImagePlugin import PngInfo
19
@@ -302,6 +306,8 @@ def save_audio(
302
306
303
307
# Resample if necessary
304
308
if sample_rate != audio["sample_rate"]:
309
+ if not TORCH_AUDIO_AVAILABLE:
310
+ raise Exception("torchaudio is not available; cannot resample audio.")
305
311
waveform = torchaudio.functional.resample(waveform, audio["sample_rate"], sample_rate)
312
313
# Create output with specified format
0 commit comments