mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-06 06:17:38 +08:00
Consolidate audio nodes into SaveAudioAdvanced node (CORE-202) (#13871)
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
This commit is contained in:
parent
514bb8ba21
commit
ab0d8a9203
@ -285,7 +285,7 @@ class AudioSaveHelper:
|
|||||||
results = []
|
results = []
|
||||||
for batch_number, waveform in enumerate(audio["waveform"].cpu()):
|
for batch_number, waveform in enumerate(audio["waveform"].cpu()):
|
||||||
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
|
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
|
||||||
file = f"{filename_with_batch_num}_{counter:05}_.{format}"
|
file = f"{filename_with_batch_num}_{counter:05}.{format}"
|
||||||
output_path = os.path.join(full_output_folder, file)
|
output_path = os.path.join(full_output_folder, file)
|
||||||
|
|
||||||
# Use original sample rate initially
|
# Use original sample rate initially
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class SaveAudio(IO.ComfyNode):
|
|||||||
return IO.Schema(
|
return IO.Schema(
|
||||||
node_id="SaveAudio",
|
node_id="SaveAudio",
|
||||||
search_aliases=["export flac"],
|
search_aliases=["export flac"],
|
||||||
display_name="Save Audio (FLAC)",
|
display_name="Save Audio (FLAC) (Deprecated)",
|
||||||
category="audio",
|
category="audio",
|
||||||
essentials_category="Audio",
|
essentials_category="Audio",
|
||||||
inputs=[
|
inputs=[
|
||||||
@ -167,6 +167,7 @@ class SaveAudio(IO.ComfyNode):
|
|||||||
],
|
],
|
||||||
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
||||||
is_output_node=True,
|
is_output_node=True,
|
||||||
|
is_deprecated=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -186,7 +187,7 @@ class SaveAudioMP3(IO.ComfyNode):
|
|||||||
return IO.Schema(
|
return IO.Schema(
|
||||||
node_id="SaveAudioMP3",
|
node_id="SaveAudioMP3",
|
||||||
search_aliases=["export mp3"],
|
search_aliases=["export mp3"],
|
||||||
display_name="Save Audio (MP3)",
|
display_name="Save Audio (MP3) (Deprecated)",
|
||||||
category="audio",
|
category="audio",
|
||||||
essentials_category="Audio",
|
essentials_category="Audio",
|
||||||
inputs=[
|
inputs=[
|
||||||
@ -196,6 +197,7 @@ class SaveAudioMP3(IO.ComfyNode):
|
|||||||
],
|
],
|
||||||
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
||||||
is_output_node=True,
|
is_output_node=True,
|
||||||
|
is_deprecated=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -217,7 +219,7 @@ class SaveAudioOpus(IO.ComfyNode):
|
|||||||
return IO.Schema(
|
return IO.Schema(
|
||||||
node_id="SaveAudioOpus",
|
node_id="SaveAudioOpus",
|
||||||
search_aliases=["export opus"],
|
search_aliases=["export opus"],
|
||||||
display_name="Save Audio (Opus)",
|
display_name="Save Audio (Opus) (Deprecated)",
|
||||||
category="audio",
|
category="audio",
|
||||||
inputs=[
|
inputs=[
|
||||||
IO.Audio.Input("audio"),
|
IO.Audio.Input("audio"),
|
||||||
@ -226,6 +228,7 @@ class SaveAudioOpus(IO.ComfyNode):
|
|||||||
],
|
],
|
||||||
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
||||||
is_output_node=True,
|
is_output_node=True,
|
||||||
|
is_deprecated=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -241,6 +244,54 @@ class SaveAudioOpus(IO.ComfyNode):
|
|||||||
save_opus = execute # TODO: remove
|
save_opus = execute # TODO: remove
|
||||||
|
|
||||||
|
|
||||||
|
class SaveAudioAdvanced(IO.ComfyNode):
|
||||||
|
@classmethod
|
||||||
|
def define_schema(cls):
|
||||||
|
return IO.Schema(
|
||||||
|
node_id="SaveAudioAdvanced",
|
||||||
|
search_aliases=["save audio", "export audio", "output audio", "write audio", "flac", "mp3", "opus"],
|
||||||
|
display_name="Save Audio (Advanced)",
|
||||||
|
description="Saves the input audio to your ComfyUI output directory.",
|
||||||
|
category="audio",
|
||||||
|
inputs=[
|
||||||
|
IO.Audio.Input("audio", tooltip="The audio to save."),
|
||||||
|
IO.String.Input(
|
||||||
|
"filename_prefix",
|
||||||
|
default="audio/ComfyUI",
|
||||||
|
tooltip=(
|
||||||
|
"The prefix for the file to save. May include formatting tokens "
|
||||||
|
"such as %date:yyyy-MM-dd%."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IO.DynamicCombo.Input(
|
||||||
|
"format",
|
||||||
|
options=[
|
||||||
|
IO.DynamicCombo.Option("flac", []),
|
||||||
|
IO.DynamicCombo.Option("mp3", [
|
||||||
|
IO.Combo.Input("quality", options=["V0", "128k", "320k"], default="V0"),
|
||||||
|
]),
|
||||||
|
IO.DynamicCombo.Option("opus", [
|
||||||
|
IO.Combo.Input("quality", options=["64k", "96k", "128k", "192k", "320k"], default="128k"),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
tooltip="The file format in which to save the audio.",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
|
||||||
|
is_output_node=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def execute(cls, audio, filename_prefix: str, format: dict) -> IO.NodeOutput:
|
||||||
|
file_format = format.get("format", None)
|
||||||
|
quality = format.get("quality", None)
|
||||||
|
if quality:
|
||||||
|
ui=UI.AudioSaveHelper.get_save_audio_ui(audio, filename_prefix=filename_prefix, cls=cls, format=file_format, quality=quality)
|
||||||
|
else:
|
||||||
|
ui=UI.AudioSaveHelper.get_save_audio_ui(audio, filename_prefix=filename_prefix, cls=cls, format=file_format)
|
||||||
|
return IO.NodeOutput(ui=ui)
|
||||||
|
|
||||||
|
|
||||||
class PreviewAudio(IO.ComfyNode):
|
class PreviewAudio(IO.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def define_schema(cls):
|
def define_schema(cls):
|
||||||
@ -822,6 +873,7 @@ class AudioExtension(ComfyExtension):
|
|||||||
SaveAudio,
|
SaveAudio,
|
||||||
SaveAudioMP3,
|
SaveAudioMP3,
|
||||||
SaveAudioOpus,
|
SaveAudioOpus,
|
||||||
|
SaveAudioAdvanced,
|
||||||
LoadAudio,
|
LoadAudio,
|
||||||
PreviewAudio,
|
PreviewAudio,
|
||||||
ConditioningStableAudio,
|
ConditioningStableAudio,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user