Skip to content

Commit 5cd1113

Browse files
authored
fix(api-nodes): use a unique name for uploading audio files (Comfy-Org#11778)
1 parent 2f642d5 commit 5cd1113

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

comfy_api_nodes/nodes_kling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ async def execute_lipsync(
567567
# Upload the audio file to Comfy API and get download URL
568568
if audio:
569569
audio_url = await upload_audio_to_comfyapi(
570-
cls, audio, container_format="mp3", codec_name="libmp3lame", mime_type="audio/mpeg", filename="output.mp3"
570+
cls, audio, container_format="mp3", codec_name="libmp3lame", mime_type="audio/mpeg"
571571
)
572572
logging.info("Uploaded audio to Comfy API. URL: %s", audio_url)
573573
else:

comfy_api_nodes/util/conversions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def image_tensor_pair_to_batch(image1: torch.Tensor, image2: torch.Tensor) -> to
5555

5656
def tensor_to_bytesio(
5757
image: torch.Tensor,
58-
name: str | None = None,
58+
*,
5959
total_pixels: int = 2048 * 2048,
6060
mime_type: str = "image/png",
6161
) -> BytesIO:
@@ -75,7 +75,7 @@ def tensor_to_bytesio(
7575

7676
pil_image = tensor_to_pil(image, total_pixels=total_pixels)
7777
img_binary = pil_to_bytesio(pil_image, mime_type=mime_type)
78-
img_binary.name = f"{name if name else uuid.uuid4()}.{mimetype_to_extension(mime_type)}"
78+
img_binary.name = f"{uuid.uuid4()}.{mimetype_to_extension(mime_type)}"
7979
return img_binary
8080

8181

comfy_api_nodes/util/upload_helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ async def upload_audio_to_comfyapi(
8282
container_format: str = "mp4",
8383
codec_name: str = "aac",
8484
mime_type: str = "audio/mp4",
85-
filename: str = "uploaded_audio.mp4",
8685
) -> str:
8786
"""
8887
Uploads a single audio input to ComfyUI API and returns its download URL.
@@ -92,7 +91,7 @@ async def upload_audio_to_comfyapi(
9291
waveform: torch.Tensor = audio["waveform"]
9392
audio_data_np = audio_tensor_to_contiguous_ndarray(waveform)
9493
audio_bytes_io = audio_ndarray_to_bytesio(audio_data_np, sample_rate, container_format, codec_name)
95-
return await upload_file_to_comfyapi(cls, audio_bytes_io, filename, mime_type)
94+
return await upload_file_to_comfyapi(cls, audio_bytes_io, f"{uuid.uuid4()}.{container_format}", mime_type)
9695

9796

9897
async def upload_video_to_comfyapi(

0 commit comments

Comments
 (0)