Update nodes_audio.py

Converted from 3d to 2d in order to save , it was causing issues
This commit is contained in:
3blackbar 2024-07-17 02:07:19 +02:00 committed by GitHub
parent c5a48b15bd
commit 22c9e23a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -137,7 +137,7 @@ class SaveAudio:
def save_audio(self, audio, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
filename_prefix += self.prefix_append
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir)
results = list()
results = []
metadata = {}
if not args.disable_metadata:
@ -151,7 +151,14 @@ class SaveAudio:
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
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()
waveform = waveform.cpu()
torchaudio.save(buff, waveform, audio["sample_rate"], format="FLAC")
buff = insert_or_replace_vorbis_comment(buff, metadata)