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(api-nodes): use a unique name for uploading audio files (#11778)
Alexander Piskun5cd1113236b0
diff --git a/comfy_api_nodes/nodes_kling.py b/comfy_api_nodes/nodes_kling.pyindex 9c707a339..01d9c34f5 100644--- a/comfy_api_nodes/nodes_kling.py+++ b/comfy_api_nodes/nodes_kling.py@@ -567,7 +567,7 @@ async def execute_lipsync(# Upload the audio file to Comfy API and get download URLif audio:audio_url = await upload_audio_to_comfyapi(- cls, audio, container_format="mp3", codec_name="libmp3lame", mime_type="audio/mpeg", filename="output.mp3"+ cls, audio, container_format="mp3", codec_name="libmp3lame", mime_type="audio/mpeg")logging.info("Uploaded audio to Comfy API. URL: %s", audio_url)else:diff --git a/comfy_api_nodes/util/conversions.py b/comfy_api_nodes/util/conversions.pyindex d64239c86..99c302a2a 100644--- a/comfy_api_nodes/util/conversions.py+++ b/comfy_api_nodes/util/conversions.py@@ -55,7 +55,7 @@ def image_tensor_pair_to_batch(image1: torch.Tensor, image2: torch.Tensor) -> todef tensor_to_bytesio(image: torch.Tensor,- name: str | None = None,+ *,total_pixels: int = 2048 * 2048,mime_type: str = "image/png",) -> BytesIO:@@ -75,7 +75,7 @@ def tensor_to_bytesio(pil_image = tensor_to_pil(image, total_pixels=total_pixels)img_binary = pil_to_bytesio(pil_image, mime_type=mime_type)- img_binary.name = f"{name if name else uuid.uuid4()}.{mimetype_to_extension(mime_type)}"+ img_binary.name = f"{uuid.uuid4()}.{mimetype_to_extension(mime_type)}"return img_binarydiff --git a/comfy_api_nodes/util/upload_helpers.py b/comfy_api_nodes/util/upload_helpers.pyindex 2535a0884..cea0d1203 100644--- a/comfy_api_nodes/util/upload_helpers.py+++ b/comfy_api_nodes/util/upload_helpers.py@@ -82,7 +82,6 @@ async def upload_audio_to_comfyapi(container_format: str = "mp4",codec_name: str = "aac",mime_type: str = "audio/mp4",- filename: str = "uploaded_audio.mp4",) -> str:"""Uploads a single audio input to ComfyUI API and returns its download URL.@@ -92,7 +91,7 @@ async def upload_audio_to_comfyapi(waveform: torch.Tensor = audio["waveform"]audio_data_np = audio_tensor_to_contiguous_ndarray(waveform)audio_bytes_io = audio_ndarray_to_bytesio(audio_data_np, sample_rate, container_format, codec_name)- return await upload_file_to_comfyapi(cls, audio_bytes_io, filename, mime_type)+ return await upload_file_to_comfyapi(cls, audio_bytes_io, f"{uuid.uuid4()}.{container_format}", mime_type)async def upload_video_to_comfyapi(