Files
ComfyUI-H3-Continuum-Tiled/audio_compat.py
T
ukr8b3g-cmyk 190141e03e fix: stabilize V3.9 and bump package to 3.9.1
Preserve Second Pass audio and scoped Review conditioning, strengthen Take compatibility, and align Review Driving Audio.

Keep v5 history readable, document v6 restart requirements, and describe the fixes at the top of both READMEs. Remove workstation-specific paths and private operational records from public documentation.
2026-10-04 19:05:33 +09:00

30 lines
1.0 KiB
Python

"""Use Core audio DSP; retain the existing adapter for older Core versions."""
from __future__ import annotations
import importlib
def resample_audio(waveform, source_rate: int, target_rate: int):
if source_rate == target_rate:
return waveform
try:
core_audio = importlib.import_module("comfy.audio")
except ModuleNotFoundError as exc:
if exc.name not in {"comfy", "comfy.audio"}:
raise
core_audio = None
core_resample = getattr(core_audio, "resample", None)
if core_resample is not None:
# Errors from an available Core API are real errors, not API absence.
return core_resample(waveform, source_rate, target_rate)
try:
torchaudio = importlib.import_module("torchaudio")
except ModuleNotFoundError as exc:
if exc.name != "torchaudio":
raise
raise RuntimeError(
"Audio resampling requires comfy.audio.resample or legacy torchaudio"
) from exc
return torchaudio.functional.resample(waveform, source_rate, target_rate)