mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-14 13:51:01 +01:00
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.9, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, --use-pytorch-cross-attention, macos, 3.10, [self-hosted macOS], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, --use-pytorch-cross-attention, macos, 3.11, [self-hosted macOS], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, --use-pytorch-cross-attention, macos, 3.12, [self-hosted macOS], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, --use-pytorch-cross-attention, macos, 3.9, [self-hosted macOS], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, --use-pytorch-cross-attention, macos, 3.11, [self-hosted macOS], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
Build package / Build Test (3.10) (push) Has been cancelled
Build package / Build Test (3.11) (push) Has been cancelled
Build package / Build Test (3.12) (push) Has been cancelled
Build package / Build Test (3.13) (push) Has been cancelled
Build package / Build Test (3.9) (push) Has been cancelled
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
import folder_paths
|
|
import comfy.audio_encoders.audio_encoders
|
|
import comfy.utils
|
|
from typing_extensions import override
|
|
from comfy_api.latest import ComfyExtension, io
|
|
|
|
|
|
class AudioEncoderLoader(io.ComfyNode):
|
|
@classmethod
|
|
def define_schema(cls) -> io.Schema:
|
|
return io.Schema(
|
|
node_id="AudioEncoderLoader",
|
|
category="loaders",
|
|
inputs=[
|
|
io.Combo.Input(
|
|
"audio_encoder_name",
|
|
options=folder_paths.get_filename_list("audio_encoders"),
|
|
),
|
|
],
|
|
outputs=[io.AudioEncoder.Output()],
|
|
)
|
|
|
|
@classmethod
|
|
def execute(cls, audio_encoder_name) -> io.NodeOutput:
|
|
audio_encoder_name = folder_paths.get_full_path_or_raise("audio_encoders", audio_encoder_name)
|
|
sd = comfy.utils.load_torch_file(audio_encoder_name, safe_load=True)
|
|
audio_encoder = comfy.audio_encoders.audio_encoders.load_audio_encoder_from_sd(sd)
|
|
if audio_encoder is None:
|
|
raise RuntimeError("ERROR: audio encoder file is invalid and does not contain a valid model.")
|
|
return io.NodeOutput(audio_encoder)
|
|
|
|
|
|
class AudioEncoderEncode(io.ComfyNode):
|
|
@classmethod
|
|
def define_schema(cls) -> io.Schema:
|
|
return io.Schema(
|
|
node_id="AudioEncoderEncode",
|
|
category="conditioning",
|
|
inputs=[
|
|
io.AudioEncoder.Input("audio_encoder"),
|
|
io.Audio.Input("audio"),
|
|
],
|
|
outputs=[io.AudioEncoderOutput.Output()],
|
|
)
|
|
|
|
@classmethod
|
|
def execute(cls, audio_encoder, audio) -> io.NodeOutput:
|
|
output = audio_encoder.encode_audio(audio["waveform"], audio["sample_rate"])
|
|
return io.NodeOutput(output)
|
|
|
|
|
|
class AudioEncoder(ComfyExtension):
|
|
@override
|
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
|
return [
|
|
AudioEncoderLoader,
|
|
AudioEncoderEncode,
|
|
]
|
|
|
|
|
|
async def comfy_entrypoint() -> AudioEncoder:
|
|
return AudioEncoder()
|