diff --git a/__init__.py b/__init__.py index 41eb4a2..8adbb8e 100644 --- a/__init__.py +++ b/__init__.py @@ -8,13 +8,21 @@ A comprehensive toolkit for ComfyUI that provides various utility nodes for imag :license: MIT, see LICENSE for more details. """ -__version__ = "1.3.0" +__version__ = "1.3.1" __author__ = "CyberDickLang" __email__ = "286878701@qq.com" __url__ = "https://github.com/whmc76" # 更新日志 CHANGELOG = { + "1.3.1": [ + "修复Audio Crop Process节点duration=0时的裁剪逻辑:", + "- 修复当duration_seconds为0时仍会进行音频裁剪的问题", + "- 优化裁剪逻辑:只有当duration大于0时才进行裁剪", + "- 支持duration=0且offset>0时只应用offset裁剪", + "- 支持duration=0且offset=0时不进行任何裁剪,保持原始音频", + "- 提升音频处理节点的用户体验和功能准确性", + ], "1.3.0": [ "改进Image Remove Alpha节点和优化专业产品图预设:", "- 改进Image Remove Alpha (UTK)节点:将background_color参数从手动输入改为预设颜色下拉菜单", diff --git a/nodes/audio/audio_crop_process.py b/nodes/audio/audio_crop_process.py index b47be37..aee37bb 100644 --- a/nodes/audio/audio_crop_process.py +++ b/nodes/audio/audio_crop_process.py @@ -52,13 +52,16 @@ class AudioCropProcessUTK: waveform = audio["waveform"] # [B, C, N] sample_rate = int(audio["sample_rate"]) # 裁剪offset和duration - start = int(offset_seconds * sample_rate) - end = ( - int(start + duration_seconds * sample_rate) - if duration_seconds > 0 - else waveform.shape[2] - ) - waveform = waveform[:, :, start:end] + if duration_seconds > 0: + # 只有当duration大于0时才进行裁剪 + start = int(offset_seconds * sample_rate) + end = int(start + duration_seconds * sample_rate) + waveform = waveform[:, :, start:end] + elif offset_seconds > 0: + # 如果duration为0但offset大于0,只应用offset裁剪 + start = int(offset_seconds * sample_rate) + waveform = waveform[:, :, start:] + # 如果duration和offset都为0,则不进行任何裁剪 # 重采样 if resample_to_hz > 0 and int(resample_to_hz) != sample_rate: import torchaudio diff --git a/pyproject.toml b/pyproject.toml index 666559a..8418ed9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "universaltoolkit" description = "A comprehensive toolkit based on ComfyUI, providing image, mask, audio, and tools nodes, fully modular and v3 compatible." -version = "1.2.10" +version = "1.3.1" license = {file = "LICENSE"} dependencies = [ "torch",