From c4d9905293689a5fb9efd137eb479ec3e6c25b5f Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Wed, 7 May 2025 08:04:29 -0400 Subject: [PATCH] Forgot this. --- comfy_extras/nodes_ace.py | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 comfy_extras/nodes_ace.py diff --git a/comfy_extras/nodes_ace.py b/comfy_extras/nodes_ace.py new file mode 100644 index 000000000..36eb999d1 --- /dev/null +++ b/comfy_extras/nodes_ace.py @@ -0,0 +1,46 @@ +import torch +import comfy.model_management + + +class TextEncodeAceStepAudio: + @classmethod + def INPUT_TYPES(s): + return {"required": { + "clip": ("CLIP", ), + "tags": ("STRING", {"multiline": True, "dynamicPrompts": True}), + "lyrics": ("STRING", {"multiline": True, "dynamicPrompts": True}), + }} + RETURN_TYPES = ("CONDITIONING",) + FUNCTION = "encode" + + CATEGORY = "conditioning" + + def encode(self, clip, tags, lyrics): + tokens = clip.tokenize(tags, lyrics=lyrics) + return (clip.encode_from_tokens_scheduled(tokens), ) + + +class EmptyAceStepLatentAudio: + def __init__(self): + self.device = comfy.model_management.intermediate_device() + + @classmethod + def INPUT_TYPES(s): + return {"required": {"seconds": ("FLOAT", {"default": 120.0, "min": 1.0, "max": 1000.0, "step": 0.1}), + "batch_size": ("INT", {"default": 1, "min": 1, "max": 4096, "tooltip": "The number of latent images in the batch."}), + }} + RETURN_TYPES = ("LATENT",) + FUNCTION = "generate" + + CATEGORY = "latent/audio" + + def generate(self, seconds, batch_size): + length = int(seconds * 44100 / 512 / 8) + latent = torch.zeros([batch_size, 8, 16, length], device=self.device) + return ({"samples": latent, "type": "audio"}, ) + + +NODE_CLASS_MAPPINGS = { + "TextEncodeAceStepAudio": TextEncodeAceStepAudio, + "EmptyAceStepLatentAudio": EmptyAceStepLatentAudio, +}