The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix save audio nodes saving mono audio as stereo. (#10289)
comfyanonymouscdfc25a1605a
diff --git a/comfy_extras/nodes_audio.py b/comfy_extras/nodes_audio.pyindex 1c868fcba..2ed7e0b22 100644--- a/comfy_extras/nodes_audio.py+++ b/comfy_extras/nodes_audio.py@@ -142,9 +142,10 @@ def save_audio(self, audio, filename_prefix="ComfyUI", format="flac", prompt=Nonfor key, value in metadata.items():output_container.metadata[key] = value+ layout = 'mono' if waveform.shape[0] == 1 else 'stereo'# Set up the output stream with appropriate propertiesif format == "opus":- out_stream = output_container.add_stream("libopus", rate=sample_rate)+ out_stream = output_container.add_stream("libopus", rate=sample_rate, layout=layout)if quality == "64k":out_stream.bit_rate = 64000elif quality == "96k":@@ -156,7 +157,7 @@ def save_audio(self, audio, filename_prefix="ComfyUI", format="flac", prompt=Nonelif quality == "320k":out_stream.bit_rate = 320000elif format == "mp3":- out_stream = output_container.add_stream("libmp3lame", rate=sample_rate)+ out_stream = output_container.add_stream("libmp3lame", rate=sample_rate, layout=layout)if quality == "V0":#TODO i would really love to support V3 and V5 but there doesn't seem to be a way to set the qscale level, the property below is a boolout_stream.codec_context.qscale = 1@@ -165,9 +166,9 @@ def save_audio(self, audio, filename_prefix="ComfyUI", format="flac", prompt=Nonelif quality == "320k":out_stream.bit_rate = 320000else: #format == "flac":- out_stream = output_container.add_stream("flac", rate=sample_rate)+ out_stream = output_container.add_stream("flac", rate=sample_rate, layout=layout)- frame = av.AudioFrame.from_ndarray(waveform.movedim(0, 1).reshape(1, -1).float().numpy(), format='flt', layout='mono' if waveform.shape[0] == 1 else 'stereo')+ frame = av.AudioFrame.from_ndarray(waveform.movedim(0, 1).reshape(1, -1).float().numpy(), format='flt', layout=layout)frame.sample_rate = sample_rateframe.pts = 0output_container.mux(out_stream.encode(frame))