mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-20 16:07:12 +08:00
Update nodes_audio.py
Converted from 3d to 2d in order to save , it was causing issues
This commit is contained in:
parent
c5a48b15bd
commit
22c9e23a73
@ -137,7 +137,7 @@ class SaveAudio:
|
|||||||
def save_audio(self, audio, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
|
def save_audio(self, audio, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
|
||||||
filename_prefix += self.prefix_append
|
filename_prefix += self.prefix_append
|
||||||
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir)
|
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir)
|
||||||
results = list()
|
results = []
|
||||||
|
|
||||||
metadata = {}
|
metadata = {}
|
||||||
if not args.disable_metadata:
|
if not args.disable_metadata:
|
||||||
@ -151,7 +151,14 @@ class SaveAudio:
|
|||||||
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
|
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
|
||||||
file = f"{filename_with_batch_num}_{counter:05}_.flac"
|
file = f"{filename_with_batch_num}_{counter:05}_.flac"
|
||||||
|
|
||||||
|
# Ensure waveform is a 2D tensor
|
||||||
|
waveform = waveform.squeeze() # Remove single-dimensional entries
|
||||||
|
|
||||||
|
if waveform.ndim == 1:
|
||||||
|
waveform = waveform.unsqueeze(0) # Convert 1D tensor to 2D if needed
|
||||||
|
|
||||||
buff = io.BytesIO()
|
buff = io.BytesIO()
|
||||||
|
waveform = waveform.cpu()
|
||||||
torchaudio.save(buff, waveform, audio["sample_rate"], format="FLAC")
|
torchaudio.save(buff, waveform, audio["sample_rate"], format="FLAC")
|
||||||
|
|
||||||
buff = insert_or_replace_vorbis_comment(buff, metadata)
|
buff = insert_or_replace_vorbis_comment(buff, metadata)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user