mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-08-13 08:36:40 +00:00
_ui.py import torchaudio safety check (#9234)
* Added safety around torchaudio import in _ui.py * Trusted cursor too much, fixed torchaudio bool
This commit is contained in:
parent
05df2df489
commit
42974a448c
@ -9,7 +9,11 @@ from typing import Type
|
||||
import av
|
||||
import numpy as np
|
||||
import torch
|
||||
import torchaudio
|
||||
try:
|
||||
import torchaudio
|
||||
TORCH_AUDIO_AVAILABLE = True
|
||||
except ImportError:
|
||||
TORCH_AUDIO_AVAILABLE = False
|
||||
from PIL import Image as PILImage
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
|
||||
@ -302,6 +306,8 @@ class AudioSaveHelper:
|
||||
|
||||
# Resample if necessary
|
||||
if sample_rate != audio["sample_rate"]:
|
||||
if not TORCH_AUDIO_AVAILABLE:
|
||||
raise Exception("torchaudio is not available; cannot resample audio.")
|
||||
waveform = torchaudio.functional.resample(waveform, audio["sample_rate"], sample_rate)
|
||||
|
||||
# Create output with specified format
|
||||
|
Loading…
x
Reference in New Issue
Block a user