Spaces:
Sleeping
Sleeping
add docs and serve mode
Browse files- .env.example +2 -2
- .gitignore +2 -1
- acestep/acestep_v15_pipeline.py +49 -0
- acestep/gradio_ui/events/results_handlers.py +19 -8
- acestep/gradio_ui/interfaces/__init__.py +2 -1
- acestep/gradio_ui/interfaces/generation.py +30 -21
- acestep/gradio_ui/interfaces/training.py +6 -2
- acestep/inference.py +1 -1
- API.md → docs/en/API.md +349 -54
- docs/en/GRADIO_GUIDE.md +551 -0
- INFERENCE.md → docs/en/INFERENCE.md +386 -70
- docs/ja/API.md +570 -0
- docs/ja/GRADIO_GUIDE.md +551 -0
- docs/ja/INFERENCE.md +739 -0
- docs/zh/API.md +570 -0
- docs/zh/GRADIO_GUIDE.md +551 -0
- docs/zh/INFERENCE.md +1049 -0
.env.example
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
ACESTEP_CONFIG_PATH=acestep-v15-turbo
|
| 2 |
-
ACESTEP_LM_MODEL_PATH=acestep-5Hz-lm-
|
| 3 |
ACESTEP_DEVICE=auto
|
| 4 |
ACESTEP_LM_BACKEND=vllm
|
|
|
|
| 1 |
+
ACESTEP_CONFIG_PATH=acestep-v15-turbo
|
| 2 |
+
ACESTEP_LM_MODEL_PATH=acestep-5Hz-lm-1.7B
|
| 3 |
ACESTEP_DEVICE=auto
|
| 4 |
ACESTEP_LM_BACKEND=vllm
|
.gitignore
CHANGED
|
@@ -224,4 +224,5 @@ scripts/
|
|
| 224 |
checkpoints_legacy/
|
| 225 |
lora_output/
|
| 226 |
datasets/
|
| 227 |
-
python_embeded/
|
|
|
|
|
|
| 224 |
checkpoints_legacy/
|
| 225 |
lora_output/
|
| 226 |
datasets/
|
| 227 |
+
python_embeded/
|
| 228 |
+
checkpoints_pack/
|
acestep/acestep_v15_pipeline.py
CHANGED
|
@@ -5,6 +5,27 @@ Handler wrapper connecting model and UI
|
|
| 5 |
import os
|
| 6 |
import sys
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Clear proxy settings that may affect Gradio
|
| 9 |
for proxy_var in ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY']:
|
| 10 |
os.environ.pop(proxy_var, None)
|
|
@@ -101,6 +122,10 @@ def main():
|
|
| 101 |
parser.add_argument("--server-name", type=str, default="127.0.0.1", help="Server name (default: 127.0.0.1, use 0.0.0.0 for all interfaces)")
|
| 102 |
parser.add_argument("--language", type=str, default="en", choices=["en", "zh", "ja"], help="UI language: en (English), zh (中文), ja (日本語)")
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
# Service initialization arguments
|
| 105 |
parser.add_argument("--init_service", type=lambda x: x.lower() in ['true', '1', 'yes'], default=False, help="Initialize service on startup (default: False)")
|
| 106 |
parser.add_argument("--checkpoint", type=str, default=None, help="Checkpoint file path (optional, for display purposes)")
|
|
@@ -115,6 +140,29 @@ def main():
|
|
| 115 |
|
| 116 |
args = parser.parse_args()
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
try:
|
| 119 |
init_params = None
|
| 120 |
|
|
@@ -198,6 +246,7 @@ def main():
|
|
| 198 |
# Prepare initialization parameters for UI
|
| 199 |
init_params = {
|
| 200 |
'pre_initialized': True,
|
|
|
|
| 201 |
'checkpoint': args.checkpoint,
|
| 202 |
'config_path': args.config_path,
|
| 203 |
'device': args.device,
|
|
|
|
| 5 |
import os
|
| 6 |
import sys
|
| 7 |
|
| 8 |
+
# Load environment variables from .env file in project root
|
| 9 |
+
# This allows configuration without hardcoding values
|
| 10 |
+
# Falls back to .env.example if .env is not found
|
| 11 |
+
try:
|
| 12 |
+
from dotenv import load_dotenv
|
| 13 |
+
# Get project root directory
|
| 14 |
+
_current_file = os.path.abspath(__file__)
|
| 15 |
+
_project_root = os.path.dirname(os.path.dirname(_current_file))
|
| 16 |
+
_env_path = os.path.join(_project_root, '.env')
|
| 17 |
+
_env_example_path = os.path.join(_project_root, '.env.example')
|
| 18 |
+
|
| 19 |
+
if os.path.exists(_env_path):
|
| 20 |
+
load_dotenv(_env_path)
|
| 21 |
+
print(f"Loaded configuration from {_env_path}")
|
| 22 |
+
elif os.path.exists(_env_example_path):
|
| 23 |
+
load_dotenv(_env_example_path)
|
| 24 |
+
print(f"Loaded configuration from {_env_example_path} (fallback)")
|
| 25 |
+
except ImportError:
|
| 26 |
+
# python-dotenv not installed, skip loading .env
|
| 27 |
+
pass
|
| 28 |
+
|
| 29 |
# Clear proxy settings that may affect Gradio
|
| 30 |
for proxy_var in ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY']:
|
| 31 |
os.environ.pop(proxy_var, None)
|
|
|
|
| 122 |
parser.add_argument("--server-name", type=str, default="127.0.0.1", help="Server name (default: 127.0.0.1, use 0.0.0.0 for all interfaces)")
|
| 123 |
parser.add_argument("--language", type=str, default="en", choices=["en", "zh", "ja"], help="UI language: en (English), zh (中文), ja (日本語)")
|
| 124 |
|
| 125 |
+
# Service mode argument
|
| 126 |
+
parser.add_argument("--service_mode", type=lambda x: x.lower() in ['true', '1', 'yes'], default=False,
|
| 127 |
+
help="Enable service mode (default: False). When enabled, uses preset models and restricts UI options.")
|
| 128 |
+
|
| 129 |
# Service initialization arguments
|
| 130 |
parser.add_argument("--init_service", type=lambda x: x.lower() in ['true', '1', 'yes'], default=False, help="Initialize service on startup (default: False)")
|
| 131 |
parser.add_argument("--checkpoint", type=str, default=None, help="Checkpoint file path (optional, for display purposes)")
|
|
|
|
| 140 |
|
| 141 |
args = parser.parse_args()
|
| 142 |
|
| 143 |
+
# Service mode defaults (can be configured via .env file)
|
| 144 |
+
if args.service_mode:
|
| 145 |
+
print("Service mode enabled - applying preset configurations...")
|
| 146 |
+
# Force init_service in service mode
|
| 147 |
+
args.init_service = True
|
| 148 |
+
# Default DiT model for service mode (from env or fallback)
|
| 149 |
+
if args.config_path is None:
|
| 150 |
+
args.config_path = os.environ.get(
|
| 151 |
+
"SERVICE_MODE_DIT_MODEL",
|
| 152 |
+
"acestep-v15-turbo-fix-inst-shift-dynamic"
|
| 153 |
+
)
|
| 154 |
+
# Default LM model for service mode (from env or fallback)
|
| 155 |
+
if args.lm_model_path is None:
|
| 156 |
+
args.lm_model_path = os.environ.get(
|
| 157 |
+
"SERVICE_MODE_LM_MODEL",
|
| 158 |
+
"acestep-5Hz-lm-1.7B-v4-fix"
|
| 159 |
+
)
|
| 160 |
+
# Backend for service mode (from env or fallback to vllm)
|
| 161 |
+
args.backend = os.environ.get("SERVICE_MODE_BACKEND", "vllm")
|
| 162 |
+
print(f" DiT model: {args.config_path}")
|
| 163 |
+
print(f" LM model: {args.lm_model_path}")
|
| 164 |
+
print(f" Backend: {args.backend}")
|
| 165 |
+
|
| 166 |
try:
|
| 167 |
init_params = None
|
| 168 |
|
|
|
|
| 246 |
# Prepare initialization parameters for UI
|
| 247 |
init_params = {
|
| 248 |
'pre_initialized': True,
|
| 249 |
+
'service_mode': args.service_mode,
|
| 250 |
'checkpoint': args.checkpoint,
|
| 251 |
'config_path': args.config_path,
|
| 252 |
'device': args.device,
|
acestep/gradio_ui/events/results_handlers.py
CHANGED
|
@@ -266,7 +266,18 @@ def _build_generation_info(
|
|
| 266 |
"""
|
| 267 |
info_parts = []
|
| 268 |
|
| 269 |
-
# Part 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
if lm_metadata:
|
| 271 |
metadata_lines = []
|
| 272 |
if lm_metadata.get('bpm'):
|
|
@@ -288,7 +299,7 @@ def _build_generation_info(
|
|
| 288 |
metadata_section = "**🤖 LM-Generated Metadata:**\n" + "\n".join(metadata_lines)
|
| 289 |
info_parts.append(metadata_section)
|
| 290 |
|
| 291 |
-
# Part
|
| 292 |
if time_costs:
|
| 293 |
time_lines = []
|
| 294 |
|
|
@@ -337,16 +348,11 @@ def _build_generation_info(
|
|
| 337 |
if auto_lrc_time > 0:
|
| 338 |
time_lines.append(f" - Auto LRC: {auto_lrc_time:.2f}s")
|
| 339 |
|
| 340 |
-
# Pipeline total
|
| 341 |
-
pipeline_total = time_costs.get('pipeline_total_time', 0.0)
|
| 342 |
-
if pipeline_total > 0:
|
| 343 |
-
time_lines.append(f"\n**⏱️ Pipeline Total: {pipeline_total:.2f}s**")
|
| 344 |
-
|
| 345 |
if time_lines:
|
| 346 |
time_section = "\n".join(time_lines)
|
| 347 |
info_parts.append(time_section)
|
| 348 |
|
| 349 |
-
# Part
|
| 350 |
summary_lines = [
|
| 351 |
"**🎵 Generation Complete**",
|
| 352 |
f" - **Seeds:** {seed_value}",
|
|
@@ -355,6 +361,11 @@ def _build_generation_info(
|
|
| 355 |
]
|
| 356 |
info_parts.append("\n".join(summary_lines))
|
| 357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
# Combine all parts
|
| 359 |
return "\n\n".join(info_parts)
|
| 360 |
|
|
|
|
| 266 |
"""
|
| 267 |
info_parts = []
|
| 268 |
|
| 269 |
+
# Part 1: Per-track average time (prominently displayed at the top)
|
| 270 |
+
# Only count model time (LM + DiT), not post-processing like audio conversion
|
| 271 |
+
if time_costs and num_audios > 0:
|
| 272 |
+
lm_total = time_costs.get('lm_total_time', 0.0)
|
| 273 |
+
dit_total = time_costs.get('dit_total_time_cost', 0.0)
|
| 274 |
+
model_total = lm_total + dit_total
|
| 275 |
+
if model_total > 0:
|
| 276 |
+
avg_time_per_track = model_total / num_audios
|
| 277 |
+
avg_section = f"**🎯 Average Time per Track: {avg_time_per_track:.2f}s** ({num_audios} track(s))"
|
| 278 |
+
info_parts.append(avg_section)
|
| 279 |
+
|
| 280 |
+
# Part 2: LM-generated metadata (if available)
|
| 281 |
if lm_metadata:
|
| 282 |
metadata_lines = []
|
| 283 |
if lm_metadata.get('bpm'):
|
|
|
|
| 299 |
metadata_section = "**🤖 LM-Generated Metadata:**\n" + "\n".join(metadata_lines)
|
| 300 |
info_parts.append(metadata_section)
|
| 301 |
|
| 302 |
+
# Part 3: Time costs breakdown (formatted and beautified)
|
| 303 |
if time_costs:
|
| 304 |
time_lines = []
|
| 305 |
|
|
|
|
| 348 |
if auto_lrc_time > 0:
|
| 349 |
time_lines.append(f" - Auto LRC: {auto_lrc_time:.2f}s")
|
| 350 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if time_lines:
|
| 352 |
time_section = "\n".join(time_lines)
|
| 353 |
info_parts.append(time_section)
|
| 354 |
|
| 355 |
+
# Part 4: Generation summary
|
| 356 |
summary_lines = [
|
| 357 |
"**🎵 Generation Complete**",
|
| 358 |
f" - **Seeds:** {seed_value}",
|
|
|
|
| 361 |
]
|
| 362 |
info_parts.append("\n".join(summary_lines))
|
| 363 |
|
| 364 |
+
# Part 5: Pipeline total time (at the end)
|
| 365 |
+
pipeline_total = time_costs.get('pipeline_total_time', 0.0) if time_costs else 0.0
|
| 366 |
+
if pipeline_total > 0:
|
| 367 |
+
info_parts.append(f"**⏱️ Total Time: {pipeline_total:.2f}s**")
|
| 368 |
+
|
| 369 |
# Combine all parts
|
| 370 |
return "\n\n".join(info_parts)
|
| 371 |
|
acestep/gradio_ui/interfaces/__init__.py
CHANGED
|
@@ -78,7 +78,8 @@ def create_gradio_interface(dit_handler, llm_handler, dataset_handler, init_para
|
|
| 78 |
results_section = create_results_section(dit_handler)
|
| 79 |
|
| 80 |
# Training Section (LoRA training and dataset builder)
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
# Connect event handlers
|
| 84 |
setup_event_handlers(demo, dit_handler, llm_handler, dataset_handler, dataset_section, generation_section, results_section)
|
|
|
|
| 78 |
results_section = create_results_section(dit_handler)
|
| 79 |
|
| 80 |
# Training Section (LoRA training and dataset builder)
|
| 81 |
+
# Pass init_params to support hiding in service mode
|
| 82 |
+
training_section = create_training_section(dit_handler, llm_handler, init_params=init_params)
|
| 83 |
|
| 84 |
# Connect event handlers
|
| 85 |
setup_event_handlers(demo, dit_handler, llm_handler, dataset_handler, dataset_section, generation_section, results_section)
|
acestep/gradio_ui/interfaces/generation.py
CHANGED
|
@@ -26,6 +26,9 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 26 |
# Check if service is pre-initialized
|
| 27 |
service_pre_initialized = init_params is not None and init_params.get('pre_initialized', False)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
# Get current language from init_params if available
|
| 30 |
current_language = init_params.get('language', language) if init_params else language
|
| 31 |
|
|
@@ -175,9 +178,11 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 175 |
with gr.Column(scale=2):
|
| 176 |
with gr.Accordion(t("generation.required_inputs"), open=True):
|
| 177 |
# Task type
|
| 178 |
-
# Determine initial task_type choices based on
|
| 179 |
-
|
| 180 |
-
if
|
|
|
|
|
|
|
| 181 |
initial_task_choices = TASK_TYPES_TURBO
|
| 182 |
else:
|
| 183 |
initial_task_choices = TASK_TYPES_BASE
|
|
@@ -277,19 +282,20 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 277 |
)
|
| 278 |
|
| 279 |
# Simple/Custom Mode Toggle
|
| 280 |
-
|
|
|
|
| 281 |
generation_mode = gr.Radio(
|
| 282 |
choices=[
|
| 283 |
(t("generation.mode_simple"), "simple"),
|
| 284 |
(t("generation.mode_custom"), "custom"),
|
| 285 |
],
|
| 286 |
-
value="simple",
|
| 287 |
label=t("generation.mode_label"),
|
| 288 |
info=t("generation.mode_info"),
|
| 289 |
)
|
| 290 |
|
| 291 |
-
# Simple Mode Components -
|
| 292 |
-
with gr.Group(visible=
|
| 293 |
with gr.Row(equal_height=True):
|
| 294 |
simple_query_input = gr.Textbox(
|
| 295 |
label=t("generation.simple_query_label"),
|
|
@@ -332,7 +338,8 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 332 |
simple_sample_created = gr.State(value=False)
|
| 333 |
|
| 334 |
# Music Caption - wrapped in accordion that can be collapsed in Simple mode
|
| 335 |
-
|
|
|
|
| 336 |
with gr.Row(equal_height=True):
|
| 337 |
captions = gr.Textbox(
|
| 338 |
label=t("generation.caption_label"),
|
|
@@ -349,7 +356,8 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 349 |
scale=2,
|
| 350 |
)
|
| 351 |
# Lyrics - wrapped in accordion that can be collapsed in Simple mode
|
| 352 |
-
|
|
|
|
| 353 |
lyrics = gr.Textbox(
|
| 354 |
label=t("generation.lyrics_label"),
|
| 355 |
placeholder=t("generation.lyrics_placeholder"),
|
|
@@ -388,7 +396,8 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 388 |
)
|
| 389 |
|
| 390 |
# Optional Parameters
|
| 391 |
-
|
|
|
|
| 392 |
with gr.Row():
|
| 393 |
bpm = gr.Number(
|
| 394 |
label=t("generation.bpm_label"),
|
|
@@ -423,7 +432,8 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 423 |
minimum=1,
|
| 424 |
maximum=8,
|
| 425 |
step=1,
|
| 426 |
-
info=t("generation.batch_size_info")
|
|
|
|
| 427 |
)
|
| 428 |
|
| 429 |
# Advanced Settings
|
|
@@ -463,7 +473,8 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 463 |
choices=["mp3", "flac"],
|
| 464 |
value="mp3",
|
| 465 |
label=t("generation.audio_format_label"),
|
| 466 |
-
info=t("generation.audio_format_info")
|
|
|
|
| 467 |
)
|
| 468 |
|
| 469 |
with gr.Row():
|
|
@@ -583,6 +594,7 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 583 |
value=False,
|
| 584 |
info=t("generation.constrained_debug_info"),
|
| 585 |
scale=1,
|
|
|
|
| 586 |
)
|
| 587 |
|
| 588 |
with gr.Row():
|
|
@@ -591,12 +603,14 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 591 |
value=False,
|
| 592 |
info=t("generation.auto_score_info"),
|
| 593 |
scale=1,
|
|
|
|
| 594 |
)
|
| 595 |
auto_lrc = gr.Checkbox(
|
| 596 |
label=t("generation.auto_lrc_label"),
|
| 597 |
value=False,
|
| 598 |
info=t("generation.auto_lrc_info"),
|
| 599 |
scale=1,
|
|
|
|
| 600 |
)
|
| 601 |
lm_batch_chunk_size = gr.Number(
|
| 602 |
label=t("generation.lm_batch_chunk_label"),
|
|
@@ -606,6 +620,7 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 606 |
step=1,
|
| 607 |
info=t("generation.lm_batch_chunk_info"),
|
| 608 |
scale=1,
|
|
|
|
| 609 |
)
|
| 610 |
|
| 611 |
with gr.Row():
|
|
@@ -626,13 +641,7 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 626 |
label=t("generation.score_sensitivity_label"),
|
| 627 |
info=t("generation.score_sensitivity_info"),
|
| 628 |
scale=1,
|
| 629 |
-
|
| 630 |
-
output_alignment_preference = gr.Checkbox(
|
| 631 |
-
label=t("generation.attention_focus_label"),
|
| 632 |
-
value=False,
|
| 633 |
-
info=t("generation.attention_focus_info"),
|
| 634 |
-
interactive=False,
|
| 635 |
-
scale=1,
|
| 636 |
)
|
| 637 |
|
| 638 |
# Set generate_btn to interactive if service is pre-initialized
|
|
@@ -654,8 +663,9 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 654 |
with gr.Column(scale=1, variant="compact"):
|
| 655 |
autogen_checkbox = gr.Checkbox(
|
| 656 |
label=t("generation.autogen_label"),
|
| 657 |
-
value=
|
| 658 |
scale=1,
|
|
|
|
| 659 |
)
|
| 660 |
use_cot_caption = gr.Checkbox(
|
| 661 |
label=t("generation.caption_rewrite_label"),
|
|
@@ -741,7 +751,6 @@ def create_generation_section(dit_handler, llm_handler, init_params=None, langua
|
|
| 741 |
"infer_method": infer_method,
|
| 742 |
"custom_timesteps": custom_timesteps,
|
| 743 |
"audio_format": audio_format,
|
| 744 |
-
"output_alignment_preference": output_alignment_preference,
|
| 745 |
"think_checkbox": think_checkbox,
|
| 746 |
"autogen_checkbox": autogen_checkbox,
|
| 747 |
"generate_btn": generate_btn,
|
|
|
|
| 26 |
# Check if service is pre-initialized
|
| 27 |
service_pre_initialized = init_params is not None and init_params.get('pre_initialized', False)
|
| 28 |
|
| 29 |
+
# Check if running in service mode (restricted UI)
|
| 30 |
+
service_mode = init_params is not None and init_params.get('service_mode', False)
|
| 31 |
+
|
| 32 |
# Get current language from init_params if available
|
| 33 |
current_language = init_params.get('language', language) if init_params else language
|
| 34 |
|
|
|
|
| 178 |
with gr.Column(scale=2):
|
| 179 |
with gr.Accordion(t("generation.required_inputs"), open=True):
|
| 180 |
# Task type
|
| 181 |
+
# Determine initial task_type choices based on actual model in use
|
| 182 |
+
# When service is pre-initialized, use config_path from init_params
|
| 183 |
+
actual_model = init_params.get('config_path', default_model) if service_pre_initialized else default_model
|
| 184 |
+
actual_model_lower = (actual_model or "").lower()
|
| 185 |
+
if "turbo" in actual_model_lower:
|
| 186 |
initial_task_choices = TASK_TYPES_TURBO
|
| 187 |
else:
|
| 188 |
initial_task_choices = TASK_TYPES_BASE
|
|
|
|
| 282 |
)
|
| 283 |
|
| 284 |
# Simple/Custom Mode Toggle
|
| 285 |
+
# In service mode: only Custom mode, hide the toggle
|
| 286 |
+
with gr.Row(visible=not service_mode):
|
| 287 |
generation_mode = gr.Radio(
|
| 288 |
choices=[
|
| 289 |
(t("generation.mode_simple"), "simple"),
|
| 290 |
(t("generation.mode_custom"), "custom"),
|
| 291 |
],
|
| 292 |
+
value="custom" if service_mode else "simple",
|
| 293 |
label=t("generation.mode_label"),
|
| 294 |
info=t("generation.mode_info"),
|
| 295 |
)
|
| 296 |
|
| 297 |
+
# Simple Mode Components - hidden in service mode
|
| 298 |
+
with gr.Group(visible=not service_mode) as simple_mode_group:
|
| 299 |
with gr.Row(equal_height=True):
|
| 300 |
simple_query_input = gr.Textbox(
|
| 301 |
label=t("generation.simple_query_label"),
|
|
|
|
| 338 |
simple_sample_created = gr.State(value=False)
|
| 339 |
|
| 340 |
# Music Caption - wrapped in accordion that can be collapsed in Simple mode
|
| 341 |
+
# In service mode: auto-expand
|
| 342 |
+
with gr.Accordion(t("generation.caption_title"), open=service_mode) as caption_accordion:
|
| 343 |
with gr.Row(equal_height=True):
|
| 344 |
captions = gr.Textbox(
|
| 345 |
label=t("generation.caption_label"),
|
|
|
|
| 356 |
scale=2,
|
| 357 |
)
|
| 358 |
# Lyrics - wrapped in accordion that can be collapsed in Simple mode
|
| 359 |
+
# In service mode: auto-expand
|
| 360 |
+
with gr.Accordion(t("generation.lyrics_title"), open=service_mode) as lyrics_accordion:
|
| 361 |
lyrics = gr.Textbox(
|
| 362 |
label=t("generation.lyrics_label"),
|
| 363 |
placeholder=t("generation.lyrics_placeholder"),
|
|
|
|
| 396 |
)
|
| 397 |
|
| 398 |
# Optional Parameters
|
| 399 |
+
# In service mode: auto-expand
|
| 400 |
+
with gr.Accordion(t("generation.optional_params"), open=service_mode) as optional_params_accordion:
|
| 401 |
with gr.Row():
|
| 402 |
bpm = gr.Number(
|
| 403 |
label=t("generation.bpm_label"),
|
|
|
|
| 432 |
minimum=1,
|
| 433 |
maximum=8,
|
| 434 |
step=1,
|
| 435 |
+
info=t("generation.batch_size_info"),
|
| 436 |
+
interactive=not service_mode # Fixed in service mode
|
| 437 |
)
|
| 438 |
|
| 439 |
# Advanced Settings
|
|
|
|
| 473 |
choices=["mp3", "flac"],
|
| 474 |
value="mp3",
|
| 475 |
label=t("generation.audio_format_label"),
|
| 476 |
+
info=t("generation.audio_format_info"),
|
| 477 |
+
interactive=not service_mode # Fixed in service mode
|
| 478 |
)
|
| 479 |
|
| 480 |
with gr.Row():
|
|
|
|
| 594 |
value=False,
|
| 595 |
info=t("generation.constrained_debug_info"),
|
| 596 |
scale=1,
|
| 597 |
+
interactive=not service_mode # Fixed in service mode
|
| 598 |
)
|
| 599 |
|
| 600 |
with gr.Row():
|
|
|
|
| 603 |
value=False,
|
| 604 |
info=t("generation.auto_score_info"),
|
| 605 |
scale=1,
|
| 606 |
+
interactive=not service_mode # Fixed in service mode
|
| 607 |
)
|
| 608 |
auto_lrc = gr.Checkbox(
|
| 609 |
label=t("generation.auto_lrc_label"),
|
| 610 |
value=False,
|
| 611 |
info=t("generation.auto_lrc_info"),
|
| 612 |
scale=1,
|
| 613 |
+
interactive=not service_mode # Fixed in service mode
|
| 614 |
)
|
| 615 |
lm_batch_chunk_size = gr.Number(
|
| 616 |
label=t("generation.lm_batch_chunk_label"),
|
|
|
|
| 620 |
step=1,
|
| 621 |
info=t("generation.lm_batch_chunk_info"),
|
| 622 |
scale=1,
|
| 623 |
+
interactive=not service_mode # Fixed in service mode
|
| 624 |
)
|
| 625 |
|
| 626 |
with gr.Row():
|
|
|
|
| 641 |
label=t("generation.score_sensitivity_label"),
|
| 642 |
info=t("generation.score_sensitivity_info"),
|
| 643 |
scale=1,
|
| 644 |
+
visible=not service_mode # Hidden in service mode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 645 |
)
|
| 646 |
|
| 647 |
# Set generate_btn to interactive if service is pre-initialized
|
|
|
|
| 663 |
with gr.Column(scale=1, variant="compact"):
|
| 664 |
autogen_checkbox = gr.Checkbox(
|
| 665 |
label=t("generation.autogen_label"),
|
| 666 |
+
value=False, # Default to False for both service and local modes
|
| 667 |
scale=1,
|
| 668 |
+
interactive=not service_mode # Not selectable in service mode
|
| 669 |
)
|
| 670 |
use_cot_caption = gr.Checkbox(
|
| 671 |
label=t("generation.caption_rewrite_label"),
|
|
|
|
| 751 |
"infer_method": infer_method,
|
| 752 |
"custom_timesteps": custom_timesteps,
|
| 753 |
"audio_format": audio_format,
|
|
|
|
| 754 |
"think_checkbox": think_checkbox,
|
| 755 |
"autogen_checkbox": autogen_checkbox,
|
| 756 |
"generate_btn": generate_btn,
|
acestep/gradio_ui/interfaces/training.py
CHANGED
|
@@ -9,18 +9,22 @@ import gradio as gr
|
|
| 9 |
from acestep.gradio_ui.i18n import t
|
| 10 |
|
| 11 |
|
| 12 |
-
def create_training_section(dit_handler, llm_handler) -> dict:
|
| 13 |
"""Create the training tab section with dataset builder and training controls.
|
| 14 |
|
| 15 |
Args:
|
| 16 |
dit_handler: DiT handler instance
|
| 17 |
llm_handler: LLM handler instance
|
|
|
|
|
|
|
| 18 |
|
| 19 |
Returns:
|
| 20 |
Dictionary of Gradio components for event handling
|
| 21 |
"""
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
with gr.Tab("🎓 LoRA Training"):
|
| 24 |
gr.HTML("""
|
| 25 |
<div style="text-align: center; padding: 10px; margin-bottom: 15px;">
|
| 26 |
<h2>🎵 LoRA Training for ACE-Step</h2>
|
|
|
|
| 9 |
from acestep.gradio_ui.i18n import t
|
| 10 |
|
| 11 |
|
| 12 |
+
def create_training_section(dit_handler, llm_handler, init_params=None) -> dict:
|
| 13 |
"""Create the training tab section with dataset builder and training controls.
|
| 14 |
|
| 15 |
Args:
|
| 16 |
dit_handler: DiT handler instance
|
| 17 |
llm_handler: LLM handler instance
|
| 18 |
+
init_params: Dictionary containing initialization parameters and state.
|
| 19 |
+
If None, service will not be pre-initialized.
|
| 20 |
|
| 21 |
Returns:
|
| 22 |
Dictionary of Gradio components for event handling
|
| 23 |
"""
|
| 24 |
+
# Check if running in service mode (hide training tab)
|
| 25 |
+
service_mode = init_params is not None and init_params.get('service_mode', False)
|
| 26 |
|
| 27 |
+
with gr.Tab("🎓 LoRA Training", visible=not service_mode):
|
| 28 |
gr.HTML("""
|
| 29 |
<div style="text-align: center; padding: 10px; margin-bottom: 15px;">
|
| 30 |
<h2>🎵 LoRA Training for ACE-Step</h2>
|
acestep/inference.py
CHANGED
|
@@ -399,7 +399,7 @@ def generate_music(
|
|
| 399 |
# Determine infer_type based on whether we need audio codes
|
| 400 |
# - "llm_dit": generates both metas and audio codes (two-phase internally)
|
| 401 |
# - "dit": generates only metas (single phase)
|
| 402 |
-
infer_type = "llm_dit" if need_audio_codes else "dit"
|
| 403 |
|
| 404 |
# Use chunk size from config, or default to batch_size if not set
|
| 405 |
max_inference_batch_size = int(config.lm_batch_chunk_size) if config.lm_batch_chunk_size > 0 else actual_batch_size
|
|
|
|
| 399 |
# Determine infer_type based on whether we need audio codes
|
| 400 |
# - "llm_dit": generates both metas and audio codes (two-phase internally)
|
| 401 |
# - "dit": generates only metas (single phase)
|
| 402 |
+
infer_type = "llm_dit" if need_audio_codes and params.thinking else "dit"
|
| 403 |
|
| 404 |
# Use chunk size from config, or default to batch_size if not set
|
| 405 |
max_inference_batch_size = int(config.lm_batch_chunk_size) if config.lm_batch_chunk_size > 0 else actual_batch_size
|
API.md → docs/en/API.md
RENAMED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
# ACE-Step API Client Documentation
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
This service provides an HTTP-based asynchronous music generation API.
|
| 4 |
|
| 5 |
**Basic Workflow**:
|
| 6 |
1. Call `POST /v1/music/generate` to submit a task and obtain a `job_id`.
|
| 7 |
2. Call `GET /v1/jobs/{job_id}` to poll the task status until `status` is `succeeded` or `failed`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
---
|
| 10 |
|
|
@@ -25,10 +43,21 @@ Task status (`status`) includes the following types:
|
|
| 25 |
|
| 26 |
- **URL**: `/v1/music/generate`
|
| 27 |
- **Method**: `POST`
|
| 28 |
-
- **Content-Type**: `application/json` or `
|
| 29 |
|
| 30 |
### 2.2 Request Parameters
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
#### Method A: JSON Request (application/json)
|
| 33 |
|
| 34 |
Suitable for passing only text parameters, or referencing audio file paths that already exist on the server.
|
|
@@ -43,6 +72,20 @@ Suitable for passing only text parameters, or referencing audio file paths that
|
|
| 43 |
| `vocal_language` | string | `"en"` | Lyrics language (en, zh, ja, etc.) |
|
| 44 |
| `audio_format` | string | `"mp3"` | Output format (mp3, wav, flac) |
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
**thinking Semantics (Important)**:
|
| 47 |
|
| 48 |
- `thinking=false`:
|
|
@@ -50,11 +93,11 @@ Suitable for passing only text parameters, or referencing audio file paths that
|
|
| 50 |
- DiT runs in **text2music** mode and **ignores** any provided `audio_code_string`.
|
| 51 |
- `thinking=true`:
|
| 52 |
- The server will use 5Hz LM to generate `audio_code_string` (lm-dit behavior).
|
| 53 |
-
- DiT runs
|
| 54 |
|
| 55 |
-
**Metadata Auto-Completion (
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
- `bpm`
|
| 60 |
- `key_scale`
|
|
@@ -67,26 +110,37 @@ User-provided values always win; LM only fills the fields that are empty/missing
|
|
| 67 |
|
| 68 |
| Parameter Name | Type | Default | Description |
|
| 69 |
| :--- | :--- | :--- | :--- |
|
| 70 |
-
| `bpm` | int | null | Specify tempo (BPM) |
|
| 71 |
-
| `key_scale` | string | `""` | Key/scale (e.g., "C Major") |
|
| 72 |
-
| `time_signature` | string | `""` | Time signature (
|
| 73 |
-
| `audio_duration` | float | null | Generation duration (seconds) |
|
| 74 |
|
| 75 |
**Audio Codes (Optional)**:
|
| 76 |
|
| 77 |
| Parameter Name | Type | Default | Description |
|
| 78 |
| :--- | :--- | :--- | :--- |
|
| 79 |
-
| `audio_code_string` | string or string[] | `""` | Audio semantic tokens (5Hz) for `llm_dit`.
|
| 80 |
|
| 81 |
**Generation Control Parameters**:
|
| 82 |
|
| 83 |
| Parameter Name | Type | Default | Description |
|
| 84 |
| :--- | :--- | :--- | :--- |
|
| 85 |
-
| `inference_steps` | int | `8` | Number of inference steps |
|
| 86 |
-
| `guidance_scale` | float | `7.0` | Prompt guidance coefficient |
|
| 87 |
| `use_random_seed` | bool | `true` | Whether to use random seed |
|
| 88 |
| `seed` | int | `-1` | Specify seed (when use_random_seed=false) |
|
| 89 |
-
| `batch_size` | int |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
**5Hz LM Parameters (Optional, server-side)**:
|
| 92 |
|
|
@@ -94,26 +148,35 @@ These parameters control 5Hz LM sampling, used for metadata auto-completion and
|
|
| 94 |
|
| 95 |
| Parameter Name | Type | Default | Description |
|
| 96 |
| :--- | :--- | :--- | :--- |
|
| 97 |
-
| `lm_model_path` | string | null | 5Hz LM checkpoint dir name (e.g. `acestep-5Hz-lm-0.6B`) |
|
| 98 |
| `lm_backend` | string | `"vllm"` | `vllm` or `pt` |
|
| 99 |
| `lm_temperature` | float | `0.85` | Sampling temperature |
|
| 100 |
-
| `lm_cfg_scale` | float | `2.
|
| 101 |
| `lm_negative_prompt` | string | `"NO USER INPUT"` | Negative prompt used by CFG |
|
| 102 |
| `lm_top_k` | int | null | Top-k (0/null disables) |
|
| 103 |
| `lm_top_p` | float | `0.9` | Top-p (>=1 will be treated as disabled) |
|
| 104 |
| `lm_repetition_penalty` | float | `1.0` | Repetition penalty |
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
**Edit/Reference Audio Parameters** (requires absolute path on server):
|
| 107 |
|
| 108 |
| Parameter Name | Type | Default | Description |
|
| 109 |
| :--- | :--- | :--- | :--- |
|
| 110 |
| `reference_audio_path` | string | null | Reference audio path (Style Transfer) |
|
| 111 |
| `src_audio_path` | string | null | Source audio path (Repainting/Cover) |
|
| 112 |
-
| `task_type` | string | `"text2music"` | Task type
|
| 113 |
-
| `instruction` | string |
|
| 114 |
-
| `repainting_start` | float | `0.0` | Repainting start time |
|
| 115 |
-
| `repainting_end` | float | null | Repainting end time |
|
| 116 |
-
| `audio_cover_strength` | float | `1.0` | Cover strength |
|
| 117 |
|
| 118 |
#### Method B: File Upload (multipart/form-data)
|
| 119 |
|
|
@@ -138,7 +201,7 @@ In addition to supporting all the above fields as Form Fields, the following fil
|
|
| 138 |
|
| 139 |
### 2.4 Usage Examples (cURL)
|
| 140 |
|
| 141 |
-
**JSON Method**:
|
| 142 |
|
| 143 |
```bash
|
| 144 |
curl -X POST http://localhost:8001/v1/music/generate \
|
|
@@ -146,11 +209,11 @@ curl -X POST http://localhost:8001/v1/music/generate \
|
|
| 146 |
-d '{
|
| 147 |
"caption": "upbeat pop song",
|
| 148 |
"lyrics": "Hello world",
|
| 149 |
-
"inference_steps":
|
| 150 |
}'
|
| 151 |
```
|
| 152 |
|
| 153 |
-
**
|
| 154 |
|
| 155 |
```bash
|
| 156 |
curl -X POST http://localhost:8001/v1/music/generate \
|
|
@@ -160,47 +223,69 @@ curl -X POST http://localhost:8001/v1/music/generate \
|
|
| 160 |
"lyrics": "Hello world",
|
| 161 |
"thinking": true,
|
| 162 |
"lm_temperature": 0.85,
|
| 163 |
-
"lm_cfg_scale": 2.
|
| 164 |
-
"lm_top_k": null,
|
| 165 |
-
"lm_top_p": 0.9,
|
| 166 |
-
"lm_repetition_penalty": 1.0
|
| 167 |
}'
|
| 168 |
```
|
| 169 |
|
| 170 |
-
**
|
| 171 |
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
```bash
|
| 175 |
curl -X POST http://localhost:8001/v1/music/generate \
|
| 176 |
-H 'Content-Type: application/json' \
|
| 177 |
-d '{
|
| 178 |
-
"caption": "
|
| 179 |
-
"lyrics": "...",
|
| 180 |
-
"
|
| 181 |
-
"
|
| 182 |
}'
|
| 183 |
```
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
| 188 |
-
-
|
| 189 |
-
-
|
| 190 |
-
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
|
| 195 |
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
```bash
|
| 199 |
curl -X POST http://localhost:8001/v1/music/generate \
|
| 200 |
-
-H 'Content-Type: application/
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
| 204 |
```
|
| 205 |
|
| 206 |
**File Upload Method**:
|
|
@@ -230,11 +315,22 @@ The response contains basic task information, queue status, and final results.
|
|
| 230 |
- `status`: Current status
|
| 231 |
- `queue_position`: Current queue position (0 means running or completed)
|
| 232 |
- `eta_seconds`: Estimated remaining wait time (seconds)
|
|
|
|
| 233 |
- `result`: Result object when successful
|
| 234 |
-
- `audio_paths`: List of generated audio file URLs/
|
| 235 |
-
- `first_audio_path`:
|
|
|
|
| 236 |
- `generation_info`: Generation parameter details
|
| 237 |
- `status_message`: Brief result description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
- `error`: Error information when failed
|
| 239 |
|
| 240 |
### 3.3 Response Examples
|
|
@@ -243,11 +339,12 @@ The response contains basic task information, queue status, and final results.
|
|
| 243 |
|
| 244 |
```json
|
| 245 |
{
|
| 246 |
-
"job_id": "
|
| 247 |
"status": "queued",
|
| 248 |
"created_at": 1700000000.0,
|
| 249 |
"queue_position": 5,
|
| 250 |
"eta_seconds": 25.0,
|
|
|
|
| 251 |
"result": null,
|
| 252 |
"error": null
|
| 253 |
}
|
|
@@ -257,19 +354,217 @@ The response contains basic task information, queue status, and final results.
|
|
| 257 |
|
| 258 |
```json
|
| 259 |
{
|
| 260 |
-
"job_id": "
|
| 261 |
"status": "succeeded",
|
| 262 |
"created_at": 1700000000.0,
|
|
|
|
| 263 |
"finished_at": 1700000010.0,
|
| 264 |
"queue_position": 0,
|
| 265 |
"result": {
|
| 266 |
-
"first_audio_path": "/
|
| 267 |
-
"second_audio_path": "/
|
| 268 |
-
"audio_paths": [
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
| 270 |
"status_message": "✅ Generation completed successfully!",
|
| 271 |
-
"seed_value": "12345"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
},
|
| 273 |
"error": null
|
| 274 |
}
|
| 275 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ACE-Step API Client Documentation
|
| 2 |
|
| 3 |
+
**Language / 语言 / 言語:** [English](API.md) | [中文](../zh/API.md) | [日本語](../ja/API.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
This service provides an HTTP-based asynchronous music generation API.
|
| 8 |
|
| 9 |
**Basic Workflow**:
|
| 10 |
1. Call `POST /v1/music/generate` to submit a task and obtain a `job_id`.
|
| 11 |
2. Call `GET /v1/jobs/{job_id}` to poll the task status until `status` is `succeeded` or `failed`.
|
| 12 |
+
3. Download audio files via `GET /v1/audio?path=...` URLs returned in the result.
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## Table of Contents
|
| 17 |
+
|
| 18 |
+
- [Task Status Description](#1-task-status-description)
|
| 19 |
+
- [Create Generation Task](#2-create-generation-task)
|
| 20 |
+
- [Query Task Results](#3-query-task-results)
|
| 21 |
+
- [Random Sample Generation](#4-random-sample-generation)
|
| 22 |
+
- [List Available Models](#5-list-available-models)
|
| 23 |
+
- [Download Audio Files](#6-download-audio-files)
|
| 24 |
+
- [Health Check](#7-health-check)
|
| 25 |
+
- [Environment Variables](#8-environment-variables)
|
| 26 |
|
| 27 |
---
|
| 28 |
|
|
|
|
| 43 |
|
| 44 |
- **URL**: `/v1/music/generate`
|
| 45 |
- **Method**: `POST`
|
| 46 |
+
- **Content-Type**: `application/json`, `multipart/form-data`, or `application/x-www-form-urlencoded`
|
| 47 |
|
| 48 |
### 2.2 Request Parameters
|
| 49 |
|
| 50 |
+
#### Parameter Naming Convention
|
| 51 |
+
|
| 52 |
+
The API supports both **snake_case** and **camelCase** naming for most parameters. For example:
|
| 53 |
+
- `audio_duration` / `duration` / `audioDuration`
|
| 54 |
+
- `key_scale` / `keyscale` / `keyScale`
|
| 55 |
+
- `time_signature` / `timesignature` / `timeSignature`
|
| 56 |
+
- `sample_query` / `sampleQuery` / `description` / `desc`
|
| 57 |
+
- `use_format` / `useFormat` / `format`
|
| 58 |
+
|
| 59 |
+
Additionally, metadata can be passed in a nested object (`metas`, `metadata`, or `user_metadata`).
|
| 60 |
+
|
| 61 |
#### Method A: JSON Request (application/json)
|
| 62 |
|
| 63 |
Suitable for passing only text parameters, or referencing audio file paths that already exist on the server.
|
|
|
|
| 72 |
| `vocal_language` | string | `"en"` | Lyrics language (en, zh, ja, etc.) |
|
| 73 |
| `audio_format` | string | `"mp3"` | Output format (mp3, wav, flac) |
|
| 74 |
|
| 75 |
+
**Sample/Description Mode Parameters**:
|
| 76 |
+
|
| 77 |
+
| Parameter Name | Type | Default | Description |
|
| 78 |
+
| :--- | :--- | :--- | :--- |
|
| 79 |
+
| `sample_mode` | bool | `false` | Enable random sample generation mode (auto-generates caption/lyrics/metas via LM). |
|
| 80 |
+
| `sample_query` | string | `""` | Natural language description for sample generation (e.g., "a soft Bengali love song"). Aliases: `description`, `desc`. |
|
| 81 |
+
| `use_format` | bool | `false` | Use LM to enhance/format the provided caption and lyrics. Alias: `format`. |
|
| 82 |
+
|
| 83 |
+
**Multi-Model Support**:
|
| 84 |
+
|
| 85 |
+
| Parameter Name | Type | Default | Description |
|
| 86 |
+
| :--- | :--- | :--- | :--- |
|
| 87 |
+
| `model` | string | null | Select which DiT model to use (e.g., `"acestep-v15-turbo"`, `"acestep-v15-turbo-rl"`). Use `/v1/models` to list available models. If not specified, uses the default model. |
|
| 88 |
+
|
| 89 |
**thinking Semantics (Important)**:
|
| 90 |
|
| 91 |
- `thinking=false`:
|
|
|
|
| 93 |
- DiT runs in **text2music** mode and **ignores** any provided `audio_code_string`.
|
| 94 |
- `thinking=true`:
|
| 95 |
- The server will use 5Hz LM to generate `audio_code_string` (lm-dit behavior).
|
| 96 |
+
- DiT runs with LM-generated codes for enhanced music quality.
|
| 97 |
|
| 98 |
+
**Metadata Auto-Completion (Conditional)**:
|
| 99 |
|
| 100 |
+
When `use_cot_caption=true` or `use_cot_language=true` or metadata fields are missing, the server may call 5Hz LM to fill the missing fields based on `caption`/`lyrics`:
|
| 101 |
|
| 102 |
- `bpm`
|
| 103 |
- `key_scale`
|
|
|
|
| 110 |
|
| 111 |
| Parameter Name | Type | Default | Description |
|
| 112 |
| :--- | :--- | :--- | :--- |
|
| 113 |
+
| `bpm` | int | null | Specify tempo (BPM), range 30-300 |
|
| 114 |
+
| `key_scale` | string | `""` | Key/scale (e.g., "C Major", "Am"). Aliases: `keyscale`, `keyScale` |
|
| 115 |
+
| `time_signature` | string | `""` | Time signature (2, 3, 4, 6 for 2/4, 3/4, 4/4, 6/8). Aliases: `timesignature`, `timeSignature` |
|
| 116 |
+
| `audio_duration` | float | null | Generation duration (seconds), range 10-600. Aliases: `duration`, `target_duration` |
|
| 117 |
|
| 118 |
**Audio Codes (Optional)**:
|
| 119 |
|
| 120 |
| Parameter Name | Type | Default | Description |
|
| 121 |
| :--- | :--- | :--- | :--- |
|
| 122 |
+
| `audio_code_string` | string or string[] | `""` | Audio semantic tokens (5Hz) for `llm_dit`. Alias: `audioCodeString` |
|
| 123 |
|
| 124 |
**Generation Control Parameters**:
|
| 125 |
|
| 126 |
| Parameter Name | Type | Default | Description |
|
| 127 |
| :--- | :--- | :--- | :--- |
|
| 128 |
+
| `inference_steps` | int | `8` | Number of inference steps. Turbo model: 1-20 (recommended 8). Base model: 1-200 (recommended 32-64). |
|
| 129 |
+
| `guidance_scale` | float | `7.0` | Prompt guidance coefficient. Only effective for base model. |
|
| 130 |
| `use_random_seed` | bool | `true` | Whether to use random seed |
|
| 131 |
| `seed` | int | `-1` | Specify seed (when use_random_seed=false) |
|
| 132 |
+
| `batch_size` | int | `2` | Batch generation count (max 8) |
|
| 133 |
+
|
| 134 |
+
**Advanced DiT Parameters**:
|
| 135 |
+
|
| 136 |
+
| Parameter Name | Type | Default | Description |
|
| 137 |
+
| :--- | :--- | :--- | :--- |
|
| 138 |
+
| `shift` | float | `3.0` | Timestep shift factor (range 1.0-5.0). Only effective for base models, not turbo models. |
|
| 139 |
+
| `infer_method` | string | `"ode"` | Diffusion inference method: `"ode"` (Euler, faster) or `"sde"` (stochastic). |
|
| 140 |
+
| `timesteps` | string | null | Custom timesteps as comma-separated values (e.g., `"0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0"`). Overrides `inference_steps` and `shift`. |
|
| 141 |
+
| `use_adg` | bool | `false` | Use Adaptive Dual Guidance (base model only) |
|
| 142 |
+
| `cfg_interval_start` | float | `0.0` | CFG application start ratio (0.0-1.0) |
|
| 143 |
+
| `cfg_interval_end` | float | `1.0` | CFG application end ratio (0.0-1.0) |
|
| 144 |
|
| 145 |
**5Hz LM Parameters (Optional, server-side)**:
|
| 146 |
|
|
|
|
| 148 |
|
| 149 |
| Parameter Name | Type | Default | Description |
|
| 150 |
| :--- | :--- | :--- | :--- |
|
| 151 |
+
| `lm_model_path` | string | null | 5Hz LM checkpoint dir name (e.g. `acestep-5Hz-lm-0.6B-v3`) |
|
| 152 |
| `lm_backend` | string | `"vllm"` | `vllm` or `pt` |
|
| 153 |
| `lm_temperature` | float | `0.85` | Sampling temperature |
|
| 154 |
+
| `lm_cfg_scale` | float | `2.5` | CFG scale (>1 enables CFG) |
|
| 155 |
| `lm_negative_prompt` | string | `"NO USER INPUT"` | Negative prompt used by CFG |
|
| 156 |
| `lm_top_k` | int | null | Top-k (0/null disables) |
|
| 157 |
| `lm_top_p` | float | `0.9` | Top-p (>=1 will be treated as disabled) |
|
| 158 |
| `lm_repetition_penalty` | float | `1.0` | Repetition penalty |
|
| 159 |
|
| 160 |
+
**LM CoT (Chain-of-Thought) Parameters**:
|
| 161 |
+
|
| 162 |
+
| Parameter Name | Type | Default | Description |
|
| 163 |
+
| :--- | :--- | :--- | :--- |
|
| 164 |
+
| `use_cot_caption` | bool | `true` | Let LM rewrite/enhance the input caption via CoT reasoning. Aliases: `cot_caption`, `cot-caption` |
|
| 165 |
+
| `use_cot_language` | bool | `true` | Let LM detect vocal language via CoT. Aliases: `cot_language`, `cot-language` |
|
| 166 |
+
| `constrained_decoding` | bool | `true` | Enable FSM-based constrained decoding for structured LM output. Aliases: `constrainedDecoding`, `constrained` |
|
| 167 |
+
| `constrained_decoding_debug` | bool | `false` | Enable debug logging for constrained decoding |
|
| 168 |
+
|
| 169 |
**Edit/Reference Audio Parameters** (requires absolute path on server):
|
| 170 |
|
| 171 |
| Parameter Name | Type | Default | Description |
|
| 172 |
| :--- | :--- | :--- | :--- |
|
| 173 |
| `reference_audio_path` | string | null | Reference audio path (Style Transfer) |
|
| 174 |
| `src_audio_path` | string | null | Source audio path (Repainting/Cover) |
|
| 175 |
+
| `task_type` | string | `"text2music"` | Task type: `text2music`, `cover`, `repaint`, `lego`, `extract`, `complete` |
|
| 176 |
+
| `instruction` | string | auto | Edit instruction (auto-generated based on task_type if not provided) |
|
| 177 |
+
| `repainting_start` | float | `0.0` | Repainting start time (seconds) |
|
| 178 |
+
| `repainting_end` | float | null | Repainting end time (seconds), -1 for end of audio |
|
| 179 |
+
| `audio_cover_strength` | float | `1.0` | Cover strength (0.0-1.0). Lower values (0.2) for style transfer. |
|
| 180 |
|
| 181 |
#### Method B: File Upload (multipart/form-data)
|
| 182 |
|
|
|
|
| 201 |
|
| 202 |
### 2.4 Usage Examples (cURL)
|
| 203 |
|
| 204 |
+
**Basic JSON Method**:
|
| 205 |
|
| 206 |
```bash
|
| 207 |
curl -X POST http://localhost:8001/v1/music/generate \
|
|
|
|
| 209 |
-d '{
|
| 210 |
"caption": "upbeat pop song",
|
| 211 |
"lyrics": "Hello world",
|
| 212 |
+
"inference_steps": 8
|
| 213 |
}'
|
| 214 |
```
|
| 215 |
|
| 216 |
+
**With thinking=true (LM generates codes + fills missing metas)**:
|
| 217 |
|
| 218 |
```bash
|
| 219 |
curl -X POST http://localhost:8001/v1/music/generate \
|
|
|
|
| 223 |
"lyrics": "Hello world",
|
| 224 |
"thinking": true,
|
| 225 |
"lm_temperature": 0.85,
|
| 226 |
+
"lm_cfg_scale": 2.5
|
|
|
|
|
|
|
|
|
|
| 227 |
}'
|
| 228 |
```
|
| 229 |
|
| 230 |
+
**Description-driven generation (sample_query)**:
|
| 231 |
|
| 232 |
+
```bash
|
| 233 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 234 |
+
-H 'Content-Type: application/json' \
|
| 235 |
+
-d '{
|
| 236 |
+
"sample_query": "a soft Bengali love song for a quiet evening",
|
| 237 |
+
"thinking": true
|
| 238 |
+
}'
|
| 239 |
+
```
|
| 240 |
+
|
| 241 |
+
**With format enhancement (use_format=true)**:
|
| 242 |
|
| 243 |
```bash
|
| 244 |
curl -X POST http://localhost:8001/v1/music/generate \
|
| 245 |
-H 'Content-Type: application/json' \
|
| 246 |
-d '{
|
| 247 |
+
"caption": "pop rock",
|
| 248 |
+
"lyrics": "[Verse 1]\nWalking down the street...",
|
| 249 |
+
"use_format": true,
|
| 250 |
+
"thinking": true
|
| 251 |
}'
|
| 252 |
```
|
| 253 |
|
| 254 |
+
**Select specific model**:
|
| 255 |
|
| 256 |
+
```bash
|
| 257 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 258 |
+
-H 'Content-Type: application/json' \
|
| 259 |
+
-d '{
|
| 260 |
+
"caption": "electronic dance music",
|
| 261 |
+
"model": "acestep-v15-turbo-rl",
|
| 262 |
+
"thinking": true
|
| 263 |
+
}'
|
| 264 |
+
```
|
| 265 |
|
| 266 |
+
**With custom timesteps**:
|
| 267 |
|
| 268 |
+
```bash
|
| 269 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 270 |
+
-H 'Content-Type: application/json' \
|
| 271 |
+
-d '{
|
| 272 |
+
"caption": "jazz piano trio",
|
| 273 |
+
"timesteps": "0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0",
|
| 274 |
+
"thinking": true
|
| 275 |
+
}'
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
**With thinking=false (DiT only, but fill missing metas)**:
|
| 279 |
|
| 280 |
```bash
|
| 281 |
curl -X POST http://localhost:8001/v1/music/generate \
|
| 282 |
+
-H 'Content-Type: application/json' \
|
| 283 |
+
-d '{
|
| 284 |
+
"caption": "slow emotional ballad",
|
| 285 |
+
"lyrics": "...",
|
| 286 |
+
"thinking": false,
|
| 287 |
+
"bpm": 72
|
| 288 |
+
}'
|
| 289 |
```
|
| 290 |
|
| 291 |
**File Upload Method**:
|
|
|
|
| 315 |
- `status`: Current status
|
| 316 |
- `queue_position`: Current queue position (0 means running or completed)
|
| 317 |
- `eta_seconds`: Estimated remaining wait time (seconds)
|
| 318 |
+
- `avg_job_seconds`: Average job duration (for ETA estimation)
|
| 319 |
- `result`: Result object when successful
|
| 320 |
+
- `audio_paths`: List of generated audio file URLs (use with `/v1/audio` endpoint)
|
| 321 |
+
- `first_audio_path`: First audio path (URL)
|
| 322 |
+
- `second_audio_path`: Second audio path (URL, if batch_size >= 2)
|
| 323 |
- `generation_info`: Generation parameter details
|
| 324 |
- `status_message`: Brief result description
|
| 325 |
+
- `seed_value`: Comma-separated seed values used
|
| 326 |
+
- `metas`: Complete metadata dict
|
| 327 |
+
- `bpm`: Detected/used BPM
|
| 328 |
+
- `duration`: Detected/used duration
|
| 329 |
+
- `keyscale`: Detected/used key scale
|
| 330 |
+
- `timesignature`: Detected/used time signature
|
| 331 |
+
- `genres`: Detected genres (if available)
|
| 332 |
+
- `lm_model`: Name of the LM model used
|
| 333 |
+
- `dit_model`: Name of the DiT model used
|
| 334 |
- `error`: Error information when failed
|
| 335 |
|
| 336 |
### 3.3 Response Examples
|
|
|
|
| 339 |
|
| 340 |
```json
|
| 341 |
{
|
| 342 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 343 |
"status": "queued",
|
| 344 |
"created_at": 1700000000.0,
|
| 345 |
"queue_position": 5,
|
| 346 |
"eta_seconds": 25.0,
|
| 347 |
+
"avg_job_seconds": 5.0,
|
| 348 |
"result": null,
|
| 349 |
"error": null
|
| 350 |
}
|
|
|
|
| 354 |
|
| 355 |
```json
|
| 356 |
{
|
| 357 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 358 |
"status": "succeeded",
|
| 359 |
"created_at": 1700000000.0,
|
| 360 |
+
"started_at": 1700000001.0,
|
| 361 |
"finished_at": 1700000010.0,
|
| 362 |
"queue_position": 0,
|
| 363 |
"result": {
|
| 364 |
+
"first_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 365 |
+
"second_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3",
|
| 366 |
+
"audio_paths": [
|
| 367 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 368 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3"
|
| 369 |
+
],
|
| 370 |
+
"generation_info": "🎵 Generated 2 audios\n⏱️ Total: 8.5s\n🎲 Seeds: 12345,67890",
|
| 371 |
"status_message": "✅ Generation completed successfully!",
|
| 372 |
+
"seed_value": "12345,67890",
|
| 373 |
+
"metas": {
|
| 374 |
+
"bpm": 120,
|
| 375 |
+
"duration": 30,
|
| 376 |
+
"keyscale": "C Major",
|
| 377 |
+
"timesignature": "4",
|
| 378 |
+
"caption": "upbeat pop song with catchy melody"
|
| 379 |
+
},
|
| 380 |
+
"bpm": 120,
|
| 381 |
+
"duration": 30,
|
| 382 |
+
"keyscale": "C Major",
|
| 383 |
+
"timesignature": "4",
|
| 384 |
+
"genres": null,
|
| 385 |
+
"lm_model": "acestep-5Hz-lm-0.6B-v3",
|
| 386 |
+
"dit_model": "acestep-v15-turbo-rl"
|
| 387 |
},
|
| 388 |
"error": null
|
| 389 |
}
|
| 390 |
```
|
| 391 |
+
|
| 392 |
+
---
|
| 393 |
+
|
| 394 |
+
## 4. Random Sample Generation
|
| 395 |
+
|
| 396 |
+
### 4.1 API Definition
|
| 397 |
+
|
| 398 |
+
- **URL**: `/v1/music/random`
|
| 399 |
+
- **Method**: `POST`
|
| 400 |
+
|
| 401 |
+
This endpoint creates a sample-mode job that auto-generates caption, lyrics, and metadata via the 5Hz LM.
|
| 402 |
+
|
| 403 |
+
### 4.2 Request Parameters
|
| 404 |
+
|
| 405 |
+
| Parameter Name | Type | Default | Description |
|
| 406 |
+
| :--- | :--- | :--- | :--- |
|
| 407 |
+
| `thinking` | bool | `true` | Whether to also generate audio codes via LM |
|
| 408 |
+
|
| 409 |
+
### 4.3 Response Example
|
| 410 |
+
|
| 411 |
+
```json
|
| 412 |
+
{
|
| 413 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 414 |
+
"status": "queued",
|
| 415 |
+
"queue_position": 1
|
| 416 |
+
}
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
### 4.4 Usage Example
|
| 420 |
+
|
| 421 |
+
```bash
|
| 422 |
+
curl -X POST http://localhost:8001/v1/music/random \
|
| 423 |
+
-H 'Content-Type: application/json' \
|
| 424 |
+
-d '{"thinking": true}'
|
| 425 |
+
```
|
| 426 |
+
|
| 427 |
+
---
|
| 428 |
+
|
| 429 |
+
## 5. List Available Models
|
| 430 |
+
|
| 431 |
+
### 5.1 API Definition
|
| 432 |
+
|
| 433 |
+
- **URL**: `/v1/models`
|
| 434 |
+
- **Method**: `GET`
|
| 435 |
+
|
| 436 |
+
Returns a list of available DiT models loaded on the server.
|
| 437 |
+
|
| 438 |
+
### 5.2 Response Example
|
| 439 |
+
|
| 440 |
+
```json
|
| 441 |
+
{
|
| 442 |
+
"models": [
|
| 443 |
+
{
|
| 444 |
+
"name": "acestep-v15-turbo-rl",
|
| 445 |
+
"is_default": true
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"name": "acestep-v15-turbo",
|
| 449 |
+
"is_default": false
|
| 450 |
+
}
|
| 451 |
+
],
|
| 452 |
+
"default_model": "acestep-v15-turbo-rl"
|
| 453 |
+
}
|
| 454 |
+
```
|
| 455 |
+
|
| 456 |
+
### 5.3 Usage Example
|
| 457 |
+
|
| 458 |
+
```bash
|
| 459 |
+
curl http://localhost:8001/v1/models
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## 6. Download Audio Files
|
| 465 |
+
|
| 466 |
+
### 6.1 API Definition
|
| 467 |
+
|
| 468 |
+
- **URL**: `/v1/audio`
|
| 469 |
+
- **Method**: `GET`
|
| 470 |
+
|
| 471 |
+
Download generated audio files by path.
|
| 472 |
+
|
| 473 |
+
### 6.2 Request Parameters
|
| 474 |
+
|
| 475 |
+
| Parameter Name | Type | Description |
|
| 476 |
+
| :--- | :--- | :--- |
|
| 477 |
+
| `path` | string | URL-encoded path to the audio file |
|
| 478 |
+
|
| 479 |
+
### 6.3 Usage Example
|
| 480 |
+
|
| 481 |
+
```bash
|
| 482 |
+
# Download using the URL from job result
|
| 483 |
+
curl "http://localhost:8001/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3" -o output.mp3
|
| 484 |
+
```
|
| 485 |
+
|
| 486 |
+
---
|
| 487 |
+
|
| 488 |
+
## 7. Health Check
|
| 489 |
+
|
| 490 |
+
### 7.1 API Definition
|
| 491 |
+
|
| 492 |
+
- **URL**: `/health`
|
| 493 |
+
- **Method**: `GET`
|
| 494 |
+
|
| 495 |
+
Returns service health status.
|
| 496 |
+
|
| 497 |
+
### 7.2 Response Example
|
| 498 |
+
|
| 499 |
+
```json
|
| 500 |
+
{
|
| 501 |
+
"status": "ok",
|
| 502 |
+
"service": "ACE-Step API",
|
| 503 |
+
"version": "1.0"
|
| 504 |
+
}
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
+
---
|
| 508 |
+
|
| 509 |
+
## 8. Environment Variables
|
| 510 |
+
|
| 511 |
+
The API server can be configured using environment variables:
|
| 512 |
+
|
| 513 |
+
| Variable | Default | Description |
|
| 514 |
+
| :--- | :--- | :--- |
|
| 515 |
+
| `ACESTEP_API_HOST` | `127.0.0.1` | Server bind host |
|
| 516 |
+
| `ACESTEP_API_PORT` | `8001` | Server bind port |
|
| 517 |
+
| `ACESTEP_CONFIG_PATH` | `acestep-v15-turbo-rl` | Primary DiT model path |
|
| 518 |
+
| `ACESTEP_CONFIG_PATH2` | (empty) | Secondary DiT model path (optional) |
|
| 519 |
+
| `ACESTEP_CONFIG_PATH3` | (empty) | Third DiT model path (optional) |
|
| 520 |
+
| `ACESTEP_DEVICE` | `auto` | Device for model loading |
|
| 521 |
+
| `ACESTEP_USE_FLASH_ATTENTION` | `true` | Enable flash attention |
|
| 522 |
+
| `ACESTEP_OFFLOAD_TO_CPU` | `false` | Offload models to CPU when idle |
|
| 523 |
+
| `ACESTEP_OFFLOAD_DIT_TO_CPU` | `false` | Offload DiT specifically to CPU |
|
| 524 |
+
| `ACESTEP_LM_MODEL_PATH` | `acestep-5Hz-lm-0.6B-v3` | Default 5Hz LM model |
|
| 525 |
+
| `ACESTEP_LM_BACKEND` | `vllm` | LM backend (vllm or pt) |
|
| 526 |
+
| `ACESTEP_LM_DEVICE` | (same as ACESTEP_DEVICE) | Device for LM |
|
| 527 |
+
| `ACESTEP_LM_OFFLOAD_TO_CPU` | `false` | Offload LM to CPU |
|
| 528 |
+
| `ACESTEP_QUEUE_MAXSIZE` | `200` | Maximum queue size |
|
| 529 |
+
| `ACESTEP_QUEUE_WORKERS` | `1` | Number of queue workers |
|
| 530 |
+
| `ACESTEP_AVG_JOB_SECONDS` | `5.0` | Initial average job duration estimate |
|
| 531 |
+
| `ACESTEP_TMPDIR` | `.cache/acestep/tmp` | Temporary directory for files |
|
| 532 |
+
|
| 533 |
+
---
|
| 534 |
+
|
| 535 |
+
## Error Handling
|
| 536 |
+
|
| 537 |
+
**HTTP Status Codes**:
|
| 538 |
+
|
| 539 |
+
- `200`: Success
|
| 540 |
+
- `400`: Invalid request (bad JSON, missing fields)
|
| 541 |
+
- `404`: Job not found
|
| 542 |
+
- `415`: Unsupported Content-Type
|
| 543 |
+
- `429`: Server busy (queue is full)
|
| 544 |
+
- `500`: Internal server error
|
| 545 |
+
|
| 546 |
+
**Error Response Format**:
|
| 547 |
+
|
| 548 |
+
```json
|
| 549 |
+
{
|
| 550 |
+
"detail": "Error message describing the issue"
|
| 551 |
+
}
|
| 552 |
+
```
|
| 553 |
+
|
| 554 |
+
---
|
| 555 |
+
|
| 556 |
+
## Best Practices
|
| 557 |
+
|
| 558 |
+
1. **Use `thinking=true`** for best quality results with LM-enhanced generation.
|
| 559 |
+
|
| 560 |
+
2. **Use `sample_query`/`description`** for quick generation from natural language descriptions.
|
| 561 |
+
|
| 562 |
+
3. **Use `use_format=true`** when you have caption/lyrics but want LM to enhance them.
|
| 563 |
+
|
| 564 |
+
4. **Poll job status** with reasonable intervals (e.g., every 1-2 seconds) to avoid overloading the server.
|
| 565 |
+
|
| 566 |
+
5. **Check `avg_job_seconds`** in the response to estimate wait times.
|
| 567 |
+
|
| 568 |
+
6. **Use multi-model support** by setting `ACESTEP_CONFIG_PATH2` and `ACESTEP_CONFIG_PATH3` environment variables, then select with the `model` parameter.
|
| 569 |
+
|
| 570 |
+
7. **For production**, always set proper Content-Type headers to avoid 415 errors.
|
docs/en/G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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ACE-Step Gradio Demo User Guide
|
| 2 |
+
|
| 3 |
+
**Language / 语言 / 言語:** [English](GRADIO_GUIDE.md) | [中文](../zh/GRADIO_GUIDE.md) | [日本語](../ja/GRADIO_GUIDE.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
This guide provides comprehensive documentation for using the ACE-Step Gradio web interface for music generation, including all features and settings.
|
| 8 |
+
|
| 9 |
+
## Table of Contents
|
| 10 |
+
|
| 11 |
+
- [Getting Started](#getting-started)
|
| 12 |
+
- [Service Configuration](#service-configuration)
|
| 13 |
+
- [Generation Modes](#generation-modes)
|
| 14 |
+
- [Task Types](#task-types)
|
| 15 |
+
- [Input Parameters](#input-parameters)
|
| 16 |
+
- [Advanced Settings](#advanced-settings)
|
| 17 |
+
- [Results Section](#results-section)
|
| 18 |
+
- [LoRA Training](#lora-training)
|
| 19 |
+
- [Tips and Best Practices](#tips-and-best-practices)
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## Getting Started
|
| 24 |
+
|
| 25 |
+
### Launching the Demo
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# Basic launch
|
| 29 |
+
python app.py
|
| 30 |
+
|
| 31 |
+
# With pre-initialization
|
| 32 |
+
python app.py --config acestep-v15-turbo-rl --init-llm
|
| 33 |
+
|
| 34 |
+
# With specific port
|
| 35 |
+
python app.py --port 7860
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### Interface Overview
|
| 39 |
+
|
| 40 |
+
The Gradio interface consists of several main sections:
|
| 41 |
+
|
| 42 |
+
1. **Service Configuration** - Model loading and initialization
|
| 43 |
+
2. **Required Inputs** - Task type, audio uploads, and generation mode
|
| 44 |
+
3. **Music Caption & Lyrics** - Text inputs for generation
|
| 45 |
+
4. **Optional Parameters** - Metadata like BPM, key, duration
|
| 46 |
+
5. **Advanced Settings** - Fine-grained control over generation
|
| 47 |
+
6. **Results** - Generated audio playback and management
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Service Configuration
|
| 52 |
+
|
| 53 |
+
### Model Selection
|
| 54 |
+
|
| 55 |
+
| Setting | Description |
|
| 56 |
+
|---------|-------------|
|
| 57 |
+
| **Checkpoint File** | Select a trained model checkpoint (if available) |
|
| 58 |
+
| **Main Model Path** | Choose the DiT model configuration (e.g., `acestep-v15-turbo`, `acestep-v15-turbo-rl`) |
|
| 59 |
+
| **Device** | Processing device: `auto` (recommended), `cuda`, or `cpu` |
|
| 60 |
+
|
| 61 |
+
### 5Hz LM Configuration
|
| 62 |
+
|
| 63 |
+
| Setting | Description |
|
| 64 |
+
|---------|-------------|
|
| 65 |
+
| **5Hz LM Model Path** | Select the language model (e.g., `acestep-5Hz-lm-0.6B`, `acestep-5Hz-lm-0.6B-v3`) |
|
| 66 |
+
| **5Hz LM Backend** | `vllm` (faster, recommended) or `pt` (PyTorch, more compatible) |
|
| 67 |
+
| **Initialize 5Hz LM** | Check to load the LM during initialization (required for thinking mode) |
|
| 68 |
+
|
| 69 |
+
### Performance Options
|
| 70 |
+
|
| 71 |
+
| Setting | Description |
|
| 72 |
+
|---------|-------------|
|
| 73 |
+
| **Use Flash Attention** | Enable for faster inference (requires flash_attn package) |
|
| 74 |
+
| **Offload to CPU** | Offload models to CPU when idle to save GPU memory |
|
| 75 |
+
| **Offload DiT to CPU** | Specifically offload the DiT model to CPU |
|
| 76 |
+
|
| 77 |
+
### LoRA Adapter
|
| 78 |
+
|
| 79 |
+
| Setting | Description |
|
| 80 |
+
|---------|-------------|
|
| 81 |
+
| **LoRA Path** | Path to trained LoRA adapter directory |
|
| 82 |
+
| **Load LoRA** | Load the specified LoRA adapter |
|
| 83 |
+
| **Unload** | Remove the currently loaded LoRA |
|
| 84 |
+
| **Use LoRA** | Enable/disable the loaded LoRA for inference |
|
| 85 |
+
|
| 86 |
+
### Initialization
|
| 87 |
+
|
| 88 |
+
Click **Initialize Service** to load the models. The status box will show progress and confirmation.
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## Generation Modes
|
| 93 |
+
|
| 94 |
+
### Simple Mode
|
| 95 |
+
|
| 96 |
+
Simple mode is designed for quick, natural language-based music generation.
|
| 97 |
+
|
| 98 |
+
**How to use:**
|
| 99 |
+
1. Select "Simple" in the Generation Mode radio button
|
| 100 |
+
2. Enter a natural language description in the "Song Description" field
|
| 101 |
+
3. Optionally check "Instrumental" if you don't want vocals
|
| 102 |
+
4. Optionally select a preferred vocal language
|
| 103 |
+
5. Click **Create Sample** to generate caption, lyrics, and metadata
|
| 104 |
+
6. Review the generated content in the expanded sections
|
| 105 |
+
7. Click **Generate Music** to create the audio
|
| 106 |
+
|
| 107 |
+
**Example descriptions:**
|
| 108 |
+
- "a soft Bengali love song for a quiet evening"
|
| 109 |
+
- "upbeat electronic dance music with heavy bass drops"
|
| 110 |
+
- "melancholic indie folk with acoustic guitar"
|
| 111 |
+
- "jazz trio playing in a smoky bar"
|
| 112 |
+
|
| 113 |
+
**Random Sample:** Click the 🎲 button to load a random example description.
|
| 114 |
+
|
| 115 |
+
### Custom Mode
|
| 116 |
+
|
| 117 |
+
Custom mode provides full control over all generation parameters.
|
| 118 |
+
|
| 119 |
+
**How to use:**
|
| 120 |
+
1. Select "Custom" in the Generation Mode radio button
|
| 121 |
+
2. Manually fill in the Caption and Lyrics fields
|
| 122 |
+
3. Set optional metadata (BPM, Key, Duration, etc.)
|
| 123 |
+
4. Optionally click **Format** to enhance your input using the LM
|
| 124 |
+
5. Configure advanced settings as needed
|
| 125 |
+
6. Click **Generate Music** to create the audio
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## Task Types
|
| 130 |
+
|
| 131 |
+
### text2music (Default)
|
| 132 |
+
|
| 133 |
+
Generate music from text descriptions and/or lyrics.
|
| 134 |
+
|
| 135 |
+
**Use case:** Creating new music from scratch based on prompts.
|
| 136 |
+
|
| 137 |
+
**Required inputs:** Caption or Lyrics (at least one)
|
| 138 |
+
|
| 139 |
+
### cover
|
| 140 |
+
|
| 141 |
+
Transform existing audio while maintaining structure but changing style.
|
| 142 |
+
|
| 143 |
+
**Use case:** Creating cover versions in different styles.
|
| 144 |
+
|
| 145 |
+
**Required inputs:**
|
| 146 |
+
- Source Audio (upload in Audio Uploads section)
|
| 147 |
+
- Caption describing the target style
|
| 148 |
+
|
| 149 |
+
**Key parameter:** `Audio Cover Strength` (0.0-1.0)
|
| 150 |
+
- Higher values maintain more of the original structure
|
| 151 |
+
- Lower values allow more creative freedom
|
| 152 |
+
|
| 153 |
+
### repaint
|
| 154 |
+
|
| 155 |
+
Regenerate a specific time segment of audio.
|
| 156 |
+
|
| 157 |
+
**Use case:** Fixing or modifying specific sections of generated music.
|
| 158 |
+
|
| 159 |
+
**Required inputs:**
|
| 160 |
+
- Source Audio
|
| 161 |
+
- Repainting Start (seconds)
|
| 162 |
+
- Repainting End (seconds, -1 for end of file)
|
| 163 |
+
- Caption describing the desired content
|
| 164 |
+
|
| 165 |
+
### lego (Base Model Only)
|
| 166 |
+
|
| 167 |
+
Generate a specific instrument track in context of existing audio.
|
| 168 |
+
|
| 169 |
+
**Use case:** Adding instrument layers to backing tracks.
|
| 170 |
+
|
| 171 |
+
**Required inputs:**
|
| 172 |
+
- Source Audio
|
| 173 |
+
- Track Name (select from dropdown)
|
| 174 |
+
- Caption describing the track characteristics
|
| 175 |
+
|
| 176 |
+
**Available tracks:** vocals, backing_vocals, drums, bass, guitar, keyboard, percussion, strings, synth, fx, brass, woodwinds
|
| 177 |
+
|
| 178 |
+
### extract (Base Model Only)
|
| 179 |
+
|
| 180 |
+
Extract/isolate a specific instrument track from mixed audio.
|
| 181 |
+
|
| 182 |
+
**Use case:** Stem separation, isolating instruments.
|
| 183 |
+
|
| 184 |
+
**Required inputs:**
|
| 185 |
+
- Source Audio
|
| 186 |
+
- Track Name to extract
|
| 187 |
+
|
| 188 |
+
### complete (Base Model Only)
|
| 189 |
+
|
| 190 |
+
Complete partial tracks with specified instruments.
|
| 191 |
+
|
| 192 |
+
**Use case:** Auto-arranging incomplete compositions.
|
| 193 |
+
|
| 194 |
+
**Required inputs:**
|
| 195 |
+
- Source Audio
|
| 196 |
+
- Track Names (multiple selection)
|
| 197 |
+
- Caption describing the desired style
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## Input Parameters
|
| 202 |
+
|
| 203 |
+
### Required Inputs
|
| 204 |
+
|
| 205 |
+
#### Task Type
|
| 206 |
+
Select the generation task from the dropdown. The instruction field updates automatically based on the selected task.
|
| 207 |
+
|
| 208 |
+
#### Audio Uploads
|
| 209 |
+
|
| 210 |
+
| Field | Description |
|
| 211 |
+
|-------|-------------|
|
| 212 |
+
| **Reference Audio** | Optional audio for style reference |
|
| 213 |
+
| **Source Audio** | Required for cover, repaint, lego, extract, complete tasks |
|
| 214 |
+
| **Convert to Codes** | Extract 5Hz semantic codes from source audio |
|
| 215 |
+
|
| 216 |
+
#### LM Codes Hints
|
| 217 |
+
|
| 218 |
+
Pre-computed audio semantic codes can be pasted here to guide generation. Use the **Transcribe** button to analyze codes and extract metadata.
|
| 219 |
+
|
| 220 |
+
### Music Caption
|
| 221 |
+
|
| 222 |
+
The text description of the desired music. Be specific about:
|
| 223 |
+
- Genre and style
|
| 224 |
+
- Instruments
|
| 225 |
+
- Mood and atmosphere
|
| 226 |
+
- Tempo feel (if not specifying BPM)
|
| 227 |
+
|
| 228 |
+
**Example:** "upbeat pop rock with electric guitars, driving drums, and catchy synth hooks"
|
| 229 |
+
|
| 230 |
+
Click 🎲 to load a random example caption.
|
| 231 |
+
|
| 232 |
+
### Lyrics
|
| 233 |
+
|
| 234 |
+
Enter lyrics with structure tags:
|
| 235 |
+
|
| 236 |
+
```
|
| 237 |
+
[Verse 1]
|
| 238 |
+
Walking down the street today
|
| 239 |
+
Thinking of the words you used to say
|
| 240 |
+
|
| 241 |
+
[Chorus]
|
| 242 |
+
I'm moving on, I'm staying strong
|
| 243 |
+
This is where I belong
|
| 244 |
+
|
| 245 |
+
[Verse 2]
|
| 246 |
+
...
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
**Instrumental checkbox:** Check this to generate instrumental music regardless of lyrics content.
|
| 250 |
+
|
| 251 |
+
**Vocal Language:** Select the language for vocals. Use "unknown" for auto-detection or instrumental tracks.
|
| 252 |
+
|
| 253 |
+
**Format button:** Click to enhance caption and lyrics using the 5Hz LM.
|
| 254 |
+
|
| 255 |
+
### Optional Parameters
|
| 256 |
+
|
| 257 |
+
| Parameter | Default | Description |
|
| 258 |
+
|-----------|---------|-------------|
|
| 259 |
+
| **BPM** | Auto | Tempo in beats per minute (30-300) |
|
| 260 |
+
| **Key Scale** | Auto | Musical key (e.g., "C Major", "Am", "F# minor") |
|
| 261 |
+
| **Time Signature** | Auto | Time signature: 2 (2/4), 3 (3/4), 4 (4/4), 6 (6/8) |
|
| 262 |
+
| **Audio Duration** | Auto/-1 | Target length in seconds (10-600). -1 for automatic |
|
| 263 |
+
| **Batch Size** | 2 | Number of audio variations to generate (1-8) |
|
| 264 |
+
|
| 265 |
+
---
|
| 266 |
+
|
| 267 |
+
## Advanced Settings
|
| 268 |
+
|
| 269 |
+
### DiT Parameters
|
| 270 |
+
|
| 271 |
+
| Parameter | Default | Description |
|
| 272 |
+
|-----------|---------|-------------|
|
| 273 |
+
| **Inference Steps** | 8 | Denoising steps. Turbo: 1-20, Base: 1-200 |
|
| 274 |
+
| **Guidance Scale** | 7.0 | CFG strength (base model only). Higher = follows prompt more |
|
| 275 |
+
| **Seed** | -1 | Random seed. Use comma-separated values for batches |
|
| 276 |
+
| **Random Seed** | ✓ | When checked, generates random seeds |
|
| 277 |
+
| **Audio Format** | mp3 | Output format: mp3, flac |
|
| 278 |
+
| **Shift** | 3.0 | Timestep shift factor (1.0-5.0). Recommended 3.0 for turbo |
|
| 279 |
+
| **Inference Method** | ode | ode (Euler, faster) or sde (stochastic) |
|
| 280 |
+
| **Custom Timesteps** | - | Override timesteps (e.g., "0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0") |
|
| 281 |
+
|
| 282 |
+
### Base Model Only Parameters
|
| 283 |
+
|
| 284 |
+
| Parameter | Default | Description |
|
| 285 |
+
|-----------|---------|-------------|
|
| 286 |
+
| **Use ADG** | ✗ | Enable Adaptive Dual Guidance for better quality |
|
| 287 |
+
| **CFG Interval Start** | 0.0 | When to start applying CFG (0.0-1.0) |
|
| 288 |
+
| **CFG Interval End** | 1.0 | When to stop applying CFG (0.0-1.0) |
|
| 289 |
+
|
| 290 |
+
### LM Parameters
|
| 291 |
+
|
| 292 |
+
| Parameter | Default | Description |
|
| 293 |
+
|-----------|---------|-------------|
|
| 294 |
+
| **LM Temperature** | 0.85 | Sampling temperature (0.0-2.0). Higher = more creative |
|
| 295 |
+
| **LM CFG Scale** | 2.0 | LM guidance strength (1.0-3.0) |
|
| 296 |
+
| **LM Top-K** | 0 | Top-K sampling. 0 disables |
|
| 297 |
+
| **LM Top-P** | 0.9 | Nucleus sampling (0.0-1.0) |
|
| 298 |
+
| **LM Negative Prompt** | "NO USER INPUT" | Negative prompt for CFG |
|
| 299 |
+
|
| 300 |
+
### CoT (Chain-of-Thought) Options
|
| 301 |
+
|
| 302 |
+
| Option | Default | Description |
|
| 303 |
+
|--------|---------|-------------|
|
| 304 |
+
| **CoT Metas** | ✓ | Generate metadata via LM reasoning |
|
| 305 |
+
| **CoT Language** | ✓ | Detect vocal language via LM |
|
| 306 |
+
| **Constrained Decoding Debug** | ✗ | Enable debug logging |
|
| 307 |
+
|
| 308 |
+
### Generation Options
|
| 309 |
+
|
| 310 |
+
| Option | Default | Description |
|
| 311 |
+
|--------|---------|-------------|
|
| 312 |
+
| **LM Codes Strength** | 1.0 | How strongly LM codes influence generation (0.0-1.0) |
|
| 313 |
+
| **Auto Score** | ✗ | Automatically calculate quality scores |
|
| 314 |
+
| **Auto LRC** | ✗ | Automatically generate lyrics timestamps |
|
| 315 |
+
| **LM Batch Chunk Size** | 8 | Max items per LM batch (GPU memory) |
|
| 316 |
+
|
| 317 |
+
### Main Generation Controls
|
| 318 |
+
|
| 319 |
+
| Control | Description |
|
| 320 |
+
|---------|-------------|
|
| 321 |
+
| **Think** | Enable 5Hz LM for code generation and metadata |
|
| 322 |
+
| **ParallelThinking** | Enable parallel LM batch processing |
|
| 323 |
+
| **CaptionRewrite** | Let LM enhance the input caption |
|
| 324 |
+
| **AutoGen** | Automatically start next batch after completion |
|
| 325 |
+
|
| 326 |
+
---
|
| 327 |
+
|
| 328 |
+
## Results Section
|
| 329 |
+
|
| 330 |
+
### Generated Audio
|
| 331 |
+
|
| 332 |
+
Up to 8 audio samples are displayed based on batch size. Each sample includes:
|
| 333 |
+
|
| 334 |
+
- **Audio Player** - Play, pause, and download the generated audio
|
| 335 |
+
- **Send To Src** - Send this audio to the Source Audio input for further processing
|
| 336 |
+
- **Save** - Save audio and metadata to a JSON file
|
| 337 |
+
- **Score** - Calculate perplexity-based quality score
|
| 338 |
+
- **LRC** - Generate lyrics timestamps (LRC format)
|
| 339 |
+
|
| 340 |
+
### Details Accordion
|
| 341 |
+
|
| 342 |
+
Click "Score & LRC & LM Codes" to expand and view:
|
| 343 |
+
- **LM Codes** - The 5Hz semantic codes for this sample
|
| 344 |
+
- **Quality Score** - Perplexity-based quality metric
|
| 345 |
+
- **Lyrics Timestamps** - LRC format timing data
|
| 346 |
+
|
| 347 |
+
### Batch Navigation
|
| 348 |
+
|
| 349 |
+
| Control | Description |
|
| 350 |
+
|---------|-------------|
|
| 351 |
+
| **◀ Previous** | View the previous batch |
|
| 352 |
+
| **Batch Indicator** | Shows current batch position (e.g., "Batch 1 / 3") |
|
| 353 |
+
| **Next Batch Status** | Shows background generation progress |
|
| 354 |
+
| **Next ▶** | View the next batch (triggers generation if AutoGen is on) |
|
| 355 |
+
|
| 356 |
+
### Restore Parameters
|
| 357 |
+
|
| 358 |
+
Click **Apply These Settings to UI** to restore all generation parameters from the current batch back to the input fields. Useful for iterating on a good result.
|
| 359 |
+
|
| 360 |
+
### Batch Results
|
| 361 |
+
|
| 362 |
+
The "Batch Results & Generation Details" accordion contains:
|
| 363 |
+
- **All Generated Files** - Download all files from all batches
|
| 364 |
+
- **Generation Details** - Detailed information about the generation process
|
| 365 |
+
|
| 366 |
+
---
|
| 367 |
+
|
| 368 |
+
## LoRA Training
|
| 369 |
+
|
| 370 |
+
The LoRA Training tab provides tools for creating custom LoRA adapters.
|
| 371 |
+
|
| 372 |
+
### Dataset Builder Tab
|
| 373 |
+
|
| 374 |
+
#### Step 1: Load or Scan
|
| 375 |
+
|
| 376 |
+
**Option A: Load Existing Dataset**
|
| 377 |
+
1. Enter the path to a previously saved dataset JSON
|
| 378 |
+
2. Click **Load**
|
| 379 |
+
|
| 380 |
+
**Option B: Scan New Directory**
|
| 381 |
+
1. Enter the path to your audio folder
|
| 382 |
+
2. Click **Scan** to find audio files (wav, mp3, flac, ogg, opus)
|
| 383 |
+
|
| 384 |
+
#### Step 2: Configure Dataset
|
| 385 |
+
|
| 386 |
+
| Setting | Description |
|
| 387 |
+
|---------|-------------|
|
| 388 |
+
| **Dataset Name** | Name for your dataset |
|
| 389 |
+
| **All Instrumental** | Check if all tracks have no vocals |
|
| 390 |
+
| **Custom Activation Tag** | Unique tag to activate this LoRA's style |
|
| 391 |
+
| **Tag Position** | Where to place the tag: Prepend, Append, or Replace caption |
|
| 392 |
+
|
| 393 |
+
#### Step 3: Auto-Label
|
| 394 |
+
|
| 395 |
+
Click **Auto-Label All** to generate metadata for all audio files:
|
| 396 |
+
- Caption (music description)
|
| 397 |
+
- BPM
|
| 398 |
+
- Key
|
| 399 |
+
- Time Signature
|
| 400 |
+
|
| 401 |
+
**Skip Metas** option will skip LLM labeling and use N/A values.
|
| 402 |
+
|
| 403 |
+
#### Step 4: Preview & Edit
|
| 404 |
+
|
| 405 |
+
Use the slider to select samples and manually edit:
|
| 406 |
+
- Caption
|
| 407 |
+
- Lyrics
|
| 408 |
+
- BPM, Key, Time Signature
|
| 409 |
+
- Language
|
| 410 |
+
- Instrumental flag
|
| 411 |
+
|
| 412 |
+
Click **Save Changes** to update the sample.
|
| 413 |
+
|
| 414 |
+
#### Step 5: Save Dataset
|
| 415 |
+
|
| 416 |
+
Enter a save path and click **Save Dataset** to export as JSON.
|
| 417 |
+
|
| 418 |
+
#### Step 6: Preprocess
|
| 419 |
+
|
| 420 |
+
Convert the dataset to pre-computed tensors for fast training:
|
| 421 |
+
1. Optionally load an existing dataset JSON
|
| 422 |
+
2. Set the tensor output directory
|
| 423 |
+
3. Click **Preprocess**
|
| 424 |
+
|
| 425 |
+
This encodes audio to VAE latents, text to embeddings, and runs the condition encoder.
|
| 426 |
+
|
| 427 |
+
### Train LoRA Tab
|
| 428 |
+
|
| 429 |
+
#### Dataset Selection
|
| 430 |
+
|
| 431 |
+
Enter the path to preprocessed tensors directory and click **Load Dataset**.
|
| 432 |
+
|
| 433 |
+
#### LoRA Settings
|
| 434 |
+
|
| 435 |
+
| Setting | Default | Description |
|
| 436 |
+
|---------|---------|-------------|
|
| 437 |
+
| **LoRA Rank (r)** | 64 | Capacity of LoRA. Higher = more capacity, more memory |
|
| 438 |
+
| **LoRA Alpha** | 128 | Scaling factor (typically 2x rank) |
|
| 439 |
+
| **LoRA Dropout** | 0.1 | Dropout rate for regularization |
|
| 440 |
+
|
| 441 |
+
#### Training Parameters
|
| 442 |
+
|
| 443 |
+
| Setting | Default | Description |
|
| 444 |
+
|---------|---------|-------------|
|
| 445 |
+
| **Learning Rate** | 1e-4 | Optimization learning rate |
|
| 446 |
+
| **Max Epochs** | 500 | Maximum training epochs |
|
| 447 |
+
| **Batch Size** | 1 | Training batch size |
|
| 448 |
+
| **Gradient Accumulation** | 1 | Effective batch = batch_size × accumulation |
|
| 449 |
+
| **Save Every N Epochs** | 200 | Checkpoint save frequency |
|
| 450 |
+
| **Shift** | 3.0 | Timestep shift for turbo model |
|
| 451 |
+
| **Seed** | 42 | Random seed for reproducibility |
|
| 452 |
+
|
| 453 |
+
#### Training Controls
|
| 454 |
+
|
| 455 |
+
- **Start Training** - Begin the training process
|
| 456 |
+
- **Stop Training** - Interrupt training
|
| 457 |
+
- **Training Progress** - Shows current epoch and loss
|
| 458 |
+
- **Training Log** - Detailed training output
|
| 459 |
+
- **Training Loss Plot** - Visual loss curve
|
| 460 |
+
|
| 461 |
+
#### Export LoRA
|
| 462 |
+
|
| 463 |
+
After training, export the final adapter:
|
| 464 |
+
1. Enter the export path
|
| 465 |
+
2. Click **Export LoRA**
|
| 466 |
+
|
| 467 |
+
---
|
| 468 |
+
|
| 469 |
+
## Tips and Best Practices
|
| 470 |
+
|
| 471 |
+
### For Best Quality
|
| 472 |
+
|
| 473 |
+
1. **Use thinking mode** - Keep "Think" checkbox enabled for LM-enhanced generation
|
| 474 |
+
2. **Be specific in captions** - Include genre, instruments, mood, and style details
|
| 475 |
+
3. **Let LM detect metadata** - Leave BPM/Key/Duration empty for auto-detection
|
| 476 |
+
4. **Use batch generation** - Generate 2-4 variations and pick the best
|
| 477 |
+
|
| 478 |
+
### For Faster Generation
|
| 479 |
+
|
| 480 |
+
1. **Use turbo model** - Select `acestep-v15-turbo` or `acestep-v15-turbo-rl`
|
| 481 |
+
2. **Keep inference steps at 8** - Default is optimal for turbo
|
| 482 |
+
3. **Reduce batch size** - Lower batch size if you need quick results
|
| 483 |
+
4. **Disable AutoGen** - Manual control over batch generation
|
| 484 |
+
|
| 485 |
+
### For Consistent Results
|
| 486 |
+
|
| 487 |
+
1. **Set a specific seed** - Uncheck "Random Seed" and enter a seed value
|
| 488 |
+
2. **Save good results** - Use "Save" to export parameters for reproduction
|
| 489 |
+
3. **Use "Apply These Settings"** - Restore parameters from a good batch
|
| 490 |
+
|
| 491 |
+
### For Long-form Music
|
| 492 |
+
|
| 493 |
+
1. **Set explicit duration** - Specify duration in seconds
|
| 494 |
+
2. **Use repaint task** - Fix problematic sections after initial generation
|
| 495 |
+
3. **Chain generations** - Use "Send To Src" to build upon previous results
|
| 496 |
+
|
| 497 |
+
### For Style Consistency
|
| 498 |
+
|
| 499 |
+
1. **Train a LoRA** - Create a custom adapter for your style
|
| 500 |
+
2. **Use reference audio** - Upload style reference in Audio Uploads
|
| 501 |
+
3. **Use consistent captions** - Maintain similar descriptive language
|
| 502 |
+
|
| 503 |
+
### Troubleshooting
|
| 504 |
+
|
| 505 |
+
**No audio generated:**
|
| 506 |
+
- Check that the model is initialized (green status message)
|
| 507 |
+
- Ensure 5Hz LM is initialized if using thinking mode
|
| 508 |
+
- Check the status output for error messages
|
| 509 |
+
|
| 510 |
+
**Poor quality results:**
|
| 511 |
+
- Increase inference steps (for base model)
|
| 512 |
+
- Adjust guidance scale
|
| 513 |
+
- Try different seeds
|
| 514 |
+
- Make caption more specific
|
| 515 |
+
|
| 516 |
+
**Out of memory:**
|
| 517 |
+
- Reduce batch size
|
| 518 |
+
- Enable CPU offloading
|
| 519 |
+
- Reduce LM batch chunk size
|
| 520 |
+
|
| 521 |
+
**LM not working:**
|
| 522 |
+
- Ensure "Initialize 5Hz LM" was checked during initialization
|
| 523 |
+
- Check that a valid LM model path is selected
|
| 524 |
+
- Verify vllm or PyTorch backend is available
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
## Keyboard Shortcuts
|
| 529 |
+
|
| 530 |
+
The Gradio interface supports standard web shortcuts:
|
| 531 |
+
- **Tab** - Move between input fields
|
| 532 |
+
- **Enter** - Submit text inputs
|
| 533 |
+
- **Space** - Toggle checkboxes
|
| 534 |
+
|
| 535 |
+
---
|
| 536 |
+
|
| 537 |
+
## Language Support
|
| 538 |
+
|
| 539 |
+
The interface supports multiple UI languages:
|
| 540 |
+
- **English** (en)
|
| 541 |
+
- **Chinese** (zh)
|
| 542 |
+
- **Japanese** (ja)
|
| 543 |
+
|
| 544 |
+
Select your preferred language in the Service Configuration section.
|
| 545 |
+
|
| 546 |
+
---
|
| 547 |
+
|
| 548 |
+
For more information, see:
|
| 549 |
+
- Main README: [`../../README.md`](../../README.md)
|
| 550 |
+
- REST API Documentation: [`API.md`](API.md)
|
| 551 |
+
- Python Inference API: [`INFERENCE.md`](INFERENCE.md)
|
INFERENCE.md → docs/en/INFERENCE.md
RENAMED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
# ACE-Step Inference API Documentation
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
This document provides comprehensive documentation for the ACE-Step inference API, including parameter specifications for all supported task types.
|
| 4 |
|
| 5 |
## Table of Contents
|
|
@@ -9,6 +13,7 @@ This document provides comprehensive documentation for the ACE-Step inference AP
|
|
| 9 |
- [GenerationParams Parameters](#generationparams-parameters)
|
| 10 |
- [GenerationConfig Parameters](#generationconfig-parameters)
|
| 11 |
- [Task Types](#task-types)
|
|
|
|
| 12 |
- [Complete Examples](#complete-examples)
|
| 13 |
- [Best Practices](#best-practices)
|
| 14 |
|
|
@@ -71,7 +76,9 @@ else:
|
|
| 71 |
|
| 72 |
## API Overview
|
| 73 |
|
| 74 |
-
### Main
|
|
|
|
|
|
|
| 75 |
|
| 76 |
```python
|
| 77 |
def generate_music(
|
|
@@ -84,6 +91,63 @@ def generate_music(
|
|
| 84 |
) -> GenerationResult
|
| 85 |
```
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
### Configuration Objects
|
| 88 |
|
| 89 |
The API uses two configuration dataclasses:
|
|
@@ -123,6 +187,9 @@ class GenerationParams:
|
|
| 123 |
use_adg: bool = False
|
| 124 |
cfg_interval_start: float = 0.0
|
| 125 |
cfg_interval_end: float = 1.0
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
repainting_start: float = 0.0
|
| 128 |
repainting_end: float = -1
|
|
@@ -165,7 +232,9 @@ class GenerationConfig:
|
|
| 165 |
audio_format: str = "flac"
|
| 166 |
```
|
| 167 |
|
| 168 |
-
### Result
|
|
|
|
|
|
|
| 169 |
|
| 170 |
```python
|
| 171 |
@dataclass
|
|
@@ -196,6 +265,67 @@ Each item in `audios` list contains:
|
|
| 196 |
}
|
| 197 |
```
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
---
|
| 200 |
|
| 201 |
## GenerationParams Parameters
|
|
@@ -222,7 +352,7 @@ Each item in `audios` list contains:
|
|
| 222 |
|
| 223 |
| Parameter | Type | Default | Description |
|
| 224 |
|-----------|------|---------|-------------|
|
| 225 |
-
| `inference_steps` | `int` | `8` | Number of denoising steps. Turbo model: 1-
|
| 226 |
| `guidance_scale` | `float` | `7.0` | Classifier-free guidance scale (1.0-15.0). Higher values increase adherence to text prompt. Only supported for non-turbo model. Typical range: 5.0-9.0. |
|
| 227 |
| `seed` | `int` | `-1` | Random seed for reproducibility. Use `-1` for random seed, or any positive integer for fixed seed. |
|
| 228 |
|
|
@@ -233,6 +363,9 @@ Each item in `audios` list contains:
|
|
| 233 |
| `use_adg` | `bool` | `False` | Use Adaptive Dual Guidance (base model only). Improves quality at the cost of speed. |
|
| 234 |
| `cfg_interval_start` | `float` | `0.0` | CFG application start ratio (0.0-1.0). Controls when to start applying classifier-free guidance. |
|
| 235 |
| `cfg_interval_end` | `float` | `1.0` | CFG application end ratio (0.0-1.0). Controls when to stop applying classifier-free guidance. |
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
### Task-Specific Parameters
|
| 238 |
|
|
@@ -475,6 +608,132 @@ params = GenerationParams(
|
|
| 475 |
|
| 476 |
---
|
| 477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
## Complete Examples
|
| 479 |
|
| 480 |
### Example 1: Simple Text-to-Music Generation
|
|
@@ -528,7 +787,95 @@ config = GenerationConfig(batch_size=1)
|
|
| 528 |
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 529 |
```
|
| 530 |
|
| 531 |
-
### Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
|
| 533 |
```python
|
| 534 |
params = GenerationParams(
|
|
@@ -551,24 +898,7 @@ if result.extra_outputs.get("lm_metadata"):
|
|
| 551 |
print(f"LM detected Key: {lm_meta.get('keyscale')}")
|
| 552 |
```
|
| 553 |
|
| 554 |
-
### Example
|
| 555 |
-
|
| 556 |
-
```python
|
| 557 |
-
params = GenerationParams(
|
| 558 |
-
task_type="repaint",
|
| 559 |
-
src_audio="generated_track.mp3",
|
| 560 |
-
repainting_start=15.0, # Start at 15 seconds
|
| 561 |
-
repainting_end=25.0, # End at 25 seconds
|
| 562 |
-
caption="dramatic orchestral buildup",
|
| 563 |
-
inference_steps=32, # Higher quality for base model
|
| 564 |
-
)
|
| 565 |
-
|
| 566 |
-
config = GenerationConfig(batch_size=1)
|
| 567 |
-
|
| 568 |
-
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 569 |
-
```
|
| 570 |
-
|
| 571 |
-
### Example 5: Batch Generation with Specific Seeds
|
| 572 |
|
| 573 |
```python
|
| 574 |
params = GenerationParams(
|
|
@@ -591,7 +921,7 @@ if result.success:
|
|
| 591 |
print(f" Seed {audio['params']['seed']}: {audio['path']}")
|
| 592 |
```
|
| 593 |
|
| 594 |
-
### Example
|
| 595 |
|
| 596 |
```python
|
| 597 |
params = GenerationParams(
|
|
@@ -602,6 +932,7 @@ params = GenerationParams(
|
|
| 602 |
use_adg=True, # Adaptive Dual Guidance
|
| 603 |
cfg_interval_start=0.0,
|
| 604 |
cfg_interval_end=1.0,
|
|
|
|
| 605 |
seed=42, # Reproducible results
|
| 606 |
)
|
| 607 |
|
|
@@ -614,54 +945,25 @@ config = GenerationConfig(
|
|
| 614 |
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 615 |
```
|
| 616 |
|
| 617 |
-
### Example
|
| 618 |
-
|
| 619 |
-
```python
|
| 620 |
-
params = GenerationParams(
|
| 621 |
-
task_type="extract",
|
| 622 |
-
src_audio="full_song_mix.mp3",
|
| 623 |
-
instruction="Extract the vocals track from the audio:",
|
| 624 |
-
)
|
| 625 |
-
|
| 626 |
-
config = GenerationConfig(batch_size=1)
|
| 627 |
-
|
| 628 |
-
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 629 |
-
|
| 630 |
-
if result.success:
|
| 631 |
-
print(f"Extracted vocals: {result.audios[0]['path']}")
|
| 632 |
-
```
|
| 633 |
-
|
| 634 |
-
### Example 8: Add Guitar Track (Lego)
|
| 635 |
|
| 636 |
```python
|
| 637 |
-
|
| 638 |
-
task_type="lego",
|
| 639 |
-
src_audio="drums_and_bass.mp3",
|
| 640 |
-
instruction="Generate the guitar track based on the audio context:",
|
| 641 |
-
caption="funky rhythm guitar with wah-wah effect",
|
| 642 |
-
repainting_start=0.0,
|
| 643 |
-
repainting_end=-1, # Full duration
|
| 644 |
-
)
|
| 645 |
-
|
| 646 |
-
config = GenerationConfig(batch_size=1)
|
| 647 |
-
|
| 648 |
-
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 649 |
-
```
|
| 650 |
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
caption="upbeat electronic dance music",
|
| 657 |
-
instrumental=True, # Force instrumental output
|
| 658 |
-
duration=120,
|
| 659 |
-
bpm=128,
|
| 660 |
)
|
| 661 |
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
```
|
| 666 |
|
| 667 |
---
|
|
@@ -697,12 +999,13 @@ caption="fast slow music" # Conflicting tempos
|
|
| 697 |
- Use base model with `inference_steps=64` or higher
|
| 698 |
- Enable `use_adg=True`
|
| 699 |
- Set `guidance_scale=7.0-9.0`
|
|
|
|
| 700 |
- Use lossless audio format (`audio_format="wav"`)
|
| 701 |
|
| 702 |
**For Speed**:
|
| 703 |
- Use turbo model with `inference_steps=8`
|
| 704 |
- Disable ADG (`use_adg=False`)
|
| 705 |
-
-
|
| 706 |
- Use compressed format (`audio_format="mp3"`) or default FLAC
|
| 707 |
|
| 708 |
**For Consistency**:
|
|
@@ -808,6 +1111,9 @@ if result.success:
|
|
| 808 |
**Issue**: Seeds not being respected
|
| 809 |
- **Solution**: Set `use_random_seed=False` in config and provide `seeds` list or `seed` in params
|
| 810 |
|
|
|
|
|
|
|
|
|
|
| 811 |
---
|
| 812 |
|
| 813 |
## API Reference Summary
|
|
@@ -852,7 +1158,16 @@ class GenerationResult:
|
|
| 852 |
|
| 853 |
## Version History
|
| 854 |
|
| 855 |
-
- **v1.5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
- Split `GenerationConfig` into `GenerationParams` and `GenerationConfig`
|
| 857 |
- Renamed parameters for consistency (`key_scale` → `keyscale`, `time_signature` → `timesignature`, `audio_duration` → `duration`, `use_llm_thinking` → `thinking`, `audio_code_string` → `audio_codes`)
|
| 858 |
- Added `instrumental` parameter
|
|
@@ -864,7 +1179,7 @@ class GenerationResult:
|
|
| 864 |
- Simplified `GenerationResult` structure with unified `audios` list
|
| 865 |
- Added unified `time_costs` in `extra_outputs`
|
| 866 |
|
| 867 |
-
- **v1.5**:
|
| 868 |
- Introduced `GenerationConfig` and `GenerationResult` dataclasses
|
| 869 |
- Simplified parameter passing
|
| 870 |
- Added comprehensive documentation
|
|
@@ -872,6 +1187,7 @@ class GenerationResult:
|
|
| 872 |
---
|
| 873 |
|
| 874 |
For more information, see:
|
| 875 |
-
- Main README: [
|
| 876 |
- REST API Documentation: [`API.md`](API.md)
|
|
|
|
| 877 |
- Project repository: [ACE-Step-1.5](https://github.com/yourusername/ACE-Step-1.5)
|
|
|
|
| 1 |
# ACE-Step Inference API Documentation
|
| 2 |
|
| 3 |
+
**Language / 语言 / 言語:** [English](INFERENCE.md) | [中文](../zh/INFERENCE.md) | [日本語](../ja/INFERENCE.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
This document provides comprehensive documentation for the ACE-Step inference API, including parameter specifications for all supported task types.
|
| 8 |
|
| 9 |
## Table of Contents
|
|
|
|
| 13 |
- [GenerationParams Parameters](#generationparams-parameters)
|
| 14 |
- [GenerationConfig Parameters](#generationconfig-parameters)
|
| 15 |
- [Task Types](#task-types)
|
| 16 |
+
- [Helper Functions](#helper-functions)
|
| 17 |
- [Complete Examples](#complete-examples)
|
| 18 |
- [Best Practices](#best-practices)
|
| 19 |
|
|
|
|
| 76 |
|
| 77 |
## API Overview
|
| 78 |
|
| 79 |
+
### Main Functions
|
| 80 |
+
|
| 81 |
+
#### generate_music
|
| 82 |
|
| 83 |
```python
|
| 84 |
def generate_music(
|
|
|
|
| 91 |
) -> GenerationResult
|
| 92 |
```
|
| 93 |
|
| 94 |
+
Main function for generating music using the ACE-Step model.
|
| 95 |
+
|
| 96 |
+
#### understand_music
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
def understand_music(
|
| 100 |
+
llm_handler,
|
| 101 |
+
audio_codes: str,
|
| 102 |
+
temperature: float = 0.85,
|
| 103 |
+
top_k: Optional[int] = None,
|
| 104 |
+
top_p: Optional[float] = None,
|
| 105 |
+
repetition_penalty: float = 1.0,
|
| 106 |
+
use_constrained_decoding: bool = True,
|
| 107 |
+
constrained_decoding_debug: bool = False,
|
| 108 |
+
) -> UnderstandResult
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
Analyze audio semantic codes and extract metadata (caption, lyrics, BPM, key, etc.).
|
| 112 |
+
|
| 113 |
+
#### create_sample
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
def create_sample(
|
| 117 |
+
llm_handler,
|
| 118 |
+
query: str,
|
| 119 |
+
instrumental: bool = False,
|
| 120 |
+
vocal_language: Optional[str] = None,
|
| 121 |
+
temperature: float = 0.85,
|
| 122 |
+
top_k: Optional[int] = None,
|
| 123 |
+
top_p: Optional[float] = None,
|
| 124 |
+
repetition_penalty: float = 1.0,
|
| 125 |
+
use_constrained_decoding: bool = True,
|
| 126 |
+
constrained_decoding_debug: bool = False,
|
| 127 |
+
) -> CreateSampleResult
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
Generate a complete music sample (caption, lyrics, metadata) from a natural language description.
|
| 131 |
+
|
| 132 |
+
#### format_sample
|
| 133 |
+
|
| 134 |
+
```python
|
| 135 |
+
def format_sample(
|
| 136 |
+
llm_handler,
|
| 137 |
+
caption: str,
|
| 138 |
+
lyrics: str,
|
| 139 |
+
user_metadata: Optional[Dict[str, Any]] = None,
|
| 140 |
+
temperature: float = 0.85,
|
| 141 |
+
top_k: Optional[int] = None,
|
| 142 |
+
top_p: Optional[float] = None,
|
| 143 |
+
repetition_penalty: float = 1.0,
|
| 144 |
+
use_constrained_decoding: bool = True,
|
| 145 |
+
constrained_decoding_debug: bool = False,
|
| 146 |
+
) -> FormatSampleResult
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
Format and enhance user-provided caption and lyrics, generating structured metadata.
|
| 150 |
+
|
| 151 |
### Configuration Objects
|
| 152 |
|
| 153 |
The API uses two configuration dataclasses:
|
|
|
|
| 187 |
use_adg: bool = False
|
| 188 |
cfg_interval_start: float = 0.0
|
| 189 |
cfg_interval_end: float = 1.0
|
| 190 |
+
shift: float = 1.0 # NEW: Timestep shift factor
|
| 191 |
+
infer_method: str = "ode" # NEW: Diffusion inference method
|
| 192 |
+
timesteps: Optional[List[float]] = None # NEW: Custom timesteps
|
| 193 |
|
| 194 |
repainting_start: float = 0.0
|
| 195 |
repainting_end: float = -1
|
|
|
|
| 232 |
audio_format: str = "flac"
|
| 233 |
```
|
| 234 |
|
| 235 |
+
### Result Objects
|
| 236 |
+
|
| 237 |
+
**GenerationResult** - Result of music generation:
|
| 238 |
|
| 239 |
```python
|
| 240 |
@dataclass
|
|
|
|
| 265 |
}
|
| 266 |
```
|
| 267 |
|
| 268 |
+
**UnderstandResult** - Result of music understanding:
|
| 269 |
+
|
| 270 |
+
```python
|
| 271 |
+
@dataclass
|
| 272 |
+
class UnderstandResult:
|
| 273 |
+
# Metadata Fields
|
| 274 |
+
caption: str = ""
|
| 275 |
+
lyrics: str = ""
|
| 276 |
+
bpm: Optional[int] = None
|
| 277 |
+
duration: Optional[float] = None
|
| 278 |
+
keyscale: str = ""
|
| 279 |
+
language: str = ""
|
| 280 |
+
timesignature: str = ""
|
| 281 |
+
|
| 282 |
+
# Status
|
| 283 |
+
status_message: str = ""
|
| 284 |
+
success: bool = True
|
| 285 |
+
error: Optional[str] = None
|
| 286 |
+
```
|
| 287 |
+
|
| 288 |
+
**CreateSampleResult** - Result of sample creation:
|
| 289 |
+
|
| 290 |
+
```python
|
| 291 |
+
@dataclass
|
| 292 |
+
class CreateSampleResult:
|
| 293 |
+
# Metadata Fields
|
| 294 |
+
caption: str = ""
|
| 295 |
+
lyrics: str = ""
|
| 296 |
+
bpm: Optional[int] = None
|
| 297 |
+
duration: Optional[float] = None
|
| 298 |
+
keyscale: str = ""
|
| 299 |
+
language: str = ""
|
| 300 |
+
timesignature: str = ""
|
| 301 |
+
instrumental: bool = False
|
| 302 |
+
|
| 303 |
+
# Status
|
| 304 |
+
status_message: str = ""
|
| 305 |
+
success: bool = True
|
| 306 |
+
error: Optional[str] = None
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
**FormatSampleResult** - Result of sample formatting:
|
| 310 |
+
|
| 311 |
+
```python
|
| 312 |
+
@dataclass
|
| 313 |
+
class FormatSampleResult:
|
| 314 |
+
# Metadata Fields
|
| 315 |
+
caption: str = ""
|
| 316 |
+
lyrics: str = ""
|
| 317 |
+
bpm: Optional[int] = None
|
| 318 |
+
duration: Optional[float] = None
|
| 319 |
+
keyscale: str = ""
|
| 320 |
+
language: str = ""
|
| 321 |
+
timesignature: str = ""
|
| 322 |
+
|
| 323 |
+
# Status
|
| 324 |
+
status_message: str = ""
|
| 325 |
+
success: bool = True
|
| 326 |
+
error: Optional[str] = None
|
| 327 |
+
```
|
| 328 |
+
|
| 329 |
---
|
| 330 |
|
| 331 |
## GenerationParams Parameters
|
|
|
|
| 352 |
|
| 353 |
| Parameter | Type | Default | Description |
|
| 354 |
|-----------|------|---------|-------------|
|
| 355 |
+
| `inference_steps` | `int` | `8` | Number of denoising steps. Turbo model: 1-20 (recommended 8). Base model: 1-200 (recommended 32-64). Higher = better quality but slower. |
|
| 356 |
| `guidance_scale` | `float` | `7.0` | Classifier-free guidance scale (1.0-15.0). Higher values increase adherence to text prompt. Only supported for non-turbo model. Typical range: 5.0-9.0. |
|
| 357 |
| `seed` | `int` | `-1` | Random seed for reproducibility. Use `-1` for random seed, or any positive integer for fixed seed. |
|
| 358 |
|
|
|
|
| 363 |
| `use_adg` | `bool` | `False` | Use Adaptive Dual Guidance (base model only). Improves quality at the cost of speed. |
|
| 364 |
| `cfg_interval_start` | `float` | `0.0` | CFG application start ratio (0.0-1.0). Controls when to start applying classifier-free guidance. |
|
| 365 |
| `cfg_interval_end` | `float` | `1.0` | CFG application end ratio (0.0-1.0). Controls when to stop applying classifier-free guidance. |
|
| 366 |
+
| `shift` | `float` | `1.0` | Timestep shift factor (range 1.0-5.0, default 1.0). When != 1.0, applies `t = shift * t / (1 + (shift - 1) * t)` to timesteps. Recommended 3.0 for turbo models. |
|
| 367 |
+
| `infer_method` | `str` | `"ode"` | Diffusion inference method. `"ode"` (Euler) is faster and deterministic. `"sde"` (stochastic) may produce different results with variance. |
|
| 368 |
+
| `timesteps` | `Optional[List[float]]` | `None` | Custom timesteps as a list of floats from 1.0 to 0.0 (e.g., `[0.97, 0.76, 0.615, 0.5, 0.395, 0.28, 0.18, 0.085, 0]`). If provided, overrides `inference_steps` and `shift`. |
|
| 369 |
|
| 370 |
### Task-Specific Parameters
|
| 371 |
|
|
|
|
| 608 |
|
| 609 |
---
|
| 610 |
|
| 611 |
+
## Helper Functions
|
| 612 |
+
|
| 613 |
+
### understand_music
|
| 614 |
+
|
| 615 |
+
Analyze audio codes to extract metadata about the music.
|
| 616 |
+
|
| 617 |
+
```python
|
| 618 |
+
from acestep.inference import understand_music
|
| 619 |
+
|
| 620 |
+
result = understand_music(
|
| 621 |
+
llm_handler=llm_handler,
|
| 622 |
+
audio_codes="<|audio_code_123|><|audio_code_456|>...",
|
| 623 |
+
temperature=0.85,
|
| 624 |
+
use_constrained_decoding=True,
|
| 625 |
+
)
|
| 626 |
+
|
| 627 |
+
if result.success:
|
| 628 |
+
print(f"Caption: {result.caption}")
|
| 629 |
+
print(f"Lyrics: {result.lyrics}")
|
| 630 |
+
print(f"BPM: {result.bpm}")
|
| 631 |
+
print(f"Key: {result.keyscale}")
|
| 632 |
+
print(f"Duration: {result.duration}s")
|
| 633 |
+
print(f"Language: {result.language}")
|
| 634 |
+
else:
|
| 635 |
+
print(f"Error: {result.error}")
|
| 636 |
+
```
|
| 637 |
+
|
| 638 |
+
**Use Cases**:
|
| 639 |
+
- Analyze existing music
|
| 640 |
+
- Extract metadata from audio codes
|
| 641 |
+
- Reverse-engineer generation parameters
|
| 642 |
+
|
| 643 |
+
---
|
| 644 |
+
|
| 645 |
+
### create_sample
|
| 646 |
+
|
| 647 |
+
Generate a complete music sample from a natural language description. This is the "Simple Mode" / "Inspiration Mode" feature.
|
| 648 |
+
|
| 649 |
+
```python
|
| 650 |
+
from acestep.inference import create_sample
|
| 651 |
+
|
| 652 |
+
result = create_sample(
|
| 653 |
+
llm_handler=llm_handler,
|
| 654 |
+
query="a soft Bengali love song for a quiet evening",
|
| 655 |
+
instrumental=False,
|
| 656 |
+
vocal_language="bn", # Optional: constrain to Bengali
|
| 657 |
+
temperature=0.85,
|
| 658 |
+
)
|
| 659 |
+
|
| 660 |
+
if result.success:
|
| 661 |
+
print(f"Caption: {result.caption}")
|
| 662 |
+
print(f"Lyrics: {result.lyrics}")
|
| 663 |
+
print(f"BPM: {result.bpm}")
|
| 664 |
+
print(f"Duration: {result.duration}s")
|
| 665 |
+
print(f"Key: {result.keyscale}")
|
| 666 |
+
print(f"Is Instrumental: {result.instrumental}")
|
| 667 |
+
|
| 668 |
+
# Use with generate_music
|
| 669 |
+
params = GenerationParams(
|
| 670 |
+
caption=result.caption,
|
| 671 |
+
lyrics=result.lyrics,
|
| 672 |
+
bpm=result.bpm,
|
| 673 |
+
duration=result.duration,
|
| 674 |
+
keyscale=result.keyscale,
|
| 675 |
+
vocal_language=result.language,
|
| 676 |
+
)
|
| 677 |
+
else:
|
| 678 |
+
print(f"Error: {result.error}")
|
| 679 |
+
```
|
| 680 |
+
|
| 681 |
+
**Parameters**:
|
| 682 |
+
|
| 683 |
+
| Parameter | Type | Default | Description |
|
| 684 |
+
|-----------|------|---------|-------------|
|
| 685 |
+
| `query` | `str` | required | Natural language description of desired music |
|
| 686 |
+
| `instrumental` | `bool` | `False` | Whether to generate instrumental music |
|
| 687 |
+
| `vocal_language` | `Optional[str]` | `None` | Constrain lyrics to specific language (e.g., "en", "zh", "bn") |
|
| 688 |
+
| `temperature` | `float` | `0.85` | Sampling temperature |
|
| 689 |
+
| `top_k` | `Optional[int]` | `None` | Top-k sampling (None disables) |
|
| 690 |
+
| `top_p` | `Optional[float]` | `None` | Top-p sampling (None disables) |
|
| 691 |
+
| `repetition_penalty` | `float` | `1.0` | Repetition penalty |
|
| 692 |
+
| `use_constrained_decoding` | `bool` | `True` | Use FSM-based constrained decoding |
|
| 693 |
+
|
| 694 |
+
---
|
| 695 |
+
|
| 696 |
+
### format_sample
|
| 697 |
+
|
| 698 |
+
Format and enhance user-provided caption and lyrics, generating structured metadata.
|
| 699 |
+
|
| 700 |
+
```python
|
| 701 |
+
from acestep.inference import format_sample
|
| 702 |
+
|
| 703 |
+
result = format_sample(
|
| 704 |
+
llm_handler=llm_handler,
|
| 705 |
+
caption="Latin pop, reggaeton",
|
| 706 |
+
lyrics="[Verse 1]\nBailando en la noche...",
|
| 707 |
+
user_metadata={"bpm": 95}, # Optional: constrain specific values
|
| 708 |
+
temperature=0.85,
|
| 709 |
+
)
|
| 710 |
+
|
| 711 |
+
if result.success:
|
| 712 |
+
print(f"Enhanced Caption: {result.caption}")
|
| 713 |
+
print(f"Formatted Lyrics: {result.lyrics}")
|
| 714 |
+
print(f"BPM: {result.bpm}")
|
| 715 |
+
print(f"Duration: {result.duration}s")
|
| 716 |
+
print(f"Key: {result.keyscale}")
|
| 717 |
+
print(f"Detected Language: {result.language}")
|
| 718 |
+
else:
|
| 719 |
+
print(f"Error: {result.error}")
|
| 720 |
+
```
|
| 721 |
+
|
| 722 |
+
**Parameters**:
|
| 723 |
+
|
| 724 |
+
| Parameter | Type | Default | Description |
|
| 725 |
+
|-----------|------|---------|-------------|
|
| 726 |
+
| `caption` | `str` | required | User's caption/description |
|
| 727 |
+
| `lyrics` | `str` | required | User's lyrics with structure tags |
|
| 728 |
+
| `user_metadata` | `Optional[Dict]` | `None` | Constrain specific metadata values (bpm, duration, keyscale, timesignature, language) |
|
| 729 |
+
| `temperature` | `float` | `0.85` | Sampling temperature |
|
| 730 |
+
| `top_k` | `Optional[int]` | `None` | Top-k sampling (None disables) |
|
| 731 |
+
| `top_p` | `Optional[float]` | `None` | Top-p sampling (None disables) |
|
| 732 |
+
| `repetition_penalty` | `float` | `1.0` | Repetition penalty |
|
| 733 |
+
| `use_constrained_decoding` | `bool` | `True` | Use FSM-based constrained decoding |
|
| 734 |
+
|
| 735 |
+
---
|
| 736 |
+
|
| 737 |
## Complete Examples
|
| 738 |
|
| 739 |
### Example 1: Simple Text-to-Music Generation
|
|
|
|
| 787 |
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 788 |
```
|
| 789 |
|
| 790 |
+
### Example 3: Using Custom Timesteps
|
| 791 |
+
|
| 792 |
+
```python
|
| 793 |
+
params = GenerationParams(
|
| 794 |
+
task_type="text2music",
|
| 795 |
+
caption="jazz fusion with complex harmonies",
|
| 796 |
+
# Custom 9-step schedule
|
| 797 |
+
timesteps=[0.97, 0.76, 0.615, 0.5, 0.395, 0.28, 0.18, 0.085, 0],
|
| 798 |
+
thinking=True,
|
| 799 |
+
)
|
| 800 |
+
|
| 801 |
+
config = GenerationConfig(batch_size=1)
|
| 802 |
+
|
| 803 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 804 |
+
```
|
| 805 |
+
|
| 806 |
+
### Example 4: Using Shift Parameter (Turbo Model)
|
| 807 |
+
|
| 808 |
+
```python
|
| 809 |
+
params = GenerationParams(
|
| 810 |
+
task_type="text2music",
|
| 811 |
+
caption="upbeat electronic dance music",
|
| 812 |
+
inference_steps=8,
|
| 813 |
+
shift=3.0, # Recommended for turbo models
|
| 814 |
+
infer_method="ode",
|
| 815 |
+
)
|
| 816 |
+
|
| 817 |
+
config = GenerationConfig(batch_size=2)
|
| 818 |
+
|
| 819 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 820 |
+
```
|
| 821 |
+
|
| 822 |
+
### Example 5: Simple Mode with create_sample
|
| 823 |
+
|
| 824 |
+
```python
|
| 825 |
+
from acestep.inference import create_sample, GenerationParams, GenerationConfig, generate_music
|
| 826 |
+
|
| 827 |
+
# Step 1: Create sample from description
|
| 828 |
+
sample = create_sample(
|
| 829 |
+
llm_handler=llm_handler,
|
| 830 |
+
query="energetic K-pop dance track with catchy hooks",
|
| 831 |
+
vocal_language="ko",
|
| 832 |
+
)
|
| 833 |
+
|
| 834 |
+
if sample.success:
|
| 835 |
+
# Step 2: Generate music using the sample
|
| 836 |
+
params = GenerationParams(
|
| 837 |
+
caption=sample.caption,
|
| 838 |
+
lyrics=sample.lyrics,
|
| 839 |
+
bpm=sample.bpm,
|
| 840 |
+
duration=sample.duration,
|
| 841 |
+
keyscale=sample.keyscale,
|
| 842 |
+
vocal_language=sample.language,
|
| 843 |
+
thinking=True,
|
| 844 |
+
)
|
| 845 |
+
|
| 846 |
+
config = GenerationConfig(batch_size=2)
|
| 847 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 848 |
+
```
|
| 849 |
+
|
| 850 |
+
### Example 6: Format and Enhance User Input
|
| 851 |
+
|
| 852 |
+
```python
|
| 853 |
+
from acestep.inference import format_sample, GenerationParams, GenerationConfig, generate_music
|
| 854 |
+
|
| 855 |
+
# Step 1: Format user input
|
| 856 |
+
formatted = format_sample(
|
| 857 |
+
llm_handler=llm_handler,
|
| 858 |
+
caption="rock ballad",
|
| 859 |
+
lyrics="[Verse]\nIn the darkness I find my way...",
|
| 860 |
+
)
|
| 861 |
+
|
| 862 |
+
if formatted.success:
|
| 863 |
+
# Step 2: Generate with enhanced input
|
| 864 |
+
params = GenerationParams(
|
| 865 |
+
caption=formatted.caption,
|
| 866 |
+
lyrics=formatted.lyrics,
|
| 867 |
+
bpm=formatted.bpm,
|
| 868 |
+
duration=formatted.duration,
|
| 869 |
+
keyscale=formatted.keyscale,
|
| 870 |
+
thinking=True,
|
| 871 |
+
use_cot_metas=False, # Already formatted, skip metas CoT
|
| 872 |
+
)
|
| 873 |
+
|
| 874 |
+
config = GenerationConfig(batch_size=2)
|
| 875 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 876 |
+
```
|
| 877 |
+
|
| 878 |
+
### Example 7: Style Cover with LM Reasoning
|
| 879 |
|
| 880 |
```python
|
| 881 |
params = GenerationParams(
|
|
|
|
| 898 |
print(f"LM detected Key: {lm_meta.get('keyscale')}")
|
| 899 |
```
|
| 900 |
|
| 901 |
+
### Example 8: Batch Generation with Specific Seeds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 902 |
|
| 903 |
```python
|
| 904 |
params = GenerationParams(
|
|
|
|
| 921 |
print(f" Seed {audio['params']['seed']}: {audio['path']}")
|
| 922 |
```
|
| 923 |
|
| 924 |
+
### Example 9: High-Quality Generation (Base Model)
|
| 925 |
|
| 926 |
```python
|
| 927 |
params = GenerationParams(
|
|
|
|
| 932 |
use_adg=True, # Adaptive Dual Guidance
|
| 933 |
cfg_interval_start=0.0,
|
| 934 |
cfg_interval_end=1.0,
|
| 935 |
+
shift=3.0, # Timestep shift
|
| 936 |
seed=42, # Reproducible results
|
| 937 |
)
|
| 938 |
|
|
|
|
| 945 |
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 946 |
```
|
| 947 |
|
| 948 |
+
### Example 10: Understand Audio from Codes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 949 |
|
| 950 |
```python
|
| 951 |
+
from acestep.inference import understand_music
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 952 |
|
| 953 |
+
# Analyze audio codes (e.g., from a previous generation)
|
| 954 |
+
result = understand_music(
|
| 955 |
+
llm_handler=llm_handler,
|
| 956 |
+
audio_codes="<|audio_code_10695|><|audio_code_54246|>...",
|
| 957 |
+
temperature=0.85,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 958 |
)
|
| 959 |
|
| 960 |
+
if result.success:
|
| 961 |
+
print(f"Detected Caption: {result.caption}")
|
| 962 |
+
print(f"Detected Lyrics: {result.lyrics}")
|
| 963 |
+
print(f"Detected BPM: {result.bpm}")
|
| 964 |
+
print(f"Detected Key: {result.keyscale}")
|
| 965 |
+
print(f"Detected Duration: {result.duration}s")
|
| 966 |
+
print(f"Detected Language: {result.language}")
|
| 967 |
```
|
| 968 |
|
| 969 |
---
|
|
|
|
| 999 |
- Use base model with `inference_steps=64` or higher
|
| 1000 |
- Enable `use_adg=True`
|
| 1001 |
- Set `guidance_scale=7.0-9.0`
|
| 1002 |
+
- Set `shift=3.0` for better timestep distribution
|
| 1003 |
- Use lossless audio format (`audio_format="wav"`)
|
| 1004 |
|
| 1005 |
**For Speed**:
|
| 1006 |
- Use turbo model with `inference_steps=8`
|
| 1007 |
- Disable ADG (`use_adg=False`)
|
| 1008 |
+
- Use `infer_method="ode"` (default)
|
| 1009 |
- Use compressed format (`audio_format="mp3"`) or default FLAC
|
| 1010 |
|
| 1011 |
**For Consistency**:
|
|
|
|
| 1111 |
**Issue**: Seeds not being respected
|
| 1112 |
- **Solution**: Set `use_random_seed=False` in config and provide `seeds` list or `seed` in params
|
| 1113 |
|
| 1114 |
+
**Issue**: Custom timesteps not working
|
| 1115 |
+
- **Solution**: Ensure timesteps are a list of floats from 1.0 to 0.0, properly ordered
|
| 1116 |
+
|
| 1117 |
---
|
| 1118 |
|
| 1119 |
## API Reference Summary
|
|
|
|
| 1158 |
|
| 1159 |
## Version History
|
| 1160 |
|
| 1161 |
+
- **v1.5.2**: Current version
|
| 1162 |
+
- Added `shift` parameter for timestep shifting
|
| 1163 |
+
- Added `infer_method` parameter for ODE/SDE selection
|
| 1164 |
+
- Added `timesteps` parameter for custom timestep schedules
|
| 1165 |
+
- Added `understand_music()` function for audio analysis
|
| 1166 |
+
- Added `create_sample()` function for simple mode generation
|
| 1167 |
+
- Added `format_sample()` function for input enhancement
|
| 1168 |
+
- Added `UnderstandResult`, `CreateSampleResult`, `FormatSampleResult` dataclasses
|
| 1169 |
+
|
| 1170 |
+
- **v1.5.1**: Previous version
|
| 1171 |
- Split `GenerationConfig` into `GenerationParams` and `GenerationConfig`
|
| 1172 |
- Renamed parameters for consistency (`key_scale` → `keyscale`, `time_signature` → `timesignature`, `audio_duration` → `duration`, `use_llm_thinking` → `thinking`, `audio_code_string` → `audio_codes`)
|
| 1173 |
- Added `instrumental` parameter
|
|
|
|
| 1179 |
- Simplified `GenerationResult` structure with unified `audios` list
|
| 1180 |
- Added unified `time_costs` in `extra_outputs`
|
| 1181 |
|
| 1182 |
+
- **v1.5**: Initial version
|
| 1183 |
- Introduced `GenerationConfig` and `GenerationResult` dataclasses
|
| 1184 |
- Simplified parameter passing
|
| 1185 |
- Added comprehensive documentation
|
|
|
|
| 1187 |
---
|
| 1188 |
|
| 1189 |
For more information, see:
|
| 1190 |
+
- Main README: [`../../README.md`](../../README.md)
|
| 1191 |
- REST API Documentation: [`API.md`](API.md)
|
| 1192 |
+
- Gradio Demo Guide: [`GRADIO_GUIDE.md`](GRADIO_GUIDE.md)
|
| 1193 |
- Project repository: [ACE-Step-1.5](https://github.com/yourusername/ACE-Step-1.5)
|
docs/ja/API.md
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ACE-Step API クライアントドキュメント
|
| 2 |
+
|
| 3 |
+
**Language / 语言 / 言語:** [English](../en/API.md) | [中文](../zh/API.md) | [日本語](API.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
本サービスはHTTPベースの非同期音楽生成APIを提供します。
|
| 8 |
+
|
| 9 |
+
**基本的なワークフロー**:
|
| 10 |
+
1. `POST /v1/music/generate` を呼び出してタスクを送信し、`job_id` を取得します。
|
| 11 |
+
2. `GET /v1/jobs/{job_id}` を呼び出してタスクステータスをポーリングし、`status` が `succeeded` または `failed` になるまで待ちます。
|
| 12 |
+
3. 結果で返された `GET /v1/audio?path=...` URL から音声ファイルをダウンロードします。
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 目次
|
| 17 |
+
|
| 18 |
+
- [タスクステータスの説明](#1-タスクステータスの説明)
|
| 19 |
+
- [生成タスクの作成](#2-生成タスクの作成)
|
| 20 |
+
- [タスク結果の照会](#3-タスク結果の照会)
|
| 21 |
+
- [ランダムサンプル生成](#4-ランダムサンプル生成)
|
| 22 |
+
- [利用可能なモデルの一覧](#5-利用可能なモデルの一覧)
|
| 23 |
+
- [音声ファイルのダウンロード](#6-音声ファイルのダウンロード)
|
| 24 |
+
- [ヘルスチェック](#7-ヘルスチェック)
|
| 25 |
+
- [環境変数](#8-環境変数)
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## 1. タスクステータスの説明
|
| 30 |
+
|
| 31 |
+
タスクステータス(`status`)には以下の種類があります:
|
| 32 |
+
|
| 33 |
+
- `queued`:タスクがキューに入り、実行待ちです。この時点で `queue_position` と `eta_seconds` を確認できます。
|
| 34 |
+
- `running`:生成が進行中です。
|
| 35 |
+
- `succeeded`:生成が成功し、結果は `result` フィールドにあります。
|
| 36 |
+
- `failed`:生成が失敗し、エラー情報は `error` フィールドにあります。
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## 2. 生成タスクの作成
|
| 41 |
+
|
| 42 |
+
### 2.1 API 定義
|
| 43 |
+
|
| 44 |
+
- **URL**:`/v1/music/generate`
|
| 45 |
+
- **メソッド**:`POST`
|
| 46 |
+
- **Content-Type**:`application/json`、`multipart/form-data`、または `application/x-www-form-urlencoded`
|
| 47 |
+
|
| 48 |
+
### 2.2 リクエストパラメータ
|
| 49 |
+
|
| 50 |
+
#### パラメータ命名規則
|
| 51 |
+
|
| 52 |
+
APIはほとんどのパラメータで **snake_case** と **camelCase** の両方の命名をサポートしています。例:
|
| 53 |
+
- `audio_duration` / `duration` / `audioDuration`
|
| 54 |
+
- `key_scale` / `keyscale` / `keyScale`
|
| 55 |
+
- `time_signature` / `timesignature` / `timeSignature`
|
| 56 |
+
- `sample_query` / `sampleQuery` / `description` / `desc`
|
| 57 |
+
- `use_format` / `useFormat` / `format`
|
| 58 |
+
|
| 59 |
+
また、メタデータはネストされたオブジェクト(`metas`、`metadata`、または `user_metadata`)で渡すことができます。
|
| 60 |
+
|
| 61 |
+
#### 方法 A:JSONリクエスト(application/json)
|
| 62 |
+
|
| 63 |
+
テキストパラメータのみを渡す場合、またはサーバー上に既に存在する音声ファイルパスを参照する場合に適しています。
|
| 64 |
+
|
| 65 |
+
**基本パラメータ**:
|
| 66 |
+
|
| 67 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 68 |
+
| :--- | :--- | :--- | :--- |
|
| 69 |
+
| `caption` | string | `""` | 音楽の説明プロンプト |
|
| 70 |
+
| `lyrics` | string | `""` | 歌詞の内容 |
|
| 71 |
+
| `thinking` | bool | `false` | 5Hz LMを使用してオーディオコードを生成するかどうか(lm-dit動作)|
|
| 72 |
+
| `vocal_language` | string | `"en"` | 歌詞の言語(en、zh、jaなど)|
|
| 73 |
+
| `audio_format` | string | `"mp3"` | 出力形式(mp3、wav、flac)|
|
| 74 |
+
|
| 75 |
+
**サンプル/説明モードパラメータ**:
|
| 76 |
+
|
| 77 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 78 |
+
| :--- | :--- | :--- | :--- |
|
| 79 |
+
| `sample_mode` | bool | `false` | ランダムサンプル生成モードを有効にする(LM経由でcaption/lyrics/metasを自動生成)|
|
| 80 |
+
| `sample_query` | string | `""` | サンプル生成のための自然言語の説明(例:「静かな夜のための柔らかいベンガルのラブソング」)。別名:`description`、`desc` |
|
| 81 |
+
| `use_format` | bool | `false` | LMを使用して提供されたcaptionとlyricsを強化/フォーマットする。別名:`format` |
|
| 82 |
+
|
| 83 |
+
**マルチモデルサポート**:
|
| 84 |
+
|
| 85 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 86 |
+
| :--- | :--- | :--- | :--- |
|
| 87 |
+
| `model` | string | null | 使用するDiTモデルを選択(例:`"acestep-v15-turbo"`、`"acestep-v15-turbo-rl"`)。`/v1/models` で利用可能なモデルを一覧表示。指定しない場合はデフォルトモデルを使用。|
|
| 88 |
+
|
| 89 |
+
**thinkingのセマンティクス(重要)**:
|
| 90 |
+
|
| 91 |
+
- `thinking=false`:
|
| 92 |
+
- サーバーは5Hz LMを使用して `audio_code_string` を生成**しません**。
|
| 93 |
+
- DiTは **text2music** モードで実行され、提供された `audio_code_string` を**無視**します。
|
| 94 |
+
- `thinking=true`:
|
| 95 |
+
- サーバーは5Hz LMを使用して `audio_code_string` を生成します(lm-dit動作)。
|
| 96 |
+
- DiTはLM生成のコードで実行され、音楽品質が向上します。
|
| 97 |
+
|
| 98 |
+
**メタデータの自動補完(条件付き)**:
|
| 99 |
+
|
| 100 |
+
`use_cot_caption=true` または `use_cot_language=true` またはメタデータフィールドが欠落している場合、サーバーは `caption`/`lyrics` に基づいて5Hz LMを呼び出し、欠落���ているフィールドを補完することがあります:
|
| 101 |
+
|
| 102 |
+
- `bpm`
|
| 103 |
+
- `key_scale`
|
| 104 |
+
- `time_signature`
|
| 105 |
+
- `audio_duration`
|
| 106 |
+
|
| 107 |
+
ユーザー提供の値が常に優先されます。LMは空/欠落しているフィールドのみを補完します。
|
| 108 |
+
|
| 109 |
+
**音楽属性パラメータ**:
|
| 110 |
+
|
| 111 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 112 |
+
| :--- | :--- | :--- | :--- |
|
| 113 |
+
| `bpm` | int | null | テンポ(BPM)を指定、範囲30-300 |
|
| 114 |
+
| `key_scale` | string | `""` | キー/スケール(例:「C Major」、「Am」)。別名:`keyscale`、`keyScale` |
|
| 115 |
+
| `time_signature` | string | `""` | 拍子記号(2、3、4、6はそれぞれ2/4、3/4、4/4、6/8)。別名:`timesignature`、`timeSignature` |
|
| 116 |
+
| `audio_duration` | float | null | 生成時間(秒)、範囲10-600。別名:`duration`、`target_duration` |
|
| 117 |
+
|
| 118 |
+
**オーディオコード(オプション)**:
|
| 119 |
+
|
| 120 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 121 |
+
| :--- | :--- | :--- | :--- |
|
| 122 |
+
| `audio_code_string` | string または string[] | `""` | `llm_dit` 用のオーディオセマンティックトークン(5Hz)。別名:`audioCodeString` |
|
| 123 |
+
|
| 124 |
+
**生成制御パラメータ**:
|
| 125 |
+
|
| 126 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 127 |
+
| :--- | :--- | :--- | :--- |
|
| 128 |
+
| `inference_steps` | int | `8` | 推論ステップ数。Turboモデル:1-20(推奨8)。Baseモデル:1-200(推奨32-64)|
|
| 129 |
+
| `guidance_scale` | float | `7.0` | プロンプトガイダンス係数。baseモデルのみ有効 |
|
| 130 |
+
| `use_random_seed` | bool | `true` | ランダムシードを使用するかどうか |
|
| 131 |
+
| `seed` | int | `-1` | シードを指定(use_random_seed=falseの場合)|
|
| 132 |
+
| `batch_size` | int | `2` | バッチ生成数(最大8)|
|
| 133 |
+
|
| 134 |
+
**高度なDiTパラメータ**:
|
| 135 |
+
|
| 136 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 137 |
+
| :--- | :--- | :--- | :--- |
|
| 138 |
+
| `shift` | float | `3.0` | タイムステップシフト係数(範囲1.0-5.0)。baseモデルのみ有効、turboモデルには無効 |
|
| 139 |
+
| `infer_method` | string | `"ode"` | 拡散推論方法:`"ode"`(Euler、より高速)または `"sde"`(確率的)|
|
| 140 |
+
| `timesteps` | string | null | カンマ区切りのカスタムタイムステップ(例:`"0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0"`)。`inference_steps` と `shift` をオーバーライド |
|
| 141 |
+
| `use_adg` | bool | `false` | 適応デュアルガイダンスを使用(baseモデルのみ)|
|
| 142 |
+
| `cfg_interval_start` | float | `0.0` | CFG適用開始比率(0.0-1.0)|
|
| 143 |
+
| `cfg_interval_end` | float | `1.0` | CFG適用終了比率(0.0-1.0)|
|
| 144 |
+
|
| 145 |
+
**5Hz LMパラメータ(オプション、サーバー側)**:
|
| 146 |
+
|
| 147 |
+
これらのパラメータは5Hz LMサンプリングを制御し、メタデータの自動補完と(`thinking=true` の場合)コード生成に使用されます。
|
| 148 |
+
|
| 149 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 150 |
+
| :--- | :--- | :--- | :--- |
|
| 151 |
+
| `lm_model_path` | string | null | 5Hz LMチェックポイントディレクトリ名(例:`acestep-5Hz-lm-0.6B-v3`)|
|
| 152 |
+
| `lm_backend` | string | `"vllm"` | `vllm` または `pt` |
|
| 153 |
+
| `lm_temperature` | float | `0.85` | サンプリング温度 |
|
| 154 |
+
| `lm_cfg_scale` | float | `2.5` | CFGスケール(>1でCFGを有効化)|
|
| 155 |
+
| `lm_negative_prompt` | string | `"NO USER INPUT"` | CFGで使用するネガティブプロンプト |
|
| 156 |
+
| `lm_top_k` | int | null | Top-k(0/nullで無効)|
|
| 157 |
+
| `lm_top_p` | float | `0.9` | Top-p(>=1は無効として扱われる)|
|
| 158 |
+
| `lm_repetition_penalty` | float | `1.0` | 繰り返しペナルティ |
|
| 159 |
+
|
| 160 |
+
**LM CoT(思考の連鎖)パラメータ**:
|
| 161 |
+
|
| 162 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 163 |
+
| :--- | :--- | :--- | :--- |
|
| 164 |
+
| `use_cot_caption` | bool | `true` | LMにCoT推論で入力captionを書き換え/強化させる。別名:`cot_caption`、`cot-caption` |
|
| 165 |
+
| `use_cot_language` | bool | `true` | LMにCoTでボーカル言語を検出させる。別名:`cot_language`、`cot-language` |
|
| 166 |
+
| `constrained_decoding` | bool | `true` | 構造化されたLM出力のためのFSMベースの制約付きデコーディングを有効にする。別名:`constrainedDecoding`、`constrained` |
|
| 167 |
+
| `constrained_decoding_debug` | bool | `false` | 制約付きデコーディングのデバッグログを有効にする |
|
| 168 |
+
|
| 169 |
+
**編集/参照オーディオパラメータ**(サーバー上の絶対パスが必要):
|
| 170 |
+
|
| 171 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 172 |
+
| :--- | :--- | :--- | :--- |
|
| 173 |
+
| `reference_audio_path` | string | null | 参照オーディオパス(スタイル転送)|
|
| 174 |
+
| `src_audio_path` | string | null | ソースオーディオパス(リペイント/カバー)|
|
| 175 |
+
| `task_type` | string | `"text2music"` | タスクタイプ:`text2music`、`cover`、`repaint`、`lego`、`extract`、`complete` |
|
| 176 |
+
| `instruction` | string | auto | 編集指示(提供されない場合はtask_typeに基づいて自動生成)|
|
| 177 |
+
| `repainting_start` | float | `0.0` | リペイント開始時間(秒)|
|
| 178 |
+
| `repainting_end` | float | null | リペイント終了時間(秒)、-1でオーディオの終端 |
|
| 179 |
+
| `audio_cover_strength` | float | `1.0` | カバー強度(0.0-1.0)。スタイル転送には小さい値(0.2)を使用 |
|
| 180 |
+
|
| 181 |
+
#### 方法 B:ファイルアップロード(multipart/form-data)
|
| 182 |
+
|
| 183 |
+
参照またはソースオーディオとしてローカルオーディオファイルをアップロードする必要がある場合に使用します。
|
| 184 |
+
|
| 185 |
+
上記のすべてのフィールドをフォームフィールドとしてサポートすることに加えて、以下のファイルフィールドもサポートしています:
|
| 186 |
+
|
| 187 |
+
- `reference_audio`:(ファイル)参照オーディオファイルをアップロード
|
| 188 |
+
- `src_audio`:(ファイル)ソースオーディオファイルをアップロード
|
| 189 |
+
|
| 190 |
+
> **注意**:ファイルをアップロードすると、対応する `_path` パラメータは自動的に無視され、システムはアップロード後の一時ファイルパスを使用します。
|
| 191 |
+
|
| 192 |
+
### 2.3 レスポンス例
|
| 193 |
+
|
| 194 |
+
```json
|
| 195 |
+
{
|
| 196 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 197 |
+
"status": "queued",
|
| 198 |
+
"queue_position": 1
|
| 199 |
+
}
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
### 2.4 使用例(cURL)
|
| 203 |
+
|
| 204 |
+
**基本的なJSONメソッド**:
|
| 205 |
+
|
| 206 |
+
```bash
|
| 207 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 208 |
+
-H 'Content-Type: application/json' \
|
| 209 |
+
-d '{
|
| 210 |
+
"caption": "アップビートなポップソング",
|
| 211 |
+
"lyrics": "Hello world",
|
| 212 |
+
"inference_steps": 8
|
| 213 |
+
}'
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
**thinking=trueの場合(LMがコードを生成 + 欠落メタを補完)**:
|
| 217 |
+
|
| 218 |
+
```bash
|
| 219 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 220 |
+
-H 'Content-Type: application/json' \
|
| 221 |
+
-d '{
|
| 222 |
+
"caption": "アップビートなポップソング",
|
| 223 |
+
"lyrics": "Hello world",
|
| 224 |
+
"thinking": true,
|
| 225 |
+
"lm_temperature": 0.85,
|
| 226 |
+
"lm_cfg_scale": 2.5
|
| 227 |
+
}'
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
**説明駆動型生成(sample_query)**:
|
| 231 |
+
|
| 232 |
+
```bash
|
| 233 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 234 |
+
-H 'Content-Type: application/json' \
|
| 235 |
+
-d '{
|
| 236 |
+
"sample_query": "静かな夜のための柔らかいベンガルのラブソング",
|
| 237 |
+
"thinking": true
|
| 238 |
+
}'
|
| 239 |
+
```
|
| 240 |
+
|
| 241 |
+
**フォーマット強化(use_format=true)**:
|
| 242 |
+
|
| 243 |
+
```bash
|
| 244 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 245 |
+
-H 'Content-Type: application/json' \
|
| 246 |
+
-d '{
|
| 247 |
+
"caption": "ポップロック",
|
| 248 |
+
"lyrics": "[Verse 1]\n街を歩いて...",
|
| 249 |
+
"use_format": true,
|
| 250 |
+
"thinking": true
|
| 251 |
+
}'
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
**特定のモデルを選択**:
|
| 255 |
+
|
| 256 |
+
```bash
|
| 257 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 258 |
+
-H 'Content-Type: application/json' \
|
| 259 |
+
-d '{
|
| 260 |
+
"caption": "エレクトロニックダンスミュージック",
|
| 261 |
+
"model": "acestep-v15-turbo-rl",
|
| 262 |
+
"thinking": true
|
| 263 |
+
}'
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
**カスタムタイムステップを使用**:
|
| 267 |
+
|
| 268 |
+
```bash
|
| 269 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 270 |
+
-H 'Content-Type: application/json' \
|
| 271 |
+
-d '{
|
| 272 |
+
"caption": "ジャズピアノトリオ",
|
| 273 |
+
"timesteps": "0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0",
|
| 274 |
+
"thinking": true
|
| 275 |
+
}'
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
**thinking=falseの場合(DiTのみ、ただし欠落メタを補完)**:
|
| 279 |
+
|
| 280 |
+
```bash
|
| 281 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 282 |
+
-H 'Content-Type: application/json' \
|
| 283 |
+
-d '{
|
| 284 |
+
"caption": "ゆっくりとした感情的なバラード",
|
| 285 |
+
"lyrics": "...",
|
| 286 |
+
"thinking": false,
|
| 287 |
+
"bpm": 72
|
| 288 |
+
}'
|
| 289 |
+
```
|
| 290 |
+
|
| 291 |
+
**ファイルアップロードメソッド**:
|
| 292 |
+
|
| 293 |
+
```bash
|
| 294 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 295 |
+
-F "caption=この曲をリミックス" \
|
| 296 |
+
-F "src_audio=@/path/to/local/song.mp3" \
|
| 297 |
+
-F "task_type=repaint"
|
| 298 |
+
```
|
| 299 |
+
|
| 300 |
+
---
|
| 301 |
+
|
| 302 |
+
## 3. タスク結果の照会
|
| 303 |
+
|
| 304 |
+
### 3.1 API 定義
|
| 305 |
+
|
| 306 |
+
- **URL**:`/v1/jobs/{job_id}`
|
| 307 |
+
- **メソッド**:`GET`
|
| 308 |
+
|
| 309 |
+
### 3.2 レスポンスパラメータ
|
| 310 |
+
|
| 311 |
+
レスポンスには基本的なタスク情報、キューステータス、最終結果が含まれます。
|
| 312 |
+
|
| 313 |
+
**主要フィールド**:
|
| 314 |
+
|
| 315 |
+
- `status`:現在のステータス
|
| 316 |
+
- `queue_position`:現在のキュー位置(0は実行中または完了を意味)
|
| 317 |
+
- `eta_seconds`:推定残り待ち時間(秒)
|
| 318 |
+
- `avg_job_seconds`:平均ジョブ時間(ETA推定用)
|
| 319 |
+
- `result`:成功時の結果オブジェクト
|
| 320 |
+
- `audio_paths`:生成されたオーディオファイルURLのリスト(`/v1/audio` エンドポイントと併用)
|
| 321 |
+
- `first_audio_path`:最初のオーディオパス(URL)
|
| 322 |
+
- `second_audio_path`:2番目のオーディオパス(URL、batch_size >= 2の場合)
|
| 323 |
+
- `generation_info`:生成パラメータの詳細
|
| 324 |
+
- `status_message`:簡潔な結果説明
|
| 325 |
+
- `seed_value`:使用されたシード値(カンマ区切り)
|
| 326 |
+
- `metas`:完全なメタデータ辞書
|
| 327 |
+
- `bpm`:検出/使用されたBPM
|
| 328 |
+
- `duration`:検出/使用された長さ
|
| 329 |
+
- `keyscale`:検出/使用されたキー
|
| 330 |
+
- `timesignature`:検出/使用された拍子
|
| 331 |
+
- `genres`:検出されたジャンル(利用可能な場合)
|
| 332 |
+
- `lm_model`:使用されたLMモデルの名前
|
| 333 |
+
- `dit_model`:使���されたDiTモデルの名前
|
| 334 |
+
- `error`:失敗時のエラー情報
|
| 335 |
+
|
| 336 |
+
### 3.3 レスポンス例
|
| 337 |
+
|
| 338 |
+
**キュー中**:
|
| 339 |
+
|
| 340 |
+
```json
|
| 341 |
+
{
|
| 342 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 343 |
+
"status": "queued",
|
| 344 |
+
"created_at": 1700000000.0,
|
| 345 |
+
"queue_position": 5,
|
| 346 |
+
"eta_seconds": 25.0,
|
| 347 |
+
"avg_job_seconds": 5.0,
|
| 348 |
+
"result": null,
|
| 349 |
+
"error": null
|
| 350 |
+
}
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
**実行成功**:
|
| 354 |
+
|
| 355 |
+
```json
|
| 356 |
+
{
|
| 357 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 358 |
+
"status": "succeeded",
|
| 359 |
+
"created_at": 1700000000.0,
|
| 360 |
+
"started_at": 1700000001.0,
|
| 361 |
+
"finished_at": 1700000010.0,
|
| 362 |
+
"queue_position": 0,
|
| 363 |
+
"result": {
|
| 364 |
+
"first_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 365 |
+
"second_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3",
|
| 366 |
+
"audio_paths": [
|
| 367 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 368 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3"
|
| 369 |
+
],
|
| 370 |
+
"generation_info": "🎵 2つのオーディオを生成\n⏱️ 合計:8.5s\n🎲 シード:12345,67890",
|
| 371 |
+
"status_message": "✅ 生成が正常に完了しました!",
|
| 372 |
+
"seed_value": "12345,67890",
|
| 373 |
+
"metas": {
|
| 374 |
+
"bpm": 120,
|
| 375 |
+
"duration": 30,
|
| 376 |
+
"keyscale": "C Major",
|
| 377 |
+
"timesignature": "4",
|
| 378 |
+
"caption": "キャッチーなメロディのアップビートなポップソング"
|
| 379 |
+
},
|
| 380 |
+
"bpm": 120,
|
| 381 |
+
"duration": 30,
|
| 382 |
+
"keyscale": "C Major",
|
| 383 |
+
"timesignature": "4",
|
| 384 |
+
"genres": null,
|
| 385 |
+
"lm_model": "acestep-5Hz-lm-0.6B-v3",
|
| 386 |
+
"dit_model": "acestep-v15-turbo-rl"
|
| 387 |
+
},
|
| 388 |
+
"error": null
|
| 389 |
+
}
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
---
|
| 393 |
+
|
| 394 |
+
## 4. ランダムサンプル生成
|
| 395 |
+
|
| 396 |
+
### 4.1 API 定義
|
| 397 |
+
|
| 398 |
+
- **URL**:`/v1/music/random`
|
| 399 |
+
- **メソッド**:`POST`
|
| 400 |
+
|
| 401 |
+
このエンドポイントは5Hz LM経由でcaption、lyrics、メタデータを自動生成するサンプルモードジョブを作成します。
|
| 402 |
+
|
| 403 |
+
### 4.2 リクエストパラメータ
|
| 404 |
+
|
| 405 |
+
| パラメータ名 | 型 | デフォルト | 説明 |
|
| 406 |
+
| :--- | :--- | :--- | :--- |
|
| 407 |
+
| `thinking` | bool | `true` | LM経由でオーディオコードも生成するかどうか |
|
| 408 |
+
|
| 409 |
+
### 4.3 レスポンス例
|
| 410 |
+
|
| 411 |
+
```json
|
| 412 |
+
{
|
| 413 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 414 |
+
"status": "queued",
|
| 415 |
+
"queue_position": 1
|
| 416 |
+
}
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
### 4.4 使用例
|
| 420 |
+
|
| 421 |
+
```bash
|
| 422 |
+
curl -X POST http://localhost:8001/v1/music/random \
|
| 423 |
+
-H 'Content-Type: application/json' \
|
| 424 |
+
-d '{"thinking": true}'
|
| 425 |
+
```
|
| 426 |
+
|
| 427 |
+
---
|
| 428 |
+
|
| 429 |
+
## 5. 利用可能なモデルの一覧
|
| 430 |
+
|
| 431 |
+
### 5.1 API 定義
|
| 432 |
+
|
| 433 |
+
- **URL**:`/v1/models`
|
| 434 |
+
- **メソッド**:`GET`
|
| 435 |
+
|
| 436 |
+
サーバーにロードされている利用可能なDiTモデルのリストを返します。
|
| 437 |
+
|
| 438 |
+
### 5.2 レスポンス例
|
| 439 |
+
|
| 440 |
+
```json
|
| 441 |
+
{
|
| 442 |
+
"models": [
|
| 443 |
+
{
|
| 444 |
+
"name": "acestep-v15-turbo-rl",
|
| 445 |
+
"is_default": true
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"name": "acestep-v15-turbo",
|
| 449 |
+
"is_default": false
|
| 450 |
+
}
|
| 451 |
+
],
|
| 452 |
+
"default_model": "acestep-v15-turbo-rl"
|
| 453 |
+
}
|
| 454 |
+
```
|
| 455 |
+
|
| 456 |
+
### 5.3 使用例
|
| 457 |
+
|
| 458 |
+
```bash
|
| 459 |
+
curl http://localhost:8001/v1/models
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## 6. 音声ファイルのダウンロード
|
| 465 |
+
|
| 466 |
+
### 6.1 API 定義
|
| 467 |
+
|
| 468 |
+
- **URL**:`/v1/audio`
|
| 469 |
+
- **メソッド**:`GET`
|
| 470 |
+
|
| 471 |
+
パスで生成されたオーディオファイルをダウンロードします。
|
| 472 |
+
|
| 473 |
+
### 6.2 リクエストパラメータ
|
| 474 |
+
|
| 475 |
+
| パラメータ名 | 型 | 説明 |
|
| 476 |
+
| :--- | :--- | :--- |
|
| 477 |
+
| `path` | string | URLエンコードされたオーディオファイルパス |
|
| 478 |
+
|
| 479 |
+
### 6.3 使用例
|
| 480 |
+
|
| 481 |
+
```bash
|
| 482 |
+
# ジョブ結果のURLを使用してダウンロード
|
| 483 |
+
curl "http://localhost:8001/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3" -o output.mp3
|
| 484 |
+
```
|
| 485 |
+
|
| 486 |
+
---
|
| 487 |
+
|
| 488 |
+
## 7. ヘルスチェック
|
| 489 |
+
|
| 490 |
+
### 7.1 API 定義
|
| 491 |
+
|
| 492 |
+
- **URL**:`/health`
|
| 493 |
+
- **メソッド**:`GET`
|
| 494 |
+
|
| 495 |
+
サービスのヘルスステータスを返します。
|
| 496 |
+
|
| 497 |
+
### 7.2 レスポンス例
|
| 498 |
+
|
| 499 |
+
```json
|
| 500 |
+
{
|
| 501 |
+
"status": "ok",
|
| 502 |
+
"service": "ACE-Step API",
|
| 503 |
+
"version": "1.0"
|
| 504 |
+
}
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
+
---
|
| 508 |
+
|
| 509 |
+
## 8. 環境変数
|
| 510 |
+
|
| 511 |
+
APIサーバーは環境変数で設定できます:
|
| 512 |
+
|
| 513 |
+
| 変数 | デフォルト | 説明 |
|
| 514 |
+
| :--- | :--- | :--- |
|
| 515 |
+
| `ACESTEP_API_HOST` | `127.0.0.1` | サーバーバインドホスト |
|
| 516 |
+
| `ACESTEP_API_PORT` | `8001` | サーバーバインドポート |
|
| 517 |
+
| `ACESTEP_CONFIG_PATH` | `acestep-v15-turbo-rl` | プライマリDiTモデルパス |
|
| 518 |
+
| `ACESTEP_CONFIG_PATH2` | (空)| セカンダリDiTモデルパス(オプション)|
|
| 519 |
+
| `ACESTEP_CONFIG_PATH3` | (空)| 3番目のDiTモデルパス(オプション)|
|
| 520 |
+
| `ACESTEP_DEVICE` | `auto` | モデルロードデバイス |
|
| 521 |
+
| `ACESTEP_USE_FLASH_ATTENTION` | `true` | flash attentionを有効化 |
|
| 522 |
+
| `ACESTEP_OFFLOAD_TO_CPU` | `false` | アイドル時にモデルをCPUにオフロード |
|
| 523 |
+
| `ACESTEP_OFFLOAD_DIT_TO_CPU` | `false` | DiTを特にCPUにオフロード |
|
| 524 |
+
| `ACESTEP_LM_MODEL_PATH` | `acestep-5Hz-lm-0.6B-v3` | デフォルト5Hz LMモデル |
|
| 525 |
+
| `ACESTEP_LM_BACKEND` | `vllm` | LMバックエンド(vllmまたはpt)|
|
| 526 |
+
| `ACESTEP_LM_DEVICE` | (ACESTEP_DEVICEと同じ)| LMデバイス |
|
| 527 |
+
| `ACESTEP_LM_OFFLOAD_TO_CPU` | `false` | LMをCPUにオフロード |
|
| 528 |
+
| `ACESTEP_QUEUE_MAXSIZE` | `200` | 最大キューサ��ズ |
|
| 529 |
+
| `ACESTEP_QUEUE_WORKERS` | `1` | キューワーカー数 |
|
| 530 |
+
| `ACESTEP_AVG_JOB_SECONDS` | `5.0` | 初期平均ジョブ時間推定 |
|
| 531 |
+
| `ACESTEP_TMPDIR` | `.cache/acestep/tmp` | 一時ファイルディレクトリ |
|
| 532 |
+
|
| 533 |
+
---
|
| 534 |
+
|
| 535 |
+
## エラー処理
|
| 536 |
+
|
| 537 |
+
**HTTPステータスコード**:
|
| 538 |
+
|
| 539 |
+
- `200`:成功
|
| 540 |
+
- `400`:無効なリクエスト(不正なJSON、フィールドの欠落)
|
| 541 |
+
- `404`:ジョブが見つからない
|
| 542 |
+
- `415`:サポートされていないContent-Type
|
| 543 |
+
- `429`:サーバービジー(キューが満杯)
|
| 544 |
+
- `500`:内部サーバーエラー
|
| 545 |
+
|
| 546 |
+
**エラーレスポンス形式**:
|
| 547 |
+
|
| 548 |
+
```json
|
| 549 |
+
{
|
| 550 |
+
"detail": "問題を説明するエラーメッセージ"
|
| 551 |
+
}
|
| 552 |
+
```
|
| 553 |
+
|
| 554 |
+
---
|
| 555 |
+
|
| 556 |
+
## ベストプラクティス
|
| 557 |
+
|
| 558 |
+
1. **`thinking=true` を使用** してLM強化生成で最高品質の結果を得る。
|
| 559 |
+
|
| 560 |
+
2. **`sample_query`/`description` を使用** して自然言語の説明から素早く生成。
|
| 561 |
+
|
| 562 |
+
3. **`use_format=true` を使用** してcaption/lyricsがあるがLMに強化してもらいたい場合。
|
| 563 |
+
|
| 564 |
+
4. **ジョブステータスのポーリング** は適切な間隔(例:1-2秒ごと)で行い、サーバーの過負荷を避ける。
|
| 565 |
+
|
| 566 |
+
5. **`avg_job_seconds` を確認** してレスポンスで待ち時間を推定。
|
| 567 |
+
|
| 568 |
+
6. **マルチモデルサポートを使用** するには `ACESTEP_CONFIG_PATH2` と `ACESTEP_CONFIG_PATH3` 環境変数を設定し、`model` パラメータで選択。
|
| 569 |
+
|
| 570 |
+
7. **本番環境** では常に適切なContent-Typeヘッダーを設定して415エラーを回避。
|
docs/ja/GRADIO_GUIDE.md
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ACE-Step Gradio デモユーザーガイド
|
| 2 |
+
|
| 3 |
+
**Language / 语言 / 言語:** [English](../en/GRADIO_GUIDE.md) | [中文](../zh/GRADIO_GUIDE.md) | [日本語](GRADIO_GUIDE.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
本ガイドはACE-Step Gradio Webインターフェースを使用した音楽生成の包括的なドキュメントを提供し、すべての機能と設定を含みます。
|
| 8 |
+
|
| 9 |
+
## 目次
|
| 10 |
+
|
| 11 |
+
- [はじめに](#はじめに)
|
| 12 |
+
- [サービス設定](#サービス設定)
|
| 13 |
+
- [生成モード](#生成モード)
|
| 14 |
+
- [タスクタイプ](#タスクタイプ)
|
| 15 |
+
- [入力パラメータ](#入力パラメータ)
|
| 16 |
+
- [高度な設定](#高度な設定)
|
| 17 |
+
- [結果セクション](#結果セクション)
|
| 18 |
+
- [LoRAトレーニング](#loraトレーニング)
|
| 19 |
+
- [ヒントとベストプラクティス](#ヒントとベストプラクティス)
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## はじめに
|
| 24 |
+
|
| 25 |
+
### デモの起動
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# 基本的な起動
|
| 29 |
+
python app.py
|
| 30 |
+
|
| 31 |
+
# 事前初期化付き
|
| 32 |
+
python app.py --config acestep-v15-turbo-rl --init-llm
|
| 33 |
+
|
| 34 |
+
# 特定のポートで
|
| 35 |
+
python app.py --port 7860
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### インターフェース概要
|
| 39 |
+
|
| 40 |
+
Gradioインターフェースは以下の主要セクションで構成されています:
|
| 41 |
+
|
| 42 |
+
1. **サービス設定** - モデルの読み込みと初期化
|
| 43 |
+
2. **必須入力** - タスクタイプ、オーディオアップロード、生成モード
|
| 44 |
+
3. **音楽キャプションと歌詞** - 生成用のテキスト入力
|
| 45 |
+
4. **オプションパラメータ** - BPM、キー、durationなどのメタデータ
|
| 46 |
+
5. **高度な設定** - 生成の細かい制御
|
| 47 |
+
6. **結果** - 生成されたオーディオの再生と管理
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## サービス設定
|
| 52 |
+
|
| 53 |
+
### モデル選択
|
| 54 |
+
|
| 55 |
+
| 設定 | 説明 |
|
| 56 |
+
|---------|-------------|
|
| 57 |
+
| **チェックポイントファイル** | トレーニング済みモデルチェックポイントを選択(利用可能な場合)|
|
| 58 |
+
| **メインモデルパス** | DiTモデル設定を選択(例:`acestep-v15-turbo`、`acestep-v15-turbo-rl`)|
|
| 59 |
+
| **デバイス** | 処理デバイス:`auto`(推奨)、`cuda`、または `cpu` |
|
| 60 |
+
|
| 61 |
+
### 5Hz LM設定
|
| 62 |
+
|
| 63 |
+
| 設定 | 説明 |
|
| 64 |
+
|---------|-------------|
|
| 65 |
+
| **5Hz LMモデルパス** | 言語モデルを選択(例:`acestep-5Hz-lm-0.6B`、`acestep-5Hz-lm-0.6B-v3`)|
|
| 66 |
+
| **5Hz LMバックエンド** | `vllm`(より高速、推奨)または `pt`(PyTorch、互換性が高い)|
|
| 67 |
+
| **5Hz LMを初期化** | 初期化時にLMを読み込むためにチェック(thinkingモードに必要)|
|
| 68 |
+
|
| 69 |
+
### パフォーマンスオプション
|
| 70 |
+
|
| 71 |
+
| 設定 | 説明 |
|
| 72 |
+
|---------|-------------|
|
| 73 |
+
| **Flash Attentionを使用** | より高速な推論のために有効化(flash_attnパッケージが必要)|
|
| 74 |
+
| **CPUにオフロード** | アイドル時にモデルをCPUにオフロードしてGPUメモリを節約 |
|
| 75 |
+
| **DiTをCPUにオフロード** | DiTモデルを特にCPUにオフロード |
|
| 76 |
+
|
| 77 |
+
### LoRAアダプター
|
| 78 |
+
|
| 79 |
+
| 設定 | 説明 |
|
| 80 |
+
|---------|-------------|
|
| 81 |
+
| **LoRAパス** | トレーニング済みLoRAアダプターディレクトリへのパス |
|
| 82 |
+
| **LoRAを読み込み** | 指定されたLoRAアダプターを読み込み |
|
| 83 |
+
| **アンロード** | 現在読み込まれているLoRAを削除 |
|
| 84 |
+
| **LoRAを使用** | 推論用の読み込まれたLoRAを有効化/無効化 |
|
| 85 |
+
|
| 86 |
+
### 初期化
|
| 87 |
+
|
| 88 |
+
**サービスを初期化** をクリックしてモデルを読み込みます。ステータスボックスに進捗と確認が表示されます。
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## 生成モード
|
| 93 |
+
|
| 94 |
+
### シンプルモード
|
| 95 |
+
|
| 96 |
+
シンプルモードは、迅速な自然言語ベースの音楽生成用に設計されています。
|
| 97 |
+
|
| 98 |
+
**使用方法:**
|
| 99 |
+
1. 生成モードラジオボタンで「シンプル」を選択
|
| 100 |
+
2. 「曲の説明」フィールドに自然言語の説明を入力
|
| 101 |
+
3. ボーカルが不要な場合は「インストゥルメンタル」をオプションでチェック
|
| 102 |
+
4. オプションで希望するボーカル言語を選択
|
| 103 |
+
5. **サンプルを作成** をクリックしてcaption、歌詞、メタデータを生成
|
| 104 |
+
6. 展開されたセクションで生成されたコンテンツを確認
|
| 105 |
+
7. **音楽を生成** をクリックしてオーディオを作成
|
| 106 |
+
|
| 107 |
+
**説明の例:**
|
| 108 |
+
- 「静かな夜のための柔らかいベンガルのラブソング」
|
| 109 |
+
- 「重いベースドロップのアップビートなエレクトロニックダンスミュージック」
|
| 110 |
+
- 「アコースティックギターのメランコリックなインディーフォーク」
|
| 111 |
+
- 「煙たいバーで演奏するジャズトリオ」
|
| 112 |
+
|
| 113 |
+
**ランダムサンプル:** 🎲 ボタンをクリックしてランダムな例の説明を読み込みます。
|
| 114 |
+
|
| 115 |
+
### カスタムモード
|
| 116 |
+
|
| 117 |
+
カスタムモードはすべての生成パラメータの完全な制御を提供します。
|
| 118 |
+
|
| 119 |
+
**使用方法:**
|
| 120 |
+
1. 生成モードラジオボタンで「カスタム」を選択
|
| 121 |
+
2. Captionと歌詞フィールドを手動で入力
|
| 122 |
+
3. オプションのメタデータを設定(BPM、キー、Durationなど)
|
| 123 |
+
4. オプ���ョンで **フォーマット** をクリックしてLMを使用して入力を強化
|
| 124 |
+
5. 必要に応じて高度な設定を構成
|
| 125 |
+
6. **音楽を生成** をクリックしてオーディオを作成
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## タスクタイプ
|
| 130 |
+
|
| 131 |
+
### text2music(デフォルト)
|
| 132 |
+
|
| 133 |
+
テキスト説明および/または歌詞から音楽を生成。
|
| 134 |
+
|
| 135 |
+
**ユースケース:** プロンプトに基づいて新しい音楽をゼロから作成。
|
| 136 |
+
|
| 137 |
+
**必須入力:** Captionまたは歌詞(少なくとも1つ)
|
| 138 |
+
|
| 139 |
+
### cover
|
| 140 |
+
|
| 141 |
+
既存のオーディオを構造を維持しながらスタイルを変更して変換。
|
| 142 |
+
|
| 143 |
+
**ユースケース:** 異なるスタイルのカバーバージョンを作成。
|
| 144 |
+
|
| 145 |
+
**必須入力:**
|
| 146 |
+
- ソースオーディオ(オーディオアップロードセクションでアップロード)
|
| 147 |
+
- ターゲットスタイルを説明するCaption
|
| 148 |
+
|
| 149 |
+
**重要なパラメータ:** `オーディオカバー強度`(0.0-1.0)
|
| 150 |
+
- 高い値は元の構造をより多く維持
|
| 151 |
+
- 低い値はより創造的な自由を許可
|
| 152 |
+
|
| 153 |
+
### repaint
|
| 154 |
+
|
| 155 |
+
オーディオの特定の時間セグメントを再生成。
|
| 156 |
+
|
| 157 |
+
**ユースケース:** 生成された音楽の特定のセクションを修正または変更。
|
| 158 |
+
|
| 159 |
+
**必須入力:**
|
| 160 |
+
- ソースオーディオ
|
| 161 |
+
- リペイント開始(秒)
|
| 162 |
+
- リペイント終了(秒、ファイル終端には-1)
|
| 163 |
+
- 希望するコンテンツを説明するCaption
|
| 164 |
+
|
| 165 |
+
### lego(Baseモデルのみ)
|
| 166 |
+
|
| 167 |
+
既存のオーディオのコンテキストで特定の楽器トラックを生成。
|
| 168 |
+
|
| 169 |
+
**ユースケース:** バッキングトラックに楽器レイヤーを追加。
|
| 170 |
+
|
| 171 |
+
**必須入力:**
|
| 172 |
+
- ソースオーディオ
|
| 173 |
+
- トラック名(ドロップダウンから選択)
|
| 174 |
+
- トラック特性を説明するCaption
|
| 175 |
+
|
| 176 |
+
**利用可能なトラック:** vocals、backing_vocals、drums、bass、guitar、keyboard、percussion、strings、synth、fx、brass、woodwinds
|
| 177 |
+
|
| 178 |
+
### extract(Baseモデルのみ)
|
| 179 |
+
|
| 180 |
+
ミックスオーディオから特定の楽器トラックを抽出/分離。
|
| 181 |
+
|
| 182 |
+
**ユースケース:** ステム分離、楽器の分離。
|
| 183 |
+
|
| 184 |
+
**必須入力:**
|
| 185 |
+
- ソースオーディオ
|
| 186 |
+
- 抽出するトラック名
|
| 187 |
+
|
| 188 |
+
### complete(Baseモデルのみ)
|
| 189 |
+
|
| 190 |
+
指定された楽器で部分的なトラックを完成。
|
| 191 |
+
|
| 192 |
+
**ユースケース:** 不完全な作品の自動アレンジ。
|
| 193 |
+
|
| 194 |
+
**必須入力:**
|
| 195 |
+
- ソースオーディオ
|
| 196 |
+
- トラック名(複数選択)
|
| 197 |
+
- 希望するスタイルを説明するCaption
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## 入力パラメータ
|
| 202 |
+
|
| 203 |
+
### 必須入力
|
| 204 |
+
|
| 205 |
+
#### タスクタイプ
|
| 206 |
+
ドロップダウンから生成タスクを選択。選択されたタスクに基づいて指示フィールドが自動的に更新されます。
|
| 207 |
+
|
| 208 |
+
#### オーディオアップロード
|
| 209 |
+
|
| 210 |
+
| フィールド | 説明 |
|
| 211 |
+
|-------|-------------|
|
| 212 |
+
| **参照オーディオ** | スタイル参照用のオプションオーディオ |
|
| 213 |
+
| **ソースオーディオ** | cover、repaint、lego、extract、completeタスクに必須 |
|
| 214 |
+
| **コードに変換** | ソースオーディオから5Hzセマンティックコードを抽出 |
|
| 215 |
+
|
| 216 |
+
#### LMコードヒント
|
| 217 |
+
|
| 218 |
+
事前計算されたオーディオセマンティックコードをここに貼り付けて生成をガイドできます。**トランスクライブ** ボタンを使用してコードを分析しメタデータを抽出します。
|
| 219 |
+
|
| 220 |
+
### 音楽キャプション
|
| 221 |
+
|
| 222 |
+
希望する音楽のテキスト説明。以下について具体的に:
|
| 223 |
+
- ジャンルとスタイル
|
| 224 |
+
- 楽器
|
| 225 |
+
- ムードと雰囲気
|
| 226 |
+
- テンポ感(BPMを指定しない場合)
|
| 227 |
+
|
| 228 |
+
**例:** 「エレキギター、力強いドラム、キャッチーなシンセフックのアップビートなポップロック」
|
| 229 |
+
|
| 230 |
+
🎲 をクリックしてランダムな例のcaptionを読み込みます。
|
| 231 |
+
|
| 232 |
+
### 歌詞
|
| 233 |
+
|
| 234 |
+
構造タグ付きの歌詞を入力:
|
| 235 |
+
|
| 236 |
+
```
|
| 237 |
+
[Verse 1]
|
| 238 |
+
今日街を歩いていて
|
| 239 |
+
君が言っていた言葉を思い出していた
|
| 240 |
+
|
| 241 |
+
[Chorus]
|
| 242 |
+
前に進んでいく、強くいる
|
| 243 |
+
ここが僕の居場所
|
| 244 |
+
|
| 245 |
+
[Verse 2]
|
| 246 |
+
...
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
**インストゥルメンタルチェックボックス:** これをチェックすると、歌詞の内容に関係なくインストゥルメンタル音楽を生成します。
|
| 250 |
+
|
| 251 |
+
**ボーカル言語:** ボーカルの言語を選択。自動検出またはインストゥルメンタルトラックには「unknown」を使用。
|
| 252 |
+
|
| 253 |
+
**フォーマットボタン:** クリックして5Hz LMを使用してcaptionと歌詞を強化。
|
| 254 |
+
|
| 255 |
+
### オプションパラメータ
|
| 256 |
+
|
| 257 |
+
| パラメータ | デフォルト | 説明 |
|
| 258 |
+
|-----------|---------|-------------|
|
| 259 |
+
| **BPM** | 自動 | 1分あたりのビート数(30-300)|
|
| 260 |
+
| **キースケール** | 自動 | 音楽キー(例:「C Major」、「Am」、「F# minor」)|
|
| 261 |
+
| **拍子記号** | 自動 | 拍子記号:2(2/4)、3(3/4)、4(4/4)、6(6/8)|
|
| 262 |
+
| **オーディオ長** | 自動/-1 | 目標長(秒)(10-600)。-1で自動 |
|
| 263 |
+
| **バッチサイズ** | 2 | 生成するオーディオバリエーションの数(1-8)|
|
| 264 |
+
|
| 265 |
+
---
|
| 266 |
+
|
| 267 |
+
## 高度な設定
|
| 268 |
+
|
| 269 |
+
### DiTパラメータ
|
| 270 |
+
|
| 271 |
+
| パラメータ | デフォルト | 説明 |
|
| 272 |
+
|-----------|---------|-------------|
|
| 273 |
+
| **推論ステップ** | 8 | デノイズステップ。Turbo:1-20、Base:1-200 |
|
| 274 |
+
| **ガイダンススケール** | 7.0 | CFG強度(baseモデルのみ)。高い = プロンプトにより従う |
|
| 275 |
+
| **シード** | -1 | ランダムシード。バッチにはカンマ区切りの値を使用 |
|
| 276 |
+
| **ランダムシード** | ✓ | チェック時にランダムシードを生成 |
|
| 277 |
+
| **オーディオ形式** | mp3 | 出力形式:mp3、flac |
|
| 278 |
+
| **シフト** | 3.0 | タイムステップシフト係数(1.0-5.0)。turboには3.0推奨 |
|
| 279 |
+
| **推論方法** | ode | ode(Euler、より高速)またはsde(確率的)|
|
| 280 |
+
| **カスタムタイムステップ** | - | タイムステップをオーバーライド(例:「0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0」)|
|
| 281 |
+
|
| 282 |
+
### Baseモデルのみのパラメータ
|
| 283 |
+
|
| 284 |
+
| パラメータ | デフォルト | 説明 |
|
| 285 |
+
|-----------|---------|-------------|
|
| 286 |
+
| **ADGを使用** | ✗ | より良い品質のために適応デュアルガイダンスを有効化 |
|
| 287 |
+
| **CFG区間開始** | 0.0 | CFGを適用し始めるタイミング(0.0-1.0)|
|
| 288 |
+
| **CFG区間終了** | 1.0 | CFGの適用を停止するタイミング(0.0-1.0)|
|
| 289 |
+
|
| 290 |
+
### LMパラメータ
|
| 291 |
+
|
| 292 |
+
| パラメータ | デフォルト | 説明 |
|
| 293 |
+
|-----------|---------|-------------|
|
| 294 |
+
| **LM温度** | 0.85 | サンプリング温度(0.0-2.0)。高い = より創造的 |
|
| 295 |
+
| **LM CFGスケール** | 2.0 | LMガイダンス強度(1.0-3.0)|
|
| 296 |
+
| **LM Top-K** | 0 | Top-Kサンプリング。0で無効 |
|
| 297 |
+
| **LM Top-P** | 0.9 | 核サンプリング(0.0-1.0)|
|
| 298 |
+
| **LMネガティブプロンプト** | "NO USER INPUT" | CFG用のネガティブプロンプト |
|
| 299 |
+
|
| 300 |
+
### CoT(思考の連鎖)オプション
|
| 301 |
+
|
| 302 |
+
| オプション | デフォルト | 説明 |
|
| 303 |
+
|--------|---------|-------------|
|
| 304 |
+
| **CoT Metas** | ✓ | LM推論でメタデータを生成 |
|
| 305 |
+
| **CoT Language** | ✓ | LMでボーカル言語を検出 |
|
| 306 |
+
| **制約付きデコーディングデバッグ** | ✗ | デバッグログを有効化 |
|
| 307 |
+
|
| 308 |
+
### 生成オプション
|
| 309 |
+
|
| 310 |
+
| オプション | デフォルト | 説明 |
|
| 311 |
+
|--------|---------|-------------|
|
| 312 |
+
| **LMコード強度** | 1.0 | LMコードが生成に与える影響の強さ(0.0-1.0)|
|
| 313 |
+
| **自動スコア** | ✗ | 品質スコアを自動計算 |
|
| 314 |
+
| **自動LRC** | ✗ | 歌詞タイムスタンプを自動生成 |
|
| 315 |
+
| **LMバッチチャンクサイズ** | 8 | LMバッチあたりの最大アイテム数(GPUメモリ)|
|
| 316 |
+
|
| 317 |
+
### メイン生成コントロール
|
| 318 |
+
|
| 319 |
+
| コントロール | 説明 |
|
| 320 |
+
|---------|-------------|
|
| 321 |
+
| **Think** | コード生成とメタデータ用の5Hz LMを有効化 |
|
| 322 |
+
| **ParallelThinking** | 並列LMバッチ処理を有効化 |
|
| 323 |
+
| **CaptionRewrite** | LMに入力captionを強化させる |
|
| 324 |
+
| **AutoGen** | 完了後に次のバッチを自動開始 |
|
| 325 |
+
|
| 326 |
+
---
|
| 327 |
+
|
| 328 |
+
## 結果セクション
|
| 329 |
+
|
| 330 |
+
### 生成されたオーディオ
|
| 331 |
+
|
| 332 |
+
バッチサイズに基づいて最大8つのオーディオサンプルが表示されます。各サンプルには以下が含まれます:
|
| 333 |
+
|
| 334 |
+
- **オーディオプレーヤー** - 生成されたオーディオの再生、一時停止、ダウンロード
|
| 335 |
+
- **ソースに送信** - このオーディオをソースオーディオ入力に送信してさらに処理
|
| 336 |
+
- **保存** - オーディオとメタデータをJSONファイルに保存
|
| 337 |
+
- **スコア** - パープレキシティベースの品質スコアを計算
|
| 338 |
+
- **LRC** - 歌詞タイムスタンプを生成(LRC形式)
|
| 339 |
+
|
| 340 |
+
### 詳細アコーディオン
|
| 341 |
+
|
| 342 |
+
「スコア & LRC & LMコード」をクリックして展開し、以下を表示:
|
| 343 |
+
- **LMコード** - このサンプルの5Hzセマンティックコード
|
| 344 |
+
- **品質スコア** - パープレキシティベースの品質メトリック
|
| 345 |
+
- **歌詞タイムスタンプ** - LRC形式のタイミングデータ
|
| 346 |
+
|
| 347 |
+
### バッチナビゲーション
|
| 348 |
+
|
| 349 |
+
| コントロール | 説明 |
|
| 350 |
+
|---------|-------------|
|
| 351 |
+
| **◀ 前へ** | 前のバッチを表示 |
|
| 352 |
+
| **バッチインジケーター** | 現在のバッチ位置を表示(例:「バッチ 1 / 3」)|
|
| 353 |
+
| **次バッチステータス** | バックグラウンド生成の進捗を表示 |
|
| 354 |
+
| **次へ ▶** | 次のバッチを表示(AutoGenがオンの場合は生成をトリガー)|
|
| 355 |
+
|
| 356 |
+
### パラメータの復元
|
| 357 |
+
|
| 358 |
+
**これらの設定をUIに適用** をクリックして、現在のバッチからすべての生成パラメータを入力フィールドに復元。良い結果を反復するのに便利。
|
| 359 |
+
|
| 360 |
+
### バッチ結果
|
| 361 |
+
|
| 362 |
+
「バッチ結果と生成詳細」アコーディオンには以下が含まれます:
|
| 363 |
+
- **すべての生成ファイル** - すべてのバッチからすべてのファイルをダウンロード
|
| 364 |
+
- **生成詳細** - 生成プロセスに関する詳細情報
|
| 365 |
+
|
| 366 |
+
---
|
| 367 |
+
|
| 368 |
+
## LoRAトレーニング
|
| 369 |
+
|
| 370 |
+
LoRAトレーニングタブはカスタムLoRAアダプターを作成するためのツールを提供します。
|
| 371 |
+
|
| 372 |
+
### データセットビルダータブ
|
| 373 |
+
|
| 374 |
+
#### ステップ1:読み込みまたはスキャン
|
| 375 |
+
|
| 376 |
+
**オプションA:既存のデータセットを読み込み**
|
| 377 |
+
1. 以前保存したデータセットJSONへのパスを入力
|
| 378 |
+
2. **読み込み** をクリック
|
| 379 |
+
|
| 380 |
+
**オプションB:新しいディレクトリをスキャン**
|
| 381 |
+
1. オーディオフォルダへのパスを入力
|
| 382 |
+
2. **スキャン** をクリックしてオーディオファイルを検索(wav、mp3、flac、ogg、opus)
|
| 383 |
+
|
| 384 |
+
#### ステップ2:データセットの設定
|
| 385 |
+
|
| 386 |
+
| 設定 | 説明 |
|
| 387 |
+
|---------|-------------|
|
| 388 |
+
| **データセット名** | データセットの名前 |
|
| 389 |
+
| **すべてインストゥルメンタル** | すべてのトラックにボーカルがない場合にチェック |
|
| 390 |
+
| **カスタムアクティベーションタグ** | このLoRAのスタイルをアクティブにするユニークなタグ |
|
| 391 |
+
| **タグ位置** | タグを配置する場所:前に追加、後に追加、またはcaptionを置換 |
|
| 392 |
+
|
| 393 |
+
#### ステップ3:自動ラベル
|
| 394 |
+
|
| 395 |
+
**すべて自動ラベル** をクリックしてすべてのオーディオファイルのメタデータを生成:
|
| 396 |
+
- Caption(音楽の説明)
|
| 397 |
+
- BPM
|
| 398 |
+
- キー
|
| 399 |
+
- 拍子記号
|
| 400 |
+
|
| 401 |
+
**Metasをスキップ** オプションはLLMラベリングをスキップしてN/A値を使用します。
|
| 402 |
+
|
| 403 |
+
#### ステップ4:プレビューと編集
|
| 404 |
+
|
| 405 |
+
スライダーを使用してサンプルを選択し、手動で編集:
|
| 406 |
+
- Caption
|
| 407 |
+
- 歌詞
|
| 408 |
+
- BPM、キー、拍子記号
|
| 409 |
+
- 言語
|
| 410 |
+
- インストゥルメンタルフラグ
|
| 411 |
+
|
| 412 |
+
**変更を保存** をクリックしてサンプルを更新。
|
| 413 |
+
|
| 414 |
+
#### ステップ5:データセットを保存
|
| 415 |
+
|
| 416 |
+
保存パスを入力し、**データセットを保存** をクリックしてJSONとしてエクスポート。
|
| 417 |
+
|
| 418 |
+
#### ステップ6:前処理
|
| 419 |
+
|
| 420 |
+
高速トレーニングのためにデータセットを事前計算テンソルに変換:
|
| 421 |
+
1. オプションで既存のデータセットJSONを読み込み
|
| 422 |
+
2. テンソル出力ディレクトリを設定
|
| 423 |
+
3. **前処理** をクリック
|
| 424 |
+
|
| 425 |
+
これによりオーディオがVAE潜在変数にエンコードされ、テキストが埋め込みにエンコードされ、条件エンコーダーが実行されます。
|
| 426 |
+
|
| 427 |
+
### LoRAトレーニングタブ
|
| 428 |
+
|
| 429 |
+
#### データセット選択
|
| 430 |
+
|
| 431 |
+
前処理されたテンソルディレクトリへのパスを入力し、**データセットを読み込み** をクリック。
|
| 432 |
+
|
| 433 |
+
#### LoRA設定
|
| 434 |
+
|
| 435 |
+
| 設定 | デフォルト | 説明 |
|
| 436 |
+
|---------|---------|-------------|
|
| 437 |
+
| **LoRAランク (r)** | 64 | LoRAの容量。高い = より多くの容量、より多くのメモリ |
|
| 438 |
+
| **LoRA Alpha** | 128 | スケーリング係数(通常はランクの2倍)|
|
| 439 |
+
| **LoRA Dropout** | 0.1 | 正則化のためのドロップアウト率 |
|
| 440 |
+
|
| 441 |
+
#### トレーニングパラメータ
|
| 442 |
+
|
| 443 |
+
| 設定 | デフォルト | 説明 |
|
| 444 |
+
|---------|---------|-------------|
|
| 445 |
+
| **学習率** | 1e-4 | 最適化学習率 |
|
| 446 |
+
| **最大エポック** | 500 | 最大トレーニングエポック |
|
| 447 |
+
| **バッチサイズ** | 1 | トレーニングバッチサイズ |
|
| 448 |
+
| **勾配累積** | 1 | 有効バッチ = batch_size × accumulation |
|
| 449 |
+
| **Nエポックごとに保存** | 200 | チェックポイント保存頻度 |
|
| 450 |
+
| **シフト** | 3.0 | turboモデルのタイムステップシフト |
|
| 451 |
+
| **シード** | 42 | 再現性のためのランダムシード |
|
| 452 |
+
|
| 453 |
+
#### トレーニングコントロール
|
| 454 |
+
|
| 455 |
+
- **トレーニング開始** - トレーニングプロセスを開始
|
| 456 |
+
- **トレーニング停止** - トレーニングを中断
|
| 457 |
+
- **トレーニング進捗** - 現在のエポックとロスを表示
|
| 458 |
+
- **トレーニングログ** - 詳細なトレーニング出力
|
| 459 |
+
- **トレーニングロスプロット** - 視覚的なロス曲線
|
| 460 |
+
|
| 461 |
+
#### LoRAのエクスポート
|
| 462 |
+
|
| 463 |
+
トレーニング後、最終アダプターをエクスポート:
|
| 464 |
+
1. エクスポートパスを入力
|
| 465 |
+
2. **LoRAをエクスポート** をクリック
|
| 466 |
+
|
| 467 |
+
---
|
| 468 |
+
|
| 469 |
+
## ヒントとベストプラクティス
|
| 470 |
+
|
| 471 |
+
### 最高品質のために
|
| 472 |
+
|
| 473 |
+
1. **thinkingモードを使用** - LM強化生成のために「Think」チェックボックスを有効に保つ
|
| 474 |
+
2. **captionを具体的に** - ジャンル、楽器、ムード、スタイルの詳細を含める
|
| 475 |
+
3. **LMにメタデータを検出させる** - 自動検出のためにBPM/キー/Durationを空のままにする
|
| 476 |
+
4. **バッチ生成を使用** - 2-4のバリエーションを生成し、最良のものを選ぶ
|
| 477 |
+
|
| 478 |
+
### より高速な生成のために
|
| 479 |
+
|
| 480 |
+
1. **turboモデルを使用** - `acestep-v15-turbo` または `acestep-v15-turbo-rl` を選択
|
| 481 |
+
2. **推論ステップを8に保つ** - turboに最適なデフォルト
|
| 482 |
+
3. **バッチサイズを減らす** - 迅速な結果が必要な場合はバッチサイズを下げる
|
| 483 |
+
4. **AutoGenを無効化** - バッチ生成の手動制御
|
| 484 |
+
|
| 485 |
+
### 一貫した結果のために
|
| 486 |
+
|
| 487 |
+
1. **特定のシードを設定** - 「ランダムシード」のチェックを外してシード値を入力
|
| 488 |
+
2. **良い結果を保存** - 再現のためにパラメータをエクスポートするために「保存」を使用
|
| 489 |
+
3. **「これらの設定を適用」を使用** - 良いバッチからパラメータを復元
|
| 490 |
+
|
| 491 |
+
### 長尺音楽のために
|
| 492 |
+
|
| 493 |
+
1. **明示的なdurationを設定** - 秒単位でdurationを指定
|
| 494 |
+
2. **repaintタスクを使用** - 初期生成後に問題のあるセクションを修正
|
| 495 |
+
3. **生成をチェーン** - 以前の結果の上に構築するために「ソースに送信」を使用
|
| 496 |
+
|
| 497 |
+
### スタイルの一貫性のために
|
| 498 |
+
|
| 499 |
+
1. **LoRAをトレーニング** - あなたのスタイル用のカスタムアダプターを作成
|
| 500 |
+
2. **参照オーディオを使用** - オーディオアップロードでスタイル参照をアップロード
|
| 501 |
+
3. **一貫したcaptionを使用** - 類似の説明的な言語を維持
|
| 502 |
+
|
| 503 |
+
### トラブルシューティング
|
| 504 |
+
|
| 505 |
+
**オーディオが生成されない:**
|
| 506 |
+
- モデルが初期化されていることを確認(緑のステータスメッセージ)
|
| 507 |
+
- thinkingモードを使用している場合は5Hz LMが初期化されていることを確認
|
| 508 |
+
- エラーメッセージのステータス出力を確認
|
| 509 |
+
|
| 510 |
+
**結果の品質が悪い:**
|
| 511 |
+
- 推論ステップを増やす(baseモデルの場合)
|
| 512 |
+
- ガイダンススケールを調整
|
| 513 |
+
- 異なるシードを試す
|
| 514 |
+
- captionをより具体的にする
|
| 515 |
+
|
| 516 |
+
**メモリ不足:**
|
| 517 |
+
- バッチサイズを減らす
|
| 518 |
+
- CPUオフロードを有効化
|
| 519 |
+
- LMバッチチャンクサイズを減らす
|
| 520 |
+
|
| 521 |
+
**LMが機能しない:**
|
| 522 |
+
- 初期化時に「5Hz LMを初期化」がチェックされていたことを確認
|
| 523 |
+
- 有効なLMモデルパスが選択されていることを確認
|
| 524 |
+
- vllmまたはPyTorchバックエンドが利用可能であることを確認
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
## キーボードショートカット
|
| 529 |
+
|
| 530 |
+
Gradioインターフェースは標準的なWebショートカットをサポート:
|
| 531 |
+
- **Tab** - 入力フィールド間を移動
|
| 532 |
+
- **Enter** - テキスト入力を送信
|
| 533 |
+
- **Space** - チェックボックスを切り替え
|
| 534 |
+
|
| 535 |
+
---
|
| 536 |
+
|
| 537 |
+
## 言語サポート
|
| 538 |
+
|
| 539 |
+
インターフェースは複数のUI言語をサポート:
|
| 540 |
+
- **英語** (en)
|
| 541 |
+
- **中国語** (zh)
|
| 542 |
+
- **日本語** (ja)
|
| 543 |
+
|
| 544 |
+
サービス設定セクションで好みの言語を選択してください。
|
| 545 |
+
|
| 546 |
+
---
|
| 547 |
+
|
| 548 |
+
詳細については以下を参照:
|
| 549 |
+
- メインREADME:[`../../README.md`](../../README.md)
|
| 550 |
+
- REST APIドキュメント:[`API.md`](API.md)
|
| 551 |
+
- Python推論API:[`INFERENCE.md`](INFERENCE.md)
|
docs/ja/INFERENCE.md
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ACE-Step 推論 API ドキュメント
|
| 2 |
+
|
| 3 |
+
**Language / 语言 / 言語:** [English](../en/INFERENCE.md) | [中文](../zh/INFERENCE.md) | [日本語](INFERENCE.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
本ドキュメントはACE-Step推論APIの包括的なドキュメントを提供し、サポートされているすべてのタスクタイプのパラメータ仕様を含みます。
|
| 8 |
+
|
| 9 |
+
## 目次
|
| 10 |
+
|
| 11 |
+
- [クイックスタート](#クイックスタート)
|
| 12 |
+
- [API概要](#api概要)
|
| 13 |
+
- [GenerationParamsパラメータ](#generationparamsパラメータ)
|
| 14 |
+
- [GenerationConfigパラメータ](#generationconfigパラメータ)
|
| 15 |
+
- [タスクタイプ](#タスクタイプ)
|
| 16 |
+
- [ヘルパー関数](#ヘルパー関数)
|
| 17 |
+
- [完全な例](#完全な例)
|
| 18 |
+
- [ベストプラクティス](#ベストプラクティス)
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## クイックスタート
|
| 23 |
+
|
| 24 |
+
### 基本的な使用法
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from acestep.handler import AceStepHandler
|
| 28 |
+
from acestep.llm_inference import LLMHandler
|
| 29 |
+
from acestep.inference import GenerationParams, GenerationConfig, generate_music
|
| 30 |
+
|
| 31 |
+
# ハンドラーの初期化
|
| 32 |
+
dit_handler = AceStepHandler()
|
| 33 |
+
llm_handler = LLMHandler()
|
| 34 |
+
|
| 35 |
+
# サービスの初期化
|
| 36 |
+
dit_handler.initialize_service(
|
| 37 |
+
project_root="/path/to/project",
|
| 38 |
+
config_path="acestep-v15-turbo-rl",
|
| 39 |
+
device="cuda"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
llm_handler.initialize(
|
| 43 |
+
checkpoint_dir="/path/to/checkpoints",
|
| 44 |
+
lm_model_path="acestep-5Hz-lm-0.6B-v3",
|
| 45 |
+
backend="vllm",
|
| 46 |
+
device="cuda"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
# 生成パラメータの設定
|
| 50 |
+
params = GenerationParams(
|
| 51 |
+
caption="重低音のアップビートなエレクトロニックダンスミュージック",
|
| 52 |
+
bpm=128,
|
| 53 |
+
duration=30,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# 生成設定の構成
|
| 57 |
+
config = GenerationConfig(
|
| 58 |
+
batch_size=2,
|
| 59 |
+
audio_format="flac",
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# 音楽を生成
|
| 63 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/path/to/output")
|
| 64 |
+
|
| 65 |
+
# 結果にアクセス
|
| 66 |
+
if result.success:
|
| 67 |
+
for audio in result.audios:
|
| 68 |
+
print(f"生成完了:{audio['path']}")
|
| 69 |
+
print(f"Key:{audio['key']}")
|
| 70 |
+
print(f"Seed:{audio['params']['seed']}")
|
| 71 |
+
else:
|
| 72 |
+
print(f"エラー:{result.error}")
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## API概要
|
| 78 |
+
|
| 79 |
+
### メイン関数
|
| 80 |
+
|
| 81 |
+
#### generate_music
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
def generate_music(
|
| 85 |
+
dit_handler,
|
| 86 |
+
llm_handler,
|
| 87 |
+
params: GenerationParams,
|
| 88 |
+
config: GenerationConfig,
|
| 89 |
+
save_dir: Optional[str] = None,
|
| 90 |
+
progress=None,
|
| 91 |
+
) -> GenerationResult
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
ACE-Stepモデルを使用して音楽を生成するメイン関数。
|
| 95 |
+
|
| 96 |
+
#### understand_music
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
def understand_music(
|
| 100 |
+
llm_handler,
|
| 101 |
+
audio_codes: str,
|
| 102 |
+
temperature: float = 0.85,
|
| 103 |
+
top_k: Optional[int] = None,
|
| 104 |
+
top_p: Optional[float] = None,
|
| 105 |
+
repetition_penalty: float = 1.0,
|
| 106 |
+
use_constrained_decoding: bool = True,
|
| 107 |
+
constrained_decoding_debug: bool = False,
|
| 108 |
+
) -> UnderstandResult
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
オーディオセマンティックコードを分析し、メタデータ(caption、lyrics、BPM、キーなど)を抽出します。
|
| 112 |
+
|
| 113 |
+
#### create_sample
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
def create_sample(
|
| 117 |
+
llm_handler,
|
| 118 |
+
query: str,
|
| 119 |
+
instrumental: bool = False,
|
| 120 |
+
vocal_language: Optional[str] = None,
|
| 121 |
+
temperature: float = 0.85,
|
| 122 |
+
top_k: Optional[int] = None,
|
| 123 |
+
top_p: Optional[float] = None,
|
| 124 |
+
repetition_penalty: float = 1.0,
|
| 125 |
+
use_constrained_decoding: bool = True,
|
| 126 |
+
constrained_decoding_debug: bool = False,
|
| 127 |
+
) -> CreateSampleResult
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
自然言語の説明から完全な音楽サンプル(caption、lyrics、メタデータ)を生成します。
|
| 131 |
+
|
| 132 |
+
#### format_sample
|
| 133 |
+
|
| 134 |
+
```python
|
| 135 |
+
def format_sample(
|
| 136 |
+
llm_handler,
|
| 137 |
+
caption: str,
|
| 138 |
+
lyrics: str,
|
| 139 |
+
user_metadata: Optional[Dict[str, Any]] = None,
|
| 140 |
+
temperature: float = 0.85,
|
| 141 |
+
top_k: Optional[int] = None,
|
| 142 |
+
top_p: Optional[float] = None,
|
| 143 |
+
repetition_penalty: float = 1.0,
|
| 144 |
+
use_constrained_decoding: bool = True,
|
| 145 |
+
constrained_decoding_debug: bool = False,
|
| 146 |
+
) -> FormatSampleResult
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
ユーザー提供のcaptionとlyricsをフォーマット・強化し、構造化されたメタデータを生成します。
|
| 150 |
+
|
| 151 |
+
### 設定オブジェクト
|
| 152 |
+
|
| 153 |
+
APIは2つの設定データクラスを使用します:
|
| 154 |
+
|
| 155 |
+
**GenerationParams** - すべての音楽生成パラメータを含む:
|
| 156 |
+
|
| 157 |
+
```python
|
| 158 |
+
@dataclass
|
| 159 |
+
class GenerationParams:
|
| 160 |
+
# タスクと指示
|
| 161 |
+
task_type: str = "text2music"
|
| 162 |
+
instruction: str = "Fill the audio semantic mask based on the given conditions:"
|
| 163 |
+
|
| 164 |
+
# オーディオアップロード
|
| 165 |
+
reference_audio: Optional[str] = None
|
| 166 |
+
src_audio: Optional[str] = None
|
| 167 |
+
|
| 168 |
+
# LMコードヒント
|
| 169 |
+
audio_codes: str = ""
|
| 170 |
+
|
| 171 |
+
# テキスト入力
|
| 172 |
+
caption: str = ""
|
| 173 |
+
lyrics: str = ""
|
| 174 |
+
instrumental: bool = False
|
| 175 |
+
|
| 176 |
+
# メタデータ
|
| 177 |
+
vocal_language: str = "unknown"
|
| 178 |
+
bpm: Optional[int] = None
|
| 179 |
+
keyscale: str = ""
|
| 180 |
+
timesignature: str = ""
|
| 181 |
+
duration: float = -1.0
|
| 182 |
+
|
| 183 |
+
# 高度な設定
|
| 184 |
+
inference_steps: int = 8
|
| 185 |
+
seed: int = -1
|
| 186 |
+
guidance_scale: float = 7.0
|
| 187 |
+
use_adg: bool = False
|
| 188 |
+
cfg_interval_start: float = 0.0
|
| 189 |
+
cfg_interval_end: float = 1.0
|
| 190 |
+
shift: float = 1.0 # 新規:タイムステップシフト係数
|
| 191 |
+
infer_method: str = "ode" # 新規:拡散推論方法
|
| 192 |
+
timesteps: Optional[List[float]] = None # 新規:カスタムタイムステップ
|
| 193 |
+
|
| 194 |
+
repainting_start: float = 0.0
|
| 195 |
+
repainting_end: float = -1
|
| 196 |
+
audio_cover_strength: float = 1.0
|
| 197 |
+
|
| 198 |
+
# 5Hz言語モデルパラメータ
|
| 199 |
+
thinking: bool = True
|
| 200 |
+
lm_temperature: float = 0.85
|
| 201 |
+
lm_cfg_scale: float = 2.0
|
| 202 |
+
lm_top_k: int = 0
|
| 203 |
+
lm_top_p: float = 0.9
|
| 204 |
+
lm_negative_prompt: str = "NO USER INPUT"
|
| 205 |
+
use_cot_metas: bool = True
|
| 206 |
+
use_cot_caption: bool = True
|
| 207 |
+
use_cot_lyrics: bool = False
|
| 208 |
+
use_cot_language: bool = True
|
| 209 |
+
use_constrained_decoding: bool = True
|
| 210 |
+
|
| 211 |
+
# CoT生成値(LMによって自動入力)
|
| 212 |
+
cot_bpm: Optional[int] = None
|
| 213 |
+
cot_keyscale: str = ""
|
| 214 |
+
cot_timesignature: str = ""
|
| 215 |
+
cot_duration: Optional[float] = None
|
| 216 |
+
cot_vocal_language: str = "unknown"
|
| 217 |
+
cot_caption: str = ""
|
| 218 |
+
cot_lyrics: str = ""
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
**GenerationConfig** - バッチと出力設定を含む:
|
| 222 |
+
|
| 223 |
+
```python
|
| 224 |
+
@dataclass
|
| 225 |
+
class GenerationConfig:
|
| 226 |
+
batch_size: int = 2
|
| 227 |
+
allow_lm_batch: bool = False
|
| 228 |
+
use_random_seed: bool = True
|
| 229 |
+
seeds: Optional[List[int]] = None
|
| 230 |
+
lm_batch_chunk_size: int = 8
|
| 231 |
+
constrained_decoding_debug: bool = False
|
| 232 |
+
audio_format: str = "flac"
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
### 結果オブジェクト
|
| 236 |
+
|
| 237 |
+
**GenerationResult** - 音楽生成の結果:
|
| 238 |
+
|
| 239 |
+
```python
|
| 240 |
+
@dataclass
|
| 241 |
+
class GenerationResult:
|
| 242 |
+
# オーディオ出力
|
| 243 |
+
audios: List[Dict[str, Any]] # オーディオ辞書のリスト
|
| 244 |
+
|
| 245 |
+
# 生成情報
|
| 246 |
+
status_message: str # 生成からのステータスメッセージ
|
| 247 |
+
extra_outputs: Dict[str, Any] # 追加出力(latents、masks、lm_metadata、time_costs)
|
| 248 |
+
|
| 249 |
+
# 成功ステータス
|
| 250 |
+
success: bool # 生成が成功したかどうか
|
| 251 |
+
error: Optional[str] # 失敗した場合のエラーメッセージ
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
**オーディオ辞書構造:**
|
| 255 |
+
|
| 256 |
+
`audios` リストの各アイテムには以下が含まれます:
|
| 257 |
+
|
| 258 |
+
```python
|
| 259 |
+
{
|
| 260 |
+
"path": str, # 保存されたオーディオへのファイルパス
|
| 261 |
+
"tensor": Tensor, # オーディオテンソル [channels, samples]、CPU、float32
|
| 262 |
+
"key": str, # ユニークなオーディオキー(パラメータに基づくUUID)
|
| 263 |
+
"sample_rate": int, # サンプルレート(デフォルト:48000)
|
| 264 |
+
"params": Dict, # このオーディオの生成パラメータ(seed、audio_codesなどを含む)
|
| 265 |
+
}
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
---
|
| 269 |
+
|
| 270 |
+
## GenerationParamsパラメータ
|
| 271 |
+
|
| 272 |
+
### テキスト入力
|
| 273 |
+
|
| 274 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 275 |
+
|-----------|------|---------|-------------|
|
| 276 |
+
| `caption` | `str` | `""` | 希望する音楽のテキスト説明。「リラックスしたピアノ音楽」のような単純なプロンプトや、ジャンル、ムード、楽器などを含む詳細な説明が可能。最大512文字。|
|
| 277 |
+
| `lyrics` | `str` | `""` | ボーカル音楽の歌詞テキスト。インストゥルメンタルトラックには `"[Instrumental]"` を使用。複数言語をサポート。最大4096文字。|
|
| 278 |
+
| `instrumental` | `bool` | `False` | Trueの場合、歌詞に関係なくインストゥルメンタル音楽を生成。|
|
| 279 |
+
|
| 280 |
+
### 音楽メタデータ
|
| 281 |
+
|
| 282 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 283 |
+
|-----------|------|---------|-------------|
|
| 284 |
+
| `bpm` | `Optional[int]` | `None` | 1分あたりのビート数(30-300)。`None` でLM経由の自動検出を有効化。|
|
| 285 |
+
| `keyscale` | `str` | `""` | 音楽キー(例:「C Major」、「Am」、「F# minor」)。空文字列で自動検出を有効化。|
|
| 286 |
+
| `timesignature` | `str` | `""` | 拍子記号(2は'2/4'、3は'3/4'、4は'4/4'、6は'6/8')。空文字列で自動検出を有効化。|
|
| 287 |
+
| `vocal_language` | `str` | `"unknown"` | ボーカルの言語コード(ISO 639-1)。サポート:`"en"`、`"zh"`、`"ja"`、`"es"`、`"fr"` など。自動検出には `"unknown"` を使用。|
|
| 288 |
+
| `duration` | `float` | `-1.0` | 目標オーディオ長(秒)(10-600)。<= 0またはNoneの場合、モデルが歌詞の長さに基づいて自動選択。|
|
| 289 |
+
|
| 290 |
+
### 生成パラメータ
|
| 291 |
+
|
| 292 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 293 |
+
|-----------|------|---------|-------------|
|
| 294 |
+
| `inference_steps` | `int` | `8` | デノイズステップ数。Turboモデル:1-20(推奨8)。Baseモデル:1-200(推奨32-64)。高い = 品質向上だが遅い。|
|
| 295 |
+
| `guidance_scale` | `float` | `7.0` | 分類器フリーガイダンススケール(1.0-15.0)。高い値はテキストプロンプトへの忠実性を増加。非turboモデルのみサポート。典型的な範囲:5.0-9.0。|
|
| 296 |
+
| `seed` | `int` | `-1` | 再現性のためのランダムシード。ランダムシードには `-1`、固定シードには���意の正の整数を使用。|
|
| 297 |
+
|
| 298 |
+
### 高度なDiTパラメータ
|
| 299 |
+
|
| 300 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 301 |
+
|-----------|------|---------|-------------|
|
| 302 |
+
| `use_adg` | `bool` | `False` | 適応デュアルガイダンスを使用(baseモデルのみ)。速度を犠牲にして品質を向上。|
|
| 303 |
+
| `cfg_interval_start` | `float` | `0.0` | CFG適用開始比率(0.0-1.0)。分類器フリーガイダンスの適用開始タイミングを制御。|
|
| 304 |
+
| `cfg_interval_end` | `float` | `1.0` | CFG適用終了比率(0.0-1.0)。分類器フリーガイダンスの適用終了タイミングを制御。|
|
| 305 |
+
| `shift` | `float` | `1.0` | タイムステップシフト係数(範囲1.0-5.0、デフォルト1.0)。!= 1.0の場合、タイムステップに `t = shift * t / (1 + (shift - 1) * t)` を適用。turboモデルには3.0推奨。|
|
| 306 |
+
| `infer_method` | `str` | `"ode"` | 拡散推論方法。`"ode"`(Euler)はより高速で決定的。`"sde"`(確率的)は分散のある異なる結果を生成する可能性あり。|
|
| 307 |
+
| `timesteps` | `Optional[List[float]]` | `None` | カスタムタイムステップ、1.0から0.0の浮動小数点リスト(例:`[0.97, 0.76, 0.615, 0.5, 0.395, 0.28, 0.18, 0.085, 0]`)。提供された場合、`inference_steps` と `shift` をオーバーライド。|
|
| 308 |
+
|
| 309 |
+
### タスク固有パラメータ
|
| 310 |
+
|
| 311 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 312 |
+
|-----------|------|---------|-------------|
|
| 313 |
+
| `task_type` | `str` | `"text2music"` | 生成タスクタイプ。詳細は[タスクタイプ](#タスクタイプ)セクションを参照。|
|
| 314 |
+
| `instruction` | `str` | `"Fill the audio semantic mask based on the given conditions:"` | タスク固有の指示プロンプト。|
|
| 315 |
+
| `reference_audio` | `Optional[str]` | `None` | スタイル転送または継続タスク用の参照オーディオファイルパス。|
|
| 316 |
+
| `src_audio` | `Optional[str]` | `None` | オーディオ間タスク(cover、repaintなど)用のソースオーディオファイルパス。|
|
| 317 |
+
| `audio_codes` | `str` | `""` | 事前抽出された5Hzオーディオセマンティックコード文字列。高度な使用のみ。|
|
| 318 |
+
| `repainting_start` | `float` | `0.0` | リペイント開始時間(秒)(repaint/legoタスク用)。|
|
| 319 |
+
| `repainting_end` | `float` | `-1` | リペイント終了時間(秒)。オーディオの終端には `-1` を使用。|
|
| 320 |
+
| `audio_cover_strength` | `float` | `1.0` | オーディオカバー/コードの影響強度(0.0-1.0)。スタイル転送タスクには小さい値(0.2)を設定。|
|
| 321 |
+
|
| 322 |
+
### 5Hz言語モデルパラメータ
|
| 323 |
+
|
| 324 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 325 |
+
|-----------|------|---------|-------------|
|
| 326 |
+
| `thinking` | `bool` | `True` | セマンティック/音楽メタデータとコード用の5Hz言語モデル「思考の連鎖」推論を有効化。|
|
| 327 |
+
| `lm_temperature` | `float` | `0.85` | LMサンプリング温度(0.0-2.0)。高い = より創造的/多様、低い = より保守的。|
|
| 328 |
+
| `lm_cfg_scale` | `float` | `2.0` | LM分類器フリーガイダンススケール。高い = プロンプトへのより強い忠実性。|
|
| 329 |
+
| `lm_top_k` | `int` | `0` | LM top-kサンプリング。`0` でtop-kフィルタリングを無効化。典型的な値:40-100。|
|
| 330 |
+
| `lm_top_p` | `float` | `0.9` | LM核サンプリング(0.0-1.0)。`1.0` で核サンプリングを無効化。典型的な値:0.9-0.95。|
|
| 331 |
+
| `lm_negative_prompt` | `str` | `"NO USER INPUT"` | LMガイダンス用のネガティブプロンプト。不要な特性を避けるのに役立つ。|
|
| 332 |
+
| `use_cot_metas` | `bool` | `True` | LM CoT推論を使用してメタデータを生成(BPM、キー、duration など)。|
|
| 333 |
+
| `use_cot_caption` | `bool` | `True` | LM CoT推論を使用してユーザーcaptionを改良。|
|
| 334 |
+
| `use_cot_language` | `bool` | `True` | LM CoT推論を使用してボーカル言語を検出。|
|
| 335 |
+
| `use_cot_lyrics` | `bool` | `False` | (将来の使用のために予約)LM CoTを使用して歌詞を生成/改良。|
|
| 336 |
+
| `use_constrained_decoding` | `bool` | `True` | 構造化されたLM出力のための制約付きデコーディングを有効化。|
|
| 337 |
+
|
| 338 |
+
---
|
| 339 |
+
|
| 340 |
+
## GenerationConfigパラメータ
|
| 341 |
+
|
| 342 |
+
| パラメータ | 型 | デフォルト | 説明 |
|
| 343 |
+
|-----------|------|---------|-------------|
|
| 344 |
+
| `batch_size` | `int` | `2` | 並列生成するサンプル数(1-8)。高い値はより多くのGPUメモリを必要とする。|
|
| 345 |
+
| `allow_lm_batch` | `bool` | `False` | LMでのバッチ処理を許可。`batch_size >= 2` かつ `thinking=True` の場合により高速。|
|
| 346 |
+
| `use_random_seed` | `bool` | `True` | ランダムシードを使用するかどうか。`True` で毎回異なる結果、`False` で再現可能な結果。|
|
| 347 |
+
| `seeds` | `Optional[List[int]]` | `None` | バッチ生成用のシードリスト。提供された場合、batch_sizeより少なければランダムシードでパディング。単一のintも可。|
|
| 348 |
+
| `lm_batch_chunk_size` | `int` | `8` | LM推論チャンクあたりの最大バッチサイズ(GPUメモリ制約)。|
|
| 349 |
+
| `constrained_decoding_debug` | `bool` | `False` | 制約付きデコーディングのデバッグログを有効化。|
|
| 350 |
+
| `audio_format` | `str` | `"flac"` | 出力オーディオ形式。オプション:`"mp3"`、`"wav"`、`"flac"`。高速保存のためデフォルトはFLAC。|
|
| 351 |
+
|
| 352 |
+
---
|
| 353 |
+
|
| 354 |
+
## タスクタイプ
|
| 355 |
+
|
| 356 |
+
ACE-Stepは6種類の生成タスクタイプをサポートし、それぞれ特定のユースケースに最適化されています。
|
| 357 |
+
|
| 358 |
+
### 1. Text2Music(デフォルト)
|
| 359 |
+
|
| 360 |
+
**目的**:テキスト説明とオプションのメタデータから音楽を生成。
|
| 361 |
+
|
| 362 |
+
**主要パラメータ**:
|
| 363 |
+
```python
|
| 364 |
+
params = GenerationParams(
|
| 365 |
+
task_type="text2music",
|
| 366 |
+
caption="エレキギターのエネルギッシュなロック音楽",
|
| 367 |
+
lyrics="[Instrumental]", # または実際の歌詞
|
| 368 |
+
bpm=140,
|
| 369 |
+
duration=30,
|
| 370 |
+
)
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
**必須**:
|
| 374 |
+
- `caption` または `lyrics`(少なくとも1つ)
|
| 375 |
+
|
| 376 |
+
**オプションだが推奨**:
|
| 377 |
+
- `bpm`:テンポを制御
|
| 378 |
+
- `keyscale`:音楽キーを制御
|
| 379 |
+
- `timesignature`:リズム構造を制御
|
| 380 |
+
- `duration`:長さを制御
|
| 381 |
+
- `vocal_language`:ボーカル特性を制御
|
| 382 |
+
|
| 383 |
+
**ユースケース**:
|
| 384 |
+
- テキスト説明から音楽を生成
|
| 385 |
+
- プロンプトからバッキングトラックを作成
|
| 386 |
+
- 歌詞付きの曲を生成
|
| 387 |
+
|
| 388 |
+
---
|
| 389 |
+
|
| 390 |
+
### 2. Cover
|
| 391 |
+
|
| 392 |
+
**目的**:既存のオーディオを構造を維持しながらスタイル/音色を変更して変換。
|
| 393 |
+
|
| 394 |
+
**主要パラメータ**:
|
| 395 |
+
```python
|
| 396 |
+
params = GenerationParams(
|
| 397 |
+
task_type="cover",
|
| 398 |
+
src_audio="original_song.mp3",
|
| 399 |
+
caption="ジャズピアノバージョン",
|
| 400 |
+
audio_cover_strength=0.8, # 0.0-1.0
|
| 401 |
+
)
|
| 402 |
+
```
|
| 403 |
+
|
| 404 |
+
**必須**:
|
| 405 |
+
- `src_audio`:ソースオーディオファイルパス
|
| 406 |
+
- `caption`:希望するスタイル/変換の説明
|
| 407 |
+
|
| 408 |
+
**オプション**:
|
| 409 |
+
- `audio_cover_strength`:元のオーディオの影響を制御
|
| 410 |
+
- `1.0`:元の構造を強く維持
|
| 411 |
+
- `0.5`:バランスの取れた変換
|
| 412 |
+
- `0.1`:緩やかな解釈
|
| 413 |
+
- `lyrics`:新しい歌詞(ボーカルを変更する場合)
|
| 414 |
+
|
| 415 |
+
**ユースケース**:
|
| 416 |
+
- 異なるスタイルのカバーを作成
|
| 417 |
+
- メロディを維持しながら楽器編成を変更
|
| 418 |
+
- ジャンル変換
|
| 419 |
+
|
| 420 |
+
---
|
| 421 |
+
|
| 422 |
+
### 3. Repaint
|
| 423 |
+
|
| 424 |
+
**目的**:オーディオの特定の時間セグメントを再生成し、残りは変更しない。
|
| 425 |
+
|
| 426 |
+
**主要パラメータ**:
|
| 427 |
+
```python
|
| 428 |
+
params = GenerationParams(
|
| 429 |
+
task_type="repaint",
|
| 430 |
+
src_audio="original.mp3",
|
| 431 |
+
repainting_start=10.0, # 秒
|
| 432 |
+
repainting_end=20.0, # 秒
|
| 433 |
+
caption="ピアノソロでスムーズなトランジション",
|
| 434 |
+
)
|
| 435 |
+
```
|
| 436 |
+
|
| 437 |
+
**必須**:
|
| 438 |
+
- `src_audio`:ソースオーディオファイルパス
|
| 439 |
+
- `repainting_start`:開始時間(秒)
|
| 440 |
+
- `repainting_end`:終了時間(秒)(ファイル終端には `-1` を使用)
|
| 441 |
+
- `caption`:リペイントセクションの希望するコンテンツの説明
|
| 442 |
+
|
| 443 |
+
**ユースケース**:
|
| 444 |
+
- 生成された音楽の特定セクションを修正
|
| 445 |
+
- 曲の一部にバリエーションを追加
|
| 446 |
+
- スムーズなトランジションを作成
|
| 447 |
+
- 問題のあるセグメントを置き換え
|
| 448 |
+
|
| 449 |
+
---
|
| 450 |
+
|
| 451 |
+
### 4. Lego(Baseモデルのみ)
|
| 452 |
+
|
| 453 |
+
**目的**:既存のオーディオのコンテキストで特定の楽器トラックを生成。
|
| 454 |
+
|
| 455 |
+
**主要パラメータ**:
|
| 456 |
+
```python
|
| 457 |
+
params = GenerationParams(
|
| 458 |
+
task_type="lego",
|
| 459 |
+
src_audio="backing_track.mp3",
|
| 460 |
+
instruction="Generate the guitar track based on the audio context:",
|
| 461 |
+
caption="ブルージーな感じのリードギターメロディ",
|
| 462 |
+
repainting_start=0.0,
|
| 463 |
+
repainting_end=-1,
|
| 464 |
+
)
|
| 465 |
+
```
|
| 466 |
+
|
| 467 |
+
**必須**:
|
| 468 |
+
- `src_audio`:ソース/バッキングオーディオパス
|
| 469 |
+
- `instruction`:トラックタイプを指定する必要あり(例:「Generate the {TRACK_NAME} track...」)
|
| 470 |
+
- `caption`:希望するトラック特性の説明
|
| 471 |
+
|
| 472 |
+
**利用可能なトラック**:
|
| 473 |
+
- `"vocals"`、`"backing_vocals"`、`"drums"`、`"bass"`、`"guitar"`、`"keyboard"`、
|
| 474 |
+
- `"percussion"`、`"strings"`、`"synth"`、`"fx"`、`"brass"`、`"woodwinds"`
|
| 475 |
+
|
| 476 |
+
**ユースケース**:
|
| 477 |
+
- 特定の楽器トラックを追加
|
| 478 |
+
- バッキングトラック上に追加の楽器をレイヤー
|
| 479 |
+
- マルチトラック作品を反復的に作成
|
| 480 |
+
|
| 481 |
+
---
|
| 482 |
+
|
| 483 |
+
### 5. Extract(Baseモデルのみ)
|
| 484 |
+
|
| 485 |
+
**目的**:ミックスオーディオから特定の楽器トラックを抽出/分離。
|
| 486 |
+
|
| 487 |
+
**主要パラメータ**:
|
| 488 |
+
```python
|
| 489 |
+
params = GenerationParams(
|
| 490 |
+
task_type="extract",
|
| 491 |
+
src_audio="full_mix.mp3",
|
| 492 |
+
instruction="Extract the vocals track from the audio:",
|
| 493 |
+
)
|
| 494 |
+
```
|
| 495 |
+
|
| 496 |
+
**必須**:
|
| 497 |
+
- `src_audio`:ミックスオーディオファイルパス
|
| 498 |
+
- `instruction`:抽出するトラックを指定する必要あり
|
| 499 |
+
|
| 500 |
+
**利用可能なトラック**:Legoタスクと同じ
|
| 501 |
+
|
| 502 |
+
**ユースケース**:
|
| 503 |
+
- ステム分離
|
| 504 |
+
- 特定の楽器を分離
|
| 505 |
+
- リミックスを作成
|
| 506 |
+
- 個別トラックを分析
|
| 507 |
+
|
| 508 |
+
---
|
| 509 |
+
|
| 510 |
+
### 6. Complete(Baseモデルのみ)
|
| 511 |
+
|
| 512 |
+
**目的**:指定された楽器で部分的なトラックを完成/拡張。
|
| 513 |
+
|
| 514 |
+
**主要パラメータ**:
|
| 515 |
+
```python
|
| 516 |
+
params = GenerationParams(
|
| 517 |
+
task_type="complete",
|
| 518 |
+
src_audio="incomplete_track.mp3",
|
| 519 |
+
instruction="Complete the input track with drums, bass, guitar:",
|
| 520 |
+
caption="ロックスタイルの完成",
|
| 521 |
+
)
|
| 522 |
+
```
|
| 523 |
+
|
| 524 |
+
**必須**:
|
| 525 |
+
- `src_audio`:不完全/部分的なトラックのパス
|
| 526 |
+
- `instruction`:追加するトラックを指定する必要あり
|
| 527 |
+
- `caption`:希望するスタイルの説明
|
| 528 |
+
|
| 529 |
+
**ユースケース**:
|
| 530 |
+
- 不完全な作品をアレンジ
|
| 531 |
+
- バッキングトラックを追加
|
| 532 |
+
- 音楽アイデアを自動完成
|
| 533 |
+
|
| 534 |
+
---
|
| 535 |
+
|
| 536 |
+
## ヘルパー関数
|
| 537 |
+
|
| 538 |
+
### understand_music
|
| 539 |
+
|
| 540 |
+
オーディオコードを分析して音楽についてのメタデータを抽出。
|
| 541 |
+
|
| 542 |
+
```python
|
| 543 |
+
from acestep.inference import understand_music
|
| 544 |
+
|
| 545 |
+
result = understand_music(
|
| 546 |
+
llm_handler=llm_handler,
|
| 547 |
+
audio_codes="<|audio_code_123|><|audio_code_456|>...",
|
| 548 |
+
temperature=0.85,
|
| 549 |
+
use_constrained_decoding=True,
|
| 550 |
+
)
|
| 551 |
+
|
| 552 |
+
if result.success:
|
| 553 |
+
print(f"Caption:{result.caption}")
|
| 554 |
+
print(f"歌詞:{result.lyrics}")
|
| 555 |
+
print(f"BPM:{result.bpm}")
|
| 556 |
+
print(f"キー:{result.keyscale}")
|
| 557 |
+
print(f"長さ:{result.duration}秒")
|
| 558 |
+
print(f"言語:{result.language}")
|
| 559 |
+
else:
|
| 560 |
+
print(f"エラー:{result.error}")
|
| 561 |
+
```
|
| 562 |
+
|
| 563 |
+
**ユースケース**:
|
| 564 |
+
- 既存の音楽を分析
|
| 565 |
+
- オーディオコードからメタデータを抽出
|
| 566 |
+
- 生成パラメータをリバースエンジニアリング
|
| 567 |
+
|
| 568 |
+
---
|
| 569 |
+
|
| 570 |
+
### create_sample
|
| 571 |
+
|
| 572 |
+
自然言語の説明から完全な音楽サンプルを生成。これは「シンプルモード」/「インスピレーションモード」機能です。
|
| 573 |
+
|
| 574 |
+
```python
|
| 575 |
+
from acestep.inference import create_sample
|
| 576 |
+
|
| 577 |
+
result = create_sample(
|
| 578 |
+
llm_handler=llm_handler,
|
| 579 |
+
query="静かな夜のための柔らかいベンガルのラブソング",
|
| 580 |
+
instrumental=False,
|
| 581 |
+
vocal_language="bn", # オプション:ベンガル語に制限
|
| 582 |
+
temperature=0.85,
|
| 583 |
+
)
|
| 584 |
+
|
| 585 |
+
if result.success:
|
| 586 |
+
print(f"Caption:{result.caption}")
|
| 587 |
+
print(f"歌詞:{result.lyrics}")
|
| 588 |
+
print(f"BPM:{result.bpm}")
|
| 589 |
+
print(f"長さ:{result.duration}秒")
|
| 590 |
+
print(f"キー:{result.keyscale}")
|
| 591 |
+
print(f"インストゥルメンタルか:{result.instrumental}")
|
| 592 |
+
|
| 593 |
+
# generate_musicと一緒に使用
|
| 594 |
+
params = GenerationParams(
|
| 595 |
+
caption=result.caption,
|
| 596 |
+
lyrics=result.lyrics,
|
| 597 |
+
bpm=result.bpm,
|
| 598 |
+
duration=result.duration,
|
| 599 |
+
keyscale=result.keyscale,
|
| 600 |
+
vocal_language=result.language,
|
| 601 |
+
)
|
| 602 |
+
else:
|
| 603 |
+
print(f"エラー:{result.error}")
|
| 604 |
+
```
|
| 605 |
+
|
| 606 |
+
---
|
| 607 |
+
|
| 608 |
+
### format_sample
|
| 609 |
+
|
| 610 |
+
ユーザー提供のcaptionとlyricsをフォーマット・強化し、構造化されたメタデータを生成。
|
| 611 |
+
|
| 612 |
+
```python
|
| 613 |
+
from acestep.inference import format_sample
|
| 614 |
+
|
| 615 |
+
result = format_sample(
|
| 616 |
+
llm_handler=llm_handler,
|
| 617 |
+
caption="ラテンポップ、レゲトン",
|
| 618 |
+
lyrics="[Verse 1]\nBailando en la noche...",
|
| 619 |
+
user_metadata={"bpm": 95}, # オプション:特定の値を制約
|
| 620 |
+
temperature=0.85,
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
if result.success:
|
| 624 |
+
print(f"強化されたCaption:{result.caption}")
|
| 625 |
+
print(f"フォーマットされた歌詞:{result.lyrics}")
|
| 626 |
+
print(f"BPM:{result.bpm}")
|
| 627 |
+
print(f"長さ:{result.duration}秒")
|
| 628 |
+
print(f"キー:{result.keyscale}")
|
| 629 |
+
print(f"検出された言語:{result.language}")
|
| 630 |
+
else:
|
| 631 |
+
print(f"エラー:{result.error}")
|
| 632 |
+
```
|
| 633 |
+
|
| 634 |
+
---
|
| 635 |
+
|
| 636 |
+
## ベストプラクティス
|
| 637 |
+
|
| 638 |
+
### 1. Captionの書き方
|
| 639 |
+
|
| 640 |
+
**良いCaption**:
|
| 641 |
+
```python
|
| 642 |
+
# 具体的で説明的
|
| 643 |
+
caption="重低音とシンセサイザーリードのアップビートなエレクトロニックダンスミュージック"
|
| 644 |
+
|
| 645 |
+
# ムードとジャンルを含む
|
| 646 |
+
caption="アコースティックギターと柔らかいボーカルのメランコリックなインディーフォーク"
|
| 647 |
+
|
| 648 |
+
# 楽器を指定
|
| 649 |
+
caption="ピアノ、アップライトベース、ブラシドラムのジャズトリオ"
|
| 650 |
+
```
|
| 651 |
+
|
| 652 |
+
**避けるべき**:
|
| 653 |
+
```python
|
| 654 |
+
# 曖昧すぎる
|
| 655 |
+
caption="良い音楽"
|
| 656 |
+
|
| 657 |
+
# 矛盾
|
| 658 |
+
caption="速い遅い音楽" # テンポの矛盾
|
| 659 |
+
```
|
| 660 |
+
|
| 661 |
+
### 2. パラメータチューニング
|
| 662 |
+
|
| 663 |
+
**最高品質のために**:
|
| 664 |
+
- baseモデルを使用し、`inference_steps=64` 以上
|
| 665 |
+
- `use_adg=True` を有効化
|
| 666 |
+
- `guidance_scale=7.0-9.0` を設定
|
| 667 |
+
- より良いタイムステップ分布のために `shift=3.0` を設定
|
| 668 |
+
- ロスレスオーディオ形式を使用(`audio_format="wav"`)
|
| 669 |
+
|
| 670 |
+
**速度のために**:
|
| 671 |
+
- turboモデルを使用し、`inference_steps=8`
|
| 672 |
+
- ADGを無効化(`use_adg=False`)
|
| 673 |
+
- `infer_method="ode"`(デフォルト)を使用
|
| 674 |
+
- 圧縮形式を使用(`audio_format="mp3"`)またはデフォルトのFLAC
|
| 675 |
+
|
| 676 |
+
**一貫性のために**:
|
| 677 |
+
- configで `use_random_seed=False` を設定
|
| 678 |
+
- 固定 `seeds` リストまたはparamsで単一 `seed` を使用
|
| 679 |
+
- `lm_temperature` を低く保つ(0.7-0.85)
|
| 680 |
+
|
| 681 |
+
**多様性のために**:
|
| 682 |
+
- configで `use_random_seed=True` を設定
|
| 683 |
+
- `lm_temperature` を増加(0.9-1.1)
|
| 684 |
+
- バリエーションのために `batch_size > 1` を使用
|
| 685 |
+
|
| 686 |
+
### 3. Durationガイドライン
|
| 687 |
+
|
| 688 |
+
- **インストゥルメンタル**:30-180秒が適切
|
| 689 |
+
- **歌詞付き**:自動検出を推奨(`duration=-1` を設定またはデフォルトのまま)
|
| 690 |
+
- **短いクリップ**:最小10-20秒
|
| 691 |
+
- **長尺**:最大600秒(10分)
|
| 692 |
+
|
| 693 |
+
### 4. LMの使用
|
| 694 |
+
|
| 695 |
+
**LMを有効にする場合(`thinking=True`)**:
|
| 696 |
+
- 自動メタデータ検出が必要
|
| 697 |
+
- caption改良が欲しい
|
| 698 |
+
- 最小限の入力から生成
|
| 699 |
+
- 多様な出力が必要
|
| 700 |
+
|
| 701 |
+
**LMを無効にする場合(`thinking=False`)**:
|
| 702 |
+
- すでに正確なメタデータがある
|
| 703 |
+
- より高速な生成が必要
|
| 704 |
+
- パラメータの完全な制御が欲しい
|
| 705 |
+
|
| 706 |
+
---
|
| 707 |
+
|
| 708 |
+
## トラブルシューティング
|
| 709 |
+
|
| 710 |
+
### よくある問題
|
| 711 |
+
|
| 712 |
+
**問題**:メモリ不足エラー
|
| 713 |
+
- **解決策**:`batch_size`、`inference_steps` を減らすか、CPUオフロードを有効化
|
| 714 |
+
|
| 715 |
+
**問題**:結果の品質が悪い
|
| 716 |
+
- **解決策**:`inference_steps` を増やす、`guidance_scale` を調整、baseモデルを使用
|
| 717 |
+
|
| 718 |
+
**問題**:結果がプロンプトと一致しない
|
| 719 |
+
- **解決策**:captionをより具体的に、`guidance_scale` を増やす、LM改良を有効化(`thinking=True`)
|
| 720 |
+
|
| 721 |
+
**問題**:生成が遅い
|
| 722 |
+
- **解決策**:turboモデルを使用、`inference_steps` を減らす、ADGを無効化
|
| 723 |
+
|
| 724 |
+
**問題**:LMがコードを生成しない
|
| 725 |
+
- **解決策**:`llm_handler` が初期化されていることを確認、`thinking=True` と `use_cot_metas=True` を確認
|
| 726 |
+
|
| 727 |
+
**問題**:シードが尊重されない
|
| 728 |
+
- **解決策**:configで `use_random_seed=False` を設定し、`seeds` リストまたはparamsで `seed` を提供
|
| 729 |
+
|
| 730 |
+
**問題**:カスタムタイムステップが機能しない
|
| 731 |
+
- **解決策**:タイムステップが1.0から0.0の浮動小数点リストで、適切に順序付けられていることを確認
|
| 732 |
+
|
| 733 |
+
---
|
| 734 |
+
|
| 735 |
+
詳細については以下を参照:
|
| 736 |
+
- メインREADME:[`../../README.md`](../../README.md)
|
| 737 |
+
- REST APIドキュメント:[`API.md`](API.md)
|
| 738 |
+
- Gradioデモガイド:[`GRADIO_GUIDE.md`](GRADIO_GUIDE.md)
|
| 739 |
+
- プロジェクトリポジトリ:[ACE-Step-1.5](https://github.com/yourusername/ACE-Step-1.5)
|
docs/zh/API.md
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
本服务提供基于 HTTP 的异步音乐生成 API。
|
| 8 |
+
|
| 9 |
+
**基本工作流程**:
|
| 10 |
+
1. 调用 `POST /v1/music/generate` 提交任务并获取 `job_id`。
|
| 11 |
+
2. 调用 `GET /v1/jobs/{job_id}` 轮询任务状态,直到 `status` 为 `succeeded` 或 `failed`。
|
| 12 |
+
3. 通过结果中返回的 `GET /v1/audio?path=...` URL 下载音频文件。
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 目录
|
| 17 |
+
|
| 18 |
+
- [任务状态说明](#1-任务状态说明)
|
| 19 |
+
- [创建生成任务](#2-创建生成任务)
|
| 20 |
+
- [查询任务结果](#3-查询任务结果)
|
| 21 |
+
- [随机样本生成](#4-随机样本生成)
|
| 22 |
+
- [列出可用模型](#5-列出可用模型)
|
| 23 |
+
- [下载音频文件](#6-下载音频文件)
|
| 24 |
+
- [健康检查](#7-健康检查)
|
| 25 |
+
- [环境变量](#8-环境变量)
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## 1. 任务状态说明
|
| 30 |
+
|
| 31 |
+
任务状态(`status`)包括以下类型:
|
| 32 |
+
|
| 33 |
+
- `queued`:任务已进入队列,等待执行。此时可以查看 `queue_position` 和 `eta_seconds`。
|
| 34 |
+
- `running`:生成正在进行中。
|
| 35 |
+
- `succeeded`:生成成功,结果在 `result` 字段中。
|
| 36 |
+
- `failed`:生成失败,错误信息在 `error` 字段中。
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## 2. 创建生成任务
|
| 41 |
+
|
| 42 |
+
### 2.1 API 定义
|
| 43 |
+
|
| 44 |
+
- **URL**:`/v1/music/generate`
|
| 45 |
+
- **方法**:`POST`
|
| 46 |
+
- **Content-Type**:`application/json`、`multipart/form-data` 或 `application/x-www-form-urlencoded`
|
| 47 |
+
|
| 48 |
+
### 2.2 请求参数
|
| 49 |
+
|
| 50 |
+
#### 参数命名约定
|
| 51 |
+
|
| 52 |
+
API 支持大多数参数的 **snake_case** 和 **camelCase** 命名。例如:
|
| 53 |
+
- `audio_duration` / `duration` / `audioDuration`
|
| 54 |
+
- `key_scale` / `keyscale` / `keyScale`
|
| 55 |
+
- `time_signature` / `timesignature` / `timeSignature`
|
| 56 |
+
- `sample_query` / `sampleQuery` / `description` / `desc`
|
| 57 |
+
- `use_format` / `useFormat` / `format`
|
| 58 |
+
|
| 59 |
+
此外,元数据可以通过嵌套对象传递(`metas`、`metadata` 或 `user_metadata`)。
|
| 60 |
+
|
| 61 |
+
#### 方法 A:JSON 请求(application/json)
|
| 62 |
+
|
| 63 |
+
适用于仅传递文本参数,或引用服务器上已存在的音频文件路径。
|
| 64 |
+
|
| 65 |
+
**基本参数**:
|
| 66 |
+
|
| 67 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 68 |
+
| :--- | :--- | :--- | :--- |
|
| 69 |
+
| `caption` | string | `""` | 音乐描述提示词 |
|
| 70 |
+
| `lyrics` | string | `""` | 歌词内容 |
|
| 71 |
+
| `thinking` | bool | `false` | 是否使用 5Hz LM 生成音频代码(lm-dit 行为)|
|
| 72 |
+
| `vocal_language` | string | `"en"` | 歌词语言(en、zh、ja 等)|
|
| 73 |
+
| `audio_format` | string | `"mp3"` | 输出格式(mp3、wav、flac)|
|
| 74 |
+
|
| 75 |
+
**样本/描述模式参数**:
|
| 76 |
+
|
| 77 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 78 |
+
| :--- | :--- | :--- | :--- |
|
| 79 |
+
| `sample_mode` | bool | `false` | 启用随机样本生成模式(通过 LM 自动生成 caption/lyrics/metas)|
|
| 80 |
+
| `sample_query` | string | `""` | 用于样本生成的自然语言描述(例如"一首柔和的孟加拉情歌")。别名:`description`、`desc` |
|
| 81 |
+
| `use_format` | bool | `false` | 使用 LM 增强/格式化提供的 caption 和 lyrics。别名:`format` |
|
| 82 |
+
|
| 83 |
+
**多模型支持**:
|
| 84 |
+
|
| 85 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 86 |
+
| :--- | :--- | :--- | :--- |
|
| 87 |
+
| `model` | string | null | 选择使用哪个 DiT 模型(例如 `"acestep-v15-turbo"`、`"acestep-v15-turbo-rl"`)。使用 `/v1/models` 列出可用模型。如果未指定,使用默认模型。|
|
| 88 |
+
|
| 89 |
+
**thinking 语义(重要)**:
|
| 90 |
+
|
| 91 |
+
- `thinking=false`:
|
| 92 |
+
- 服务器**不会**使用 5Hz LM 生成 `audio_code_string`。
|
| 93 |
+
- DiT 以 **text2music** 模式运行,**忽略**任何提供的 `audio_code_string`。
|
| 94 |
+
- `thinking=true`:
|
| 95 |
+
- 服务器将使用 5Hz LM 生成 `audio_code_string`(lm-dit 行为)。
|
| 96 |
+
- DiT 使用 LM 生成的代码运行,以增强音乐质量。
|
| 97 |
+
|
| 98 |
+
**元数据自动补全(条件性)**:
|
| 99 |
+
|
| 100 |
+
当 `use_cot_caption=true` 或 `use_cot_language=true` 或元数据字段缺失时,服务器可能会调用 5Hz LM 根据 `caption`/`lyrics` 填充缺失的字段:
|
| 101 |
+
|
| 102 |
+
- `bpm`
|
| 103 |
+
- `key_scale`
|
| 104 |
+
- `time_signature`
|
| 105 |
+
- `audio_duration`
|
| 106 |
+
|
| 107 |
+
用户提供的值始终优先;LM 只填充空/缺失的字段。
|
| 108 |
+
|
| 109 |
+
**音乐属性参数**:
|
| 110 |
+
|
| 111 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 112 |
+
| :--- | :--- | :--- | :--- |
|
| 113 |
+
| `bpm` | int | null | 指定节奏(BPM),范围 30-300 |
|
| 114 |
+
| `key_scale` | string | `""` | 调性(例如"C Major"、"Am")。别名:`keyscale`、`keyScale` |
|
| 115 |
+
| `time_signature` | string | `""` | 拍号(2、3、4、6 分别表示 2/4、3/4、4/4、6/8)。别名:`timesignature`、`timeSignature` |
|
| 116 |
+
| `audio_duration` | float | null | 生成时长(秒),范围 10-600。别名:`duration`、`target_duration` |
|
| 117 |
+
|
| 118 |
+
**音频代码(可选)**:
|
| 119 |
+
|
| 120 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 121 |
+
| :--- | :--- | :--- | :--- |
|
| 122 |
+
| `audio_code_string` | string 或 string[] | `""` | 用于 `llm_dit` 的音频语义令牌(5Hz)。别名:`audioCodeString` |
|
| 123 |
+
|
| 124 |
+
**生成控制参数**:
|
| 125 |
+
|
| 126 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 127 |
+
| :--- | :--- | :--- | :--- |
|
| 128 |
+
| `inference_steps` | int | `8` | 推理步数。Turbo 模型:1-20(推荐 8)。Base 模型:1-200(推荐 32-64)|
|
| 129 |
+
| `guidance_scale` | float | `7.0` | 提示引导系数。仅对 base 模型有效 |
|
| 130 |
+
| `use_random_seed` | bool | `true` | 是否使用随机种子 |
|
| 131 |
+
| `seed` | int | `-1` | 指定种子(当 use_random_seed=false 时)|
|
| 132 |
+
| `batch_size` | int | `2` | 批量生成数量(最多 8)|
|
| 133 |
+
|
| 134 |
+
**高级 DiT 参数**:
|
| 135 |
+
|
| 136 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 137 |
+
| :--- | :--- | :--- | :--- |
|
| 138 |
+
| `shift` | float | `3.0` | 时间步偏移因子(范围 1.0-5.0)。仅对 base 模型有效,对 turbo 模型无效 |
|
| 139 |
+
| `infer_method` | string | `"ode"` | 扩散推理方法:`"ode"`(Euler,更快)或 `"sde"`(随机)|
|
| 140 |
+
| `timesteps` | string | null | 自定义时间步,逗号分隔值(例如 `"0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0"`)。覆盖 `inference_steps` 和 `shift` |
|
| 141 |
+
| `use_adg` | bool | `false` | 使用自适应双引导(仅 base 模型)|
|
| 142 |
+
| `cfg_interval_start` | float | `0.0` | CFG 应用起始比例(0.0-1.0)|
|
| 143 |
+
| `cfg_interval_end` | float | `1.0` | CFG 应用结束比例(0.0-1.0)|
|
| 144 |
+
|
| 145 |
+
**5Hz LM 参数(可选,服务器端)**:
|
| 146 |
+
|
| 147 |
+
这些参数控制 5Hz LM 采样,用于元数据自动补全和(当 `thinking=true` 时)代码生成。
|
| 148 |
+
|
| 149 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 150 |
+
| :--- | :--- | :--- | :--- |
|
| 151 |
+
| `lm_model_path` | string | null | 5Hz LM 检查点目录名(例如 `acestep-5Hz-lm-0.6B-v3`)|
|
| 152 |
+
| `lm_backend` | string | `"vllm"` | `vllm` 或 `pt` |
|
| 153 |
+
| `lm_temperature` | float | `0.85` | 采样温度 |
|
| 154 |
+
| `lm_cfg_scale` | float | `2.5` | CFG 比例(>1 启用 CFG)|
|
| 155 |
+
| `lm_negative_prompt` | string | `"NO USER INPUT"` | CFG 使用的负面提示 |
|
| 156 |
+
| `lm_top_k` | int | null | Top-k(0/null 禁用)|
|
| 157 |
+
| `lm_top_p` | float | `0.9` | Top-p(>=1 将被视为禁用)|
|
| 158 |
+
| `lm_repetition_penalty` | float | `1.0` | 重复惩罚 |
|
| 159 |
+
|
| 160 |
+
**LM CoT(思维链)参数**:
|
| 161 |
+
|
| 162 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 163 |
+
| :--- | :--- | :--- | :--- |
|
| 164 |
+
| `use_cot_caption` | bool | `true` | 让 LM 通过 CoT 推理重写/增强输入 caption。别名:`cot_caption`、`cot-caption` |
|
| 165 |
+
| `use_cot_language` | bool | `true` | 让 LM 通过 CoT 检测人声语言。别名:`cot_language`、`cot-language` |
|
| 166 |
+
| `constrained_decoding` | bool | `true` | 启用基于 FSM 的约束解码以获得结构化 LM 输出。别名:`constrainedDecoding`、`constrained` |
|
| 167 |
+
| `constrained_decoding_debug` | bool | `false` | 启用约束解码的调试日志 |
|
| 168 |
+
|
| 169 |
+
**编辑/参考音频参数**(需要服务器上的绝对路径):
|
| 170 |
+
|
| 171 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 172 |
+
| :--- | :--- | :--- | :--- |
|
| 173 |
+
| `reference_audio_path` | string | null | 参考音频路径(风格迁移)|
|
| 174 |
+
| `src_audio_path` | string | null | 源音频路径(重绘/翻唱)|
|
| 175 |
+
| `task_type` | string | `"text2music"` | 任务类型:`text2music`、`cover`、`repaint`、`lego`、`extract`、`complete` |
|
| 176 |
+
| `instruction` | string | auto | 编辑指令(如未提供则根据 task_type 自动生成)|
|
| 177 |
+
| `repainting_start` | float | `0.0` | 重绘开始时间(秒)|
|
| 178 |
+
| `repainting_end` | float | null | 重绘结束时间(秒),-1 表示音频末尾 |
|
| 179 |
+
| `audio_cover_strength` | float | `1.0` | 翻唱强度(0.0-1.0)。风格迁移使用较小值(0.2)|
|
| 180 |
+
|
| 181 |
+
#### 方法 B:文件上传(multipart/form-data)
|
| 182 |
+
|
| 183 |
+
当需要上传本地音频文件作为参考或源音频时使用。
|
| 184 |
+
|
| 185 |
+
除了支持上述所有字段作为表单字段外,还支持以下文件字段:
|
| 186 |
+
|
| 187 |
+
- `reference_audio`:(文件)上传参考音频文件
|
| 188 |
+
- `src_audio`:(文件)上传源音频文件
|
| 189 |
+
|
| 190 |
+
> **注意**:上传文件后,相应的 `_path` 参数将被自动忽略,系统将使用上传后的临时文件路径。
|
| 191 |
+
|
| 192 |
+
### 2.3 响应示例
|
| 193 |
+
|
| 194 |
+
```json
|
| 195 |
+
{
|
| 196 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 197 |
+
"status": "queued",
|
| 198 |
+
"queue_position": 1
|
| 199 |
+
}
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
### 2.4 使用示例(cURL)
|
| 203 |
+
|
| 204 |
+
**基本 JSON 方法**:
|
| 205 |
+
|
| 206 |
+
```bash
|
| 207 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 208 |
+
-H 'Content-Type: application/json' \
|
| 209 |
+
-d '{
|
| 210 |
+
"caption": "欢快的流行歌曲",
|
| 211 |
+
"lyrics": "你好世界",
|
| 212 |
+
"inference_steps": 8
|
| 213 |
+
}'
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
**使用 thinking=true(LM 生成代码 + 填充缺失元数据)**:
|
| 217 |
+
|
| 218 |
+
```bash
|
| 219 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 220 |
+
-H 'Content-Type: application/json' \
|
| 221 |
+
-d '{
|
| 222 |
+
"caption": "欢快的流行歌曲",
|
| 223 |
+
"lyrics": "你好世界",
|
| 224 |
+
"thinking": true,
|
| 225 |
+
"lm_temperature": 0.85,
|
| 226 |
+
"lm_cfg_scale": 2.5
|
| 227 |
+
}'
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
**描述驱动生成(sample_query)**:
|
| 231 |
+
|
| 232 |
+
```bash
|
| 233 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 234 |
+
-H 'Content-Type: application/json' \
|
| 235 |
+
-d '{
|
| 236 |
+
"sample_query": "一首适合安静夜晚的柔和孟加拉情歌",
|
| 237 |
+
"thinking": true
|
| 238 |
+
}'
|
| 239 |
+
```
|
| 240 |
+
|
| 241 |
+
**使用格式增强(use_format=true)**:
|
| 242 |
+
|
| 243 |
+
```bash
|
| 244 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 245 |
+
-H 'Content-Type: application/json' \
|
| 246 |
+
-d '{
|
| 247 |
+
"caption": "流行摇滚",
|
| 248 |
+
"lyrics": "[Verse 1]\n走在街上...",
|
| 249 |
+
"use_format": true,
|
| 250 |
+
"thinking": true
|
| 251 |
+
}'
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
**选择特定模型**:
|
| 255 |
+
|
| 256 |
+
```bash
|
| 257 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 258 |
+
-H 'Content-Type: application/json' \
|
| 259 |
+
-d '{
|
| 260 |
+
"caption": "电子舞曲",
|
| 261 |
+
"model": "acestep-v15-turbo-rl",
|
| 262 |
+
"thinking": true
|
| 263 |
+
}'
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
**使用自定义时间步**:
|
| 267 |
+
|
| 268 |
+
```bash
|
| 269 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 270 |
+
-H 'Content-Type: application/json' \
|
| 271 |
+
-d '{
|
| 272 |
+
"caption": "爵士钢琴三重奏",
|
| 273 |
+
"timesteps": "0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0",
|
| 274 |
+
"thinking": true
|
| 275 |
+
}'
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
**使用 thinking=false(仅 DiT,但填充缺失元数据)**:
|
| 279 |
+
|
| 280 |
+
```bash
|
| 281 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 282 |
+
-H 'Content-Type: application/json' \
|
| 283 |
+
-d '{
|
| 284 |
+
"caption": "缓慢的情感民谣",
|
| 285 |
+
"lyrics": "...",
|
| 286 |
+
"thinking": false,
|
| 287 |
+
"bpm": 72
|
| 288 |
+
}'
|
| 289 |
+
```
|
| 290 |
+
|
| 291 |
+
**文件上传方法**:
|
| 292 |
+
|
| 293 |
+
```bash
|
| 294 |
+
curl -X POST http://localhost:8001/v1/music/generate \
|
| 295 |
+
-F "caption=重新混音这首歌" \
|
| 296 |
+
-F "src_audio=@/path/to/local/song.mp3" \
|
| 297 |
+
-F "task_type=repaint"
|
| 298 |
+
```
|
| 299 |
+
|
| 300 |
+
---
|
| 301 |
+
|
| 302 |
+
## 3. 查询任务结果
|
| 303 |
+
|
| 304 |
+
### 3.1 API 定义
|
| 305 |
+
|
| 306 |
+
- **URL**:`/v1/jobs/{job_id}`
|
| 307 |
+
- **方法**:`GET`
|
| 308 |
+
|
| 309 |
+
### 3.2 响应参数
|
| 310 |
+
|
| 311 |
+
响应包含基本任务信息、队列状态和最终结果。
|
| 312 |
+
|
| 313 |
+
**主要字段**:
|
| 314 |
+
|
| 315 |
+
- `status`:当前状态
|
| 316 |
+
- `queue_position`:当前队列位置(0 表示正在运行或已完成)
|
| 317 |
+
- `eta_seconds`:预计剩余等待时间(秒)
|
| 318 |
+
- `avg_job_seconds`:平均任务持续时间(用于 ETA 估算)
|
| 319 |
+
- `result`:成功时的结果对象
|
| 320 |
+
- `audio_paths`:生成的音频文件 URL 列表(配合 `/v1/audio` 端点使用)
|
| 321 |
+
- `first_audio_path`:第一个音频路径(URL)
|
| 322 |
+
- `second_audio_path`:第二个音频路径(URL,如果 batch_size >= 2)
|
| 323 |
+
- `generation_info`:生成参数详情
|
| 324 |
+
- `status_message`:简短结果描述
|
| 325 |
+
- `seed_value`:使用的种子值,逗号分隔
|
| 326 |
+
- `metas`:完整元数据字典
|
| 327 |
+
- `bpm`:检测到/使用的 BPM
|
| 328 |
+
- `duration`:检测到/使用的时长
|
| 329 |
+
- `keyscale`:检测到/使用的调性
|
| 330 |
+
- `timesignature`:检测到/使用的拍号
|
| 331 |
+
- `genres`:检测到的风格(如果可用)
|
| 332 |
+
- `lm_model`:使用的 LM 模型名称
|
| 333 |
+
- `dit_model`:使用的 DiT 模型名称
|
| 334 |
+
- `error`:失败时的错误信息
|
| 335 |
+
|
| 336 |
+
### 3.3 响应示例
|
| 337 |
+
|
| 338 |
+
**排队中**:
|
| 339 |
+
|
| 340 |
+
```json
|
| 341 |
+
{
|
| 342 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 343 |
+
"status": "queued",
|
| 344 |
+
"created_at": 1700000000.0,
|
| 345 |
+
"queue_position": 5,
|
| 346 |
+
"eta_seconds": 25.0,
|
| 347 |
+
"avg_job_seconds": 5.0,
|
| 348 |
+
"result": null,
|
| 349 |
+
"error": null
|
| 350 |
+
}
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
**执行成功**:
|
| 354 |
+
|
| 355 |
+
```json
|
| 356 |
+
{
|
| 357 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 358 |
+
"status": "succeeded",
|
| 359 |
+
"created_at": 1700000000.0,
|
| 360 |
+
"started_at": 1700000001.0,
|
| 361 |
+
"finished_at": 1700000010.0,
|
| 362 |
+
"queue_position": 0,
|
| 363 |
+
"result": {
|
| 364 |
+
"first_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 365 |
+
"second_audio_path": "/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3",
|
| 366 |
+
"audio_paths": [
|
| 367 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3",
|
| 368 |
+
"/v1/audio?path=%2Ftmp%2Fapi_audio%2Fdef456.mp3"
|
| 369 |
+
],
|
| 370 |
+
"generation_info": "🎵 生成了 2 个音频\n⏱️ 总计:8.5s\n🎲 种子:12345,67890",
|
| 371 |
+
"status_message": "✅ 生成成功完成!",
|
| 372 |
+
"seed_value": "12345,67890",
|
| 373 |
+
"metas": {
|
| 374 |
+
"bpm": 120,
|
| 375 |
+
"duration": 30,
|
| 376 |
+
"keyscale": "C Major",
|
| 377 |
+
"timesignature": "4",
|
| 378 |
+
"caption": "欢快的流行歌曲,旋律动听"
|
| 379 |
+
},
|
| 380 |
+
"bpm": 120,
|
| 381 |
+
"duration": 30,
|
| 382 |
+
"keyscale": "C Major",
|
| 383 |
+
"timesignature": "4",
|
| 384 |
+
"genres": null,
|
| 385 |
+
"lm_model": "acestep-5Hz-lm-0.6B-v3",
|
| 386 |
+
"dit_model": "acestep-v15-turbo-rl"
|
| 387 |
+
},
|
| 388 |
+
"error": null
|
| 389 |
+
}
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
---
|
| 393 |
+
|
| 394 |
+
## 4. 随机样本生成
|
| 395 |
+
|
| 396 |
+
### 4.1 API 定义
|
| 397 |
+
|
| 398 |
+
- **URL**:`/v1/music/random`
|
| 399 |
+
- **方法**:`POST`
|
| 400 |
+
|
| 401 |
+
此端点创建一个样本模式任务,通过 5Hz LM 自动生成 caption、lyrics 和元数据。
|
| 402 |
+
|
| 403 |
+
### 4.2 请求参数
|
| 404 |
+
|
| 405 |
+
| 参数名 | 类型 | 默认值 | 说明 |
|
| 406 |
+
| :--- | :--- | :--- | :--- |
|
| 407 |
+
| `thinking` | bool | `true` | 是否同时通过 LM 生成音频代码 |
|
| 408 |
+
|
| 409 |
+
### 4.3 响应示例
|
| 410 |
+
|
| 411 |
+
```json
|
| 412 |
+
{
|
| 413 |
+
"job_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 414 |
+
"status": "queued",
|
| 415 |
+
"queue_position": 1
|
| 416 |
+
}
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
### 4.4 使用示例
|
| 420 |
+
|
| 421 |
+
```bash
|
| 422 |
+
curl -X POST http://localhost:8001/v1/music/random \
|
| 423 |
+
-H 'Content-Type: application/json' \
|
| 424 |
+
-d '{"thinking": true}'
|
| 425 |
+
```
|
| 426 |
+
|
| 427 |
+
---
|
| 428 |
+
|
| 429 |
+
## 5. 列出可用模型
|
| 430 |
+
|
| 431 |
+
### 5.1 API 定义
|
| 432 |
+
|
| 433 |
+
- **URL**:`/v1/models`
|
| 434 |
+
- **方法**:`GET`
|
| 435 |
+
|
| 436 |
+
返回服务器上加载的可用 DiT 模型列表。
|
| 437 |
+
|
| 438 |
+
### 5.2 响应示例
|
| 439 |
+
|
| 440 |
+
```json
|
| 441 |
+
{
|
| 442 |
+
"models": [
|
| 443 |
+
{
|
| 444 |
+
"name": "acestep-v15-turbo-rl",
|
| 445 |
+
"is_default": true
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
"name": "acestep-v15-turbo",
|
| 449 |
+
"is_default": false
|
| 450 |
+
}
|
| 451 |
+
],
|
| 452 |
+
"default_model": "acestep-v15-turbo-rl"
|
| 453 |
+
}
|
| 454 |
+
```
|
| 455 |
+
|
| 456 |
+
### 5.3 使用示例
|
| 457 |
+
|
| 458 |
+
```bash
|
| 459 |
+
curl http://localhost:8001/v1/models
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## 6. 下载音频文件
|
| 465 |
+
|
| 466 |
+
### 6.1 API 定义
|
| 467 |
+
|
| 468 |
+
- **URL**:`/v1/audio`
|
| 469 |
+
- **方法**:`GET`
|
| 470 |
+
|
| 471 |
+
通过路径下载生成的音频文件。
|
| 472 |
+
|
| 473 |
+
### 6.2 请求参数
|
| 474 |
+
|
| 475 |
+
| 参数名 | 类型 | 说明 |
|
| 476 |
+
| :--- | :--- | :--- |
|
| 477 |
+
| `path` | string | URL 编码的音频文件路径 |
|
| 478 |
+
|
| 479 |
+
### 6.3 使用示例
|
| 480 |
+
|
| 481 |
+
```bash
|
| 482 |
+
# 使用任务结果中的 URL 下载
|
| 483 |
+
curl "http://localhost:8001/v1/audio?path=%2Ftmp%2Fapi_audio%2Fabc123.mp3" -o output.mp3
|
| 484 |
+
```
|
| 485 |
+
|
| 486 |
+
---
|
| 487 |
+
|
| 488 |
+
## 7. 健康检查
|
| 489 |
+
|
| 490 |
+
### 7.1 API 定义
|
| 491 |
+
|
| 492 |
+
- **URL**:`/health`
|
| 493 |
+
- **方法**:`GET`
|
| 494 |
+
|
| 495 |
+
返回服务健康状态。
|
| 496 |
+
|
| 497 |
+
### 7.2 响应示例
|
| 498 |
+
|
| 499 |
+
```json
|
| 500 |
+
{
|
| 501 |
+
"status": "ok",
|
| 502 |
+
"service": "ACE-Step API",
|
| 503 |
+
"version": "1.0"
|
| 504 |
+
}
|
| 505 |
+
```
|
| 506 |
+
|
| 507 |
+
---
|
| 508 |
+
|
| 509 |
+
## 8. 环境变量
|
| 510 |
+
|
| 511 |
+
API 服务器可以通过环境变量进行配置:
|
| 512 |
+
|
| 513 |
+
| 变量 | 默认值 | 说明 |
|
| 514 |
+
| :--- | :--- | :--- |
|
| 515 |
+
| `ACESTEP_API_HOST` | `127.0.0.1` | 服务器绑定主机 |
|
| 516 |
+
| `ACESTEP_API_PORT` | `8001` | 服务器绑定端口 |
|
| 517 |
+
| `ACESTEP_CONFIG_PATH` | `acestep-v15-turbo-rl` | 主 DiT 模型路径 |
|
| 518 |
+
| `ACESTEP_CONFIG_PATH2` | (空)| 辅助 DiT 模型路径(可选)|
|
| 519 |
+
| `ACESTEP_CONFIG_PATH3` | (空)| 第三个 DiT 模型路径(可选)|
|
| 520 |
+
| `ACESTEP_DEVICE` | `auto` | 模型加载设备 |
|
| 521 |
+
| `ACESTEP_USE_FLASH_ATTENTION` | `true` | 启用 flash attention |
|
| 522 |
+
| `ACESTEP_OFFLOAD_TO_CPU` | `false` | 空闲时将模型卸载到 CPU |
|
| 523 |
+
| `ACESTEP_OFFLOAD_DIT_TO_CPU` | `false` | 专门将 DiT 卸载到 CPU |
|
| 524 |
+
| `ACESTEP_LM_MODEL_PATH` | `acestep-5Hz-lm-0.6B-v3` | 默认 5Hz LM 模型 |
|
| 525 |
+
| `ACESTEP_LM_BACKEND` | `vllm` | LM 后端(vllm 或 pt)|
|
| 526 |
+
| `ACESTEP_LM_DEVICE` | (与 ACESTEP_DEVICE 相同)| LM 设备 |
|
| 527 |
+
| `ACESTEP_LM_OFFLOAD_TO_CPU` | `false` | 将 LM 卸载到 CPU |
|
| 528 |
+
| `ACESTEP_QUEUE_MAXSIZE` | `200` | 最大队列大小 |
|
| 529 |
+
| `ACESTEP_QUEUE_WORKERS` | `1` | 队列工作者数量 |
|
| 530 |
+
| `ACESTEP_AVG_JOB_SECONDS` | `5.0` | 初始平均任务持续时间估算 |
|
| 531 |
+
| `ACESTEP_TMPDIR` | `.cache/acestep/tmp` | 临时文件目录 |
|
| 532 |
+
|
| 533 |
+
---
|
| 534 |
+
|
| 535 |
+
## 错误处理
|
| 536 |
+
|
| 537 |
+
**HTTP 状态码**:
|
| 538 |
+
|
| 539 |
+
- `200`:成功
|
| 540 |
+
- `400`:无效请求(错误的 JSON、缺少字段)
|
| 541 |
+
- `404`:找不到任务
|
| 542 |
+
- `415`:不支持的 Content-Type
|
| 543 |
+
- `429`:服务器繁忙(队列已满)
|
| 544 |
+
- `500`:内部服务器错误
|
| 545 |
+
|
| 546 |
+
**错误响应格式**:
|
| 547 |
+
|
| 548 |
+
```json
|
| 549 |
+
{
|
| 550 |
+
"detail": "描述问题的错误消息"
|
| 551 |
+
}
|
| 552 |
+
```
|
| 553 |
+
|
| 554 |
+
---
|
| 555 |
+
|
| 556 |
+
## 最佳实践
|
| 557 |
+
|
| 558 |
+
1. **使用 `thinking=true`** 以获得 LM 增强生成的最佳质量结果。
|
| 559 |
+
|
| 560 |
+
2. **使用 `sample_query`/`description`** 从自然语言描述快速生成。
|
| 561 |
+
|
| 562 |
+
3. **使用 `use_format=true`** 当你有 caption/lyrics 但希望 LM 增强它们时。
|
| 563 |
+
|
| 564 |
+
4. **轮询任务状态** 时使用合理的间隔(例如每 1-2 秒),以避免服务器过载。
|
| 565 |
+
|
| 566 |
+
5. **检查 `avg_job_seconds`** 响应来估算等待时间。
|
| 567 |
+
|
| 568 |
+
6. **使用多模型支持** 通过设置 `ACESTEP_CONFIG_PATH2` 和 `ACESTEP_CONFIG_PATH3` 环境变量,然后通过 `model` 参数选择。
|
| 569 |
+
|
| 570 |
+
7. **生产环境** 中,始终设置正确的 Content-Type 头以避免 415 错误。
|
docs/zh/GRADIO_GUIDE.md
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
---
|
| 6 |
+
|
| 7 |
+
本指南提供使用 ACE-Step Gradio Web 界面进行音乐生成的综合文档,包括所有功能和设置。
|
| 8 |
+
|
| 9 |
+
## 目录
|
| 10 |
+
|
| 11 |
+
- [快速开始](#快速开始)
|
| 12 |
+
- [服务配置](#服务配置)
|
| 13 |
+
- [生成模式](#生成模式)
|
| 14 |
+
- [任务类型](#任务类型)
|
| 15 |
+
- [输入参数](#输入参数)
|
| 16 |
+
- [高级设置](#高级设置)
|
| 17 |
+
- [结果区域](#结果区域)
|
| 18 |
+
- [LoRA 训练](#lora-训练)
|
| 19 |
+
- [技巧与最佳实践](#技巧与最佳实践)
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## 快速开始
|
| 24 |
+
|
| 25 |
+
### 启动演示
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# 基本启动
|
| 29 |
+
python app.py
|
| 30 |
+
|
| 31 |
+
# 预初始化
|
| 32 |
+
python app.py --config acestep-v15-turbo-rl --init-llm
|
| 33 |
+
|
| 34 |
+
# 指定端口
|
| 35 |
+
python app.py --port 7860
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### 界面概述
|
| 39 |
+
|
| 40 |
+
Gradio 界面包含以下主要部分:
|
| 41 |
+
|
| 42 |
+
1. **服务配置** - 模型加载和初始化
|
| 43 |
+
2. **必需输入** - 任务类型、音频上传和生成模式
|
| 44 |
+
3. **音乐描述和歌词** - 生成的文本输入
|
| 45 |
+
4. **可选参数** - BPM、调性、时长等元数据
|
| 46 |
+
5. **高级设置** - 细粒度的生成控制
|
| 47 |
+
6. **结果** - 生成的音频播放和管理
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## 服务配置
|
| 52 |
+
|
| 53 |
+
### 模型选择
|
| 54 |
+
|
| 55 |
+
| 设置 | 说明 |
|
| 56 |
+
|---------|-------------|
|
| 57 |
+
| **检查点文件** | 选择已训练的模型检查点(如果可用)|
|
| 58 |
+
| **主模型路径** | 选择 DiT 模型配置(例如 `acestep-v15-turbo`、`acestep-v15-turbo-rl`)|
|
| 59 |
+
| **设备** | 处理设备:`auto`(推荐)、`cuda` 或 `cpu` |
|
| 60 |
+
|
| 61 |
+
### 5Hz LM 配置
|
| 62 |
+
|
| 63 |
+
| 设置 | 说明 |
|
| 64 |
+
|---------|-------------|
|
| 65 |
+
| **5Hz LM 模型路径** | 选择语言模型(例如 `acestep-5Hz-lm-0.6B`、`acestep-5Hz-lm-0.6B-v3`)|
|
| 66 |
+
| **5Hz LM 后端** | `vllm`(更快,推荐)或 `pt`(PyTorch,兼容性更好)|
|
| 67 |
+
| **初始化 5Hz LM** | 勾选以在初始化期间加载 LM(thinking 模式必需)|
|
| 68 |
+
|
| 69 |
+
### 性能选项
|
| 70 |
+
|
| 71 |
+
| 设置 | 说明 |
|
| 72 |
+
|---------|-------------|
|
| 73 |
+
| **使用 Flash Attention** | 启用以加速推理(需要 flash_attn 包)|
|
| 74 |
+
| **卸载到 CPU** | 空闲时将模型卸载到 CPU 以节省 GPU 内存 |
|
| 75 |
+
| **将 DiT 卸载到 CPU** | 专门将 DiT 模型卸载到 CPU |
|
| 76 |
+
|
| 77 |
+
### LoRA 适配器
|
| 78 |
+
|
| 79 |
+
| 设置 | 说明 |
|
| 80 |
+
|---------|-------------|
|
| 81 |
+
| **LoRA 路径** | 已训练的 LoRA 适配器目录路径 |
|
| 82 |
+
| **加载 LoRA** | 加载指定的 LoRA 适配器 |
|
| 83 |
+
| **卸载** | 移除当前加载的 LoRA |
|
| 84 |
+
| **使用 LoRA** | 启用/禁用已加载的 LoRA 进行推理 |
|
| 85 |
+
|
| 86 |
+
### 初始化
|
| 87 |
+
|
| 88 |
+
点击 **初始化服务** 加载模型。状态框将显示进度和确认信息。
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## 生成模式
|
| 93 |
+
|
| 94 |
+
### 简单模式
|
| 95 |
+
|
| 96 |
+
简单模式专为快速、基于自然语言的音乐生成设计。
|
| 97 |
+
|
| 98 |
+
**使用方法:**
|
| 99 |
+
1. 在生成模式单选按钮中选择"简单"
|
| 100 |
+
2. 在"歌曲描述"字段中输入自然语言描述
|
| 101 |
+
3. 如果不想要人声,可选择勾选"纯音乐"
|
| 102 |
+
4. 可选择首选人声语言
|
| 103 |
+
5. 点击 **创建样本** 生成 caption、歌词和元数据
|
| 104 |
+
6. 在展开的部分中查看生成的内容
|
| 105 |
+
7. 点击 **生成音乐** 创建音频
|
| 106 |
+
|
| 107 |
+
**示例描述:**
|
| 108 |
+
- "一首适合安静夜晚的柔和孟加拉情歌"
|
| 109 |
+
- "欢快的电子舞曲,重低音"
|
| 110 |
+
- "忧郁的独立民谣,原声吉他"
|
| 111 |
+
- "在烟雾弥漫的酒吧里演奏的爵士三重奏"
|
| 112 |
+
|
| 113 |
+
**随机样本:** 点击 🎲 按钮加载随机示例描述。
|
| 114 |
+
|
| 115 |
+
### 自定义模式
|
| 116 |
+
|
| 117 |
+
自定义模式提供对所有生成参数的完全控制。
|
| 118 |
+
|
| 119 |
+
**使用方法:**
|
| 120 |
+
1. 在生成模式单选按钮中选择"自定义"
|
| 121 |
+
2. 手动填写 Caption 和歌词字段
|
| 122 |
+
3. 设置可选元数据(BPM、调性、时长等)
|
| 123 |
+
4. 可选点击 **格式化** 使用 LM 增强您的输入
|
| 124 |
+
5. 根据需要配置高级设置
|
| 125 |
+
6. 点击 **生成音乐** 创建音频
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## 任务类型
|
| 130 |
+
|
| 131 |
+
### text2music(默认)
|
| 132 |
+
|
| 133 |
+
从文本描述和/或歌词生成音乐。
|
| 134 |
+
|
| 135 |
+
**用例:** 基于提示从头创建新音乐。
|
| 136 |
+
|
| 137 |
+
**必需输入:** Caption 或歌词(至少一个)
|
| 138 |
+
|
| 139 |
+
### cover
|
| 140 |
+
|
| 141 |
+
转换现有音频,保持结构但改变风格。
|
| 142 |
+
|
| 143 |
+
**用例:** 创建不同风格的翻唱版本。
|
| 144 |
+
|
| 145 |
+
**必需输入:**
|
| 146 |
+
- 源音频(在音频上传区域上传)
|
| 147 |
+
- 描述目标风格的 Caption
|
| 148 |
+
|
| 149 |
+
**关键参数:** `音频翻唱强度`(0.0-1.0)
|
| 150 |
+
- 较高的值保持更多原始结构
|
| 151 |
+
- 较低的值允许更多创意自由
|
| 152 |
+
|
| 153 |
+
### repaint
|
| 154 |
+
|
| 155 |
+
重新生成音频的特定时间段。
|
| 156 |
+
|
| 157 |
+
**用例:** 修复或修改生成音乐的特定部分。
|
| 158 |
+
|
| 159 |
+
**必需输入:**
|
| 160 |
+
- 源音频
|
| 161 |
+
- 重绘开始(秒)
|
| 162 |
+
- 重绘结束(秒,-1 表示文件末尾)
|
| 163 |
+
- 描述期望内容的 Caption
|
| 164 |
+
|
| 165 |
+
### lego(仅 Base 模型)
|
| 166 |
+
|
| 167 |
+
在现有音频的上下文中生成特定乐器轨道。
|
| 168 |
+
|
| 169 |
+
**用例:** 为伴奏添加乐器层。
|
| 170 |
+
|
| 171 |
+
**必需输入:**
|
| 172 |
+
- 源音频
|
| 173 |
+
- 轨道名称(从下拉菜单选择)
|
| 174 |
+
- 描述轨道特征的 Caption
|
| 175 |
+
|
| 176 |
+
**可用轨道:** vocals、backing_vocals、drums、bass、guitar、keyboard、percussion、strings、synth、fx、brass、woodwinds
|
| 177 |
+
|
| 178 |
+
### extract(仅 Base 模型)
|
| 179 |
+
|
| 180 |
+
从混音音频中提取/分离特定乐器轨道。
|
| 181 |
+
|
| 182 |
+
**用例:** 音轨分离、分离乐器。
|
| 183 |
+
|
| 184 |
+
**必需输入:**
|
| 185 |
+
- 源音频
|
| 186 |
+
- 要提取的轨道名称
|
| 187 |
+
|
| 188 |
+
### complete(仅 Base 模型)
|
| 189 |
+
|
| 190 |
+
用指定的乐器完成部分轨道。
|
| 191 |
+
|
| 192 |
+
**用例:** 自动编排不完整的作品。
|
| 193 |
+
|
| 194 |
+
**必需输入:**
|
| 195 |
+
- 源音频
|
| 196 |
+
- 轨道名称(多选)
|
| 197 |
+
- 描述期望风格的 Caption
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## 输入参数
|
| 202 |
+
|
| 203 |
+
### 必需输入
|
| 204 |
+
|
| 205 |
+
#### 任务类型
|
| 206 |
+
从下拉菜单选择生成任务。指令字段会根据选择的任务自动更新。
|
| 207 |
+
|
| 208 |
+
#### 音频上传
|
| 209 |
+
|
| 210 |
+
| 字段 | 说明 |
|
| 211 |
+
|-------|-------------|
|
| 212 |
+
| **参考音频** | 用于风格参考的可选音频 |
|
| 213 |
+
| **源音频** | cover、repaint、lego、extract、complete 任务必需 |
|
| 214 |
+
| **转换为代码** | 从源音频提取 5Hz 语义代码 |
|
| 215 |
+
|
| 216 |
+
#### LM 代码提示
|
| 217 |
+
|
| 218 |
+
可以在此粘贴预计算的音频语义代码来引导生成。使用 **转录** 按钮分析代码并提取元数据。
|
| 219 |
+
|
| 220 |
+
### 音乐描述
|
| 221 |
+
|
| 222 |
+
期望音乐的文本描述。请具体说明:
|
| 223 |
+
- 风格和类型
|
| 224 |
+
- 乐器
|
| 225 |
+
- 情绪和氛围
|
| 226 |
+
- 节奏感(如果不指定 BPM)
|
| 227 |
+
|
| 228 |
+
**示例:** "欢快的流行摇滚,电吉他、有力的鼓点和朗朗上口的合成器钩子"
|
| 229 |
+
|
| 230 |
+
点击 🎲 加载随机示例 caption。
|
| 231 |
+
|
| 232 |
+
### 歌词
|
| 233 |
+
|
| 234 |
+
输入带结构标签的歌词:
|
| 235 |
+
|
| 236 |
+
```
|
| 237 |
+
[Verse 1]
|
| 238 |
+
今天走在街上
|
| 239 |
+
想着你曾说过的话
|
| 240 |
+
|
| 241 |
+
[Chorus]
|
| 242 |
+
我在前进,我很坚强
|
| 243 |
+
这就是我属于的地方
|
| 244 |
+
|
| 245 |
+
[Verse 2]
|
| 246 |
+
...
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
**纯音乐复选框:** 勾选此项以生成纯音乐,无论歌词内容如何。
|
| 250 |
+
|
| 251 |
+
**人声语言:** 选择人声语言。对于自动检测或纯音乐,使用"unknown"。
|
| 252 |
+
|
| 253 |
+
**格式化按钮:** 点击使用 5Hz LM 增强 caption 和歌词。
|
| 254 |
+
|
| 255 |
+
### 可选参数
|
| 256 |
+
|
| 257 |
+
| 参数 | 默认值 | 说明 |
|
| 258 |
+
|-----------|---------|-------------|
|
| 259 |
+
| **BPM** | 自动 | 每分钟节拍数(30-300)|
|
| 260 |
+
| **调性** | 自动 | 音乐调性(例如"C Major"、"Am"、"F# minor")|
|
| 261 |
+
| **拍号** | 自动 | 拍号:2(2/4)、3(3/4)、4(4/4)、6(6/8)|
|
| 262 |
+
| **音频时长** | 自动/-1 | 目标长度(秒)(10-600)。-1 为自动 |
|
| 263 |
+
| **批量大小** | 2 | 要生成的音频变体数量(1-8)|
|
| 264 |
+
|
| 265 |
+
---
|
| 266 |
+
|
| 267 |
+
## 高级设置
|
| 268 |
+
|
| 269 |
+
### DiT 参数
|
| 270 |
+
|
| 271 |
+
| 参数 | 默认值 | 说明 |
|
| 272 |
+
|-----------|---------|-------------|
|
| 273 |
+
| **推理步数** | 8 | 去噪步数。Turbo:1-20,Base:1-200 |
|
| 274 |
+
| **引导比例** | 7.0 | CFG 强度(仅 base 模型)。越高 = 越遵循提示 |
|
| 275 |
+
| **种子** | -1 | 随机种子。批量使用逗号分隔的值 |
|
| 276 |
+
| **随机种子** | ✓ | 勾选时生成随机种子 |
|
| 277 |
+
| **音频格式** | mp3 | 输出格式:mp3、flac |
|
| 278 |
+
| **偏移** | 3.0 | 时间步偏移因子(1.0-5.0)。turbo 推荐 3.0 |
|
| 279 |
+
| **推理方法** | ode | ode(Euler,更快)或 sde(随机)|
|
| 280 |
+
| **自定义时间步** | - | 覆盖时间步(例如"0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0")|
|
| 281 |
+
|
| 282 |
+
### 仅 Base 模型参数
|
| 283 |
+
|
| 284 |
+
| 参数 | 默认值 | 说明 |
|
| 285 |
+
|-----------|---------|-------------|
|
| 286 |
+
| **使用 ADG** | ✗ | 启用自适应双引导以获得更好的质量 |
|
| 287 |
+
| **CFG 区间开始** | 0.0 | 何时开始应用 CFG(0.0-1.0)|
|
| 288 |
+
| **CFG 区间结束** | 1.0 | 何时停止应用 CFG(0.0-1.0)|
|
| 289 |
+
|
| 290 |
+
### LM 参数
|
| 291 |
+
|
| 292 |
+
| 参数 | 默认值 | 说明 |
|
| 293 |
+
|-----------|---------|-------------|
|
| 294 |
+
| **LM 温度** | 0.85 | 采样温度(0.0-2.0)。越高 = 越有创意 |
|
| 295 |
+
| **LM CFG 比例** | 2.0 | LM 引导强度(1.0-3.0)|
|
| 296 |
+
| **LM Top-K** | 0 | Top-K 采样。0 禁用 |
|
| 297 |
+
| **LM Top-P** | 0.9 | 核采样(0.0-1.0)|
|
| 298 |
+
| **LM 负面提示** | "NO USER INPUT" | CFG 的负面提示 |
|
| 299 |
+
|
| 300 |
+
### CoT(思维链)选项
|
| 301 |
+
|
| 302 |
+
| 选项 | 默认值 | 说明 |
|
| 303 |
+
|--------|---------|-------------|
|
| 304 |
+
| **CoT Metas** | ✓ | 通过 LM 推理生成元数据 |
|
| 305 |
+
| **CoT Language** | ✓ | 通过 LM 检测人声语言 |
|
| 306 |
+
| **约束解码调试** | ✗ | 启用调试日志 |
|
| 307 |
+
|
| 308 |
+
### 生成选项
|
| 309 |
+
|
| 310 |
+
| 选项 | 默认值 | 说明 |
|
| 311 |
+
|--------|---------|-------------|
|
| 312 |
+
| **LM 代码强度** | 1.0 | LM 代码对生成的影响程度(0.0-1.0)|
|
| 313 |
+
| **自动评分** | ✗ | 自动计算质量分数 |
|
| 314 |
+
| **自动 LRC** | ✗ | 自动生成歌词时间戳 |
|
| 315 |
+
| **LM 批处理块大小** | 8 | 每个 LM 批次的最大项目数(GPU 内存)|
|
| 316 |
+
|
| 317 |
+
### 主要生成控制
|
| 318 |
+
|
| 319 |
+
| 控制 | 说明 |
|
| 320 |
+
|---------|-------------|
|
| 321 |
+
| **Think** | 启用 5Hz LM 进行代码生成和元数据 |
|
| 322 |
+
| **ParallelThinking** | 启用并行 LM 批处理 |
|
| 323 |
+
| **CaptionRewrite** | 让 LM 增强输入 caption |
|
| 324 |
+
| **AutoGen** | 完成后自动开始下一批次 |
|
| 325 |
+
|
| 326 |
+
---
|
| 327 |
+
|
| 328 |
+
## 结果区域
|
| 329 |
+
|
| 330 |
+
### 生成的音频
|
| 331 |
+
|
| 332 |
+
根据批量大小最多显示 8 个音频样本。每个样本包括:
|
| 333 |
+
|
| 334 |
+
- **音频播放器** - 播放、暂停和下载生成的音频
|
| 335 |
+
- **发送到源** - 将此音频发送到源音频输入以进行进一步处理
|
| 336 |
+
- **保存** - 将音频和元数据保存到 JSON 文件
|
| 337 |
+
- **评分** - 计算基于困惑度的质量分数
|
| 338 |
+
- **LRC** - 生成歌词时间戳(LRC 格式)
|
| 339 |
+
|
| 340 |
+
### 详情折叠面板
|
| 341 |
+
|
| 342 |
+
点击"评分 & LRC & LM 代码"展开并查看:
|
| 343 |
+
- **LM 代码** - 此样本的 5Hz 语义代码
|
| 344 |
+
- **���量分数** - 基于困惑度的质量指标
|
| 345 |
+
- **歌词时间戳** - LRC 格式的时间数据
|
| 346 |
+
|
| 347 |
+
### 批次导航
|
| 348 |
+
|
| 349 |
+
| 控制 | 说明 |
|
| 350 |
+
|---------|-------------|
|
| 351 |
+
| **◀ 上一批** | 查看上一批 |
|
| 352 |
+
| **批次指示器** | 显示当前批次位置(例如"批次 1 / 3")|
|
| 353 |
+
| **下一批状态** | 显示后台生成进度 |
|
| 354 |
+
| **下一批 ▶** | 查看下一批(如果 AutoGen 开启则触发生成)|
|
| 355 |
+
|
| 356 |
+
### 恢复参数
|
| 357 |
+
|
| 358 |
+
点击 **应用这些设置到 UI** 将当前批次的所有生成参数恢复到输入字段。适用于迭代优化好的结果。
|
| 359 |
+
|
| 360 |
+
### 批次结果
|
| 361 |
+
|
| 362 |
+
"批次结果和生成详情"折叠面板包含:
|
| 363 |
+
- **所有生成的文件** - 下载所有批次的所有文件
|
| 364 |
+
- **生成详情** - 关于生成过程的详细信息
|
| 365 |
+
|
| 366 |
+
---
|
| 367 |
+
|
| 368 |
+
## LoRA 训练
|
| 369 |
+
|
| 370 |
+
LoRA 训练选项卡提供创建自定义 LoRA 适配器的工具。
|
| 371 |
+
|
| 372 |
+
### 数据集构建器选项卡
|
| 373 |
+
|
| 374 |
+
#### 步骤 1:加载或扫描
|
| 375 |
+
|
| 376 |
+
**选项 A:加载现有数据集**
|
| 377 |
+
1. 输入之前保存的数据集 JSON 路径
|
| 378 |
+
2. 点击 **加载**
|
| 379 |
+
|
| 380 |
+
**选项 B:扫描新目录**
|
| 381 |
+
1. 输入音频文件夹路径
|
| 382 |
+
2. 点击 **扫描** 查找音频文件(wav、mp3、flac、ogg、opus)
|
| 383 |
+
|
| 384 |
+
#### 步骤 2:配置数据集
|
| 385 |
+
|
| 386 |
+
| 设置 | 说明 |
|
| 387 |
+
|---------|-------------|
|
| 388 |
+
| **数据集名称** | 您的数据集名称 |
|
| 389 |
+
| **全部纯音乐** | 如果所有曲目都没有人声,请勾选 |
|
| 390 |
+
| **自定义激活标签** | 激活此 LoRA 风格的唯一标签 |
|
| 391 |
+
| **标签位置** | 放置标签的位置:前置、追加或替换 caption |
|
| 392 |
+
|
| 393 |
+
#### 步骤 3:自动标注
|
| 394 |
+
|
| 395 |
+
点击 **自动标注全部** 为所有音频文件生成元数据:
|
| 396 |
+
- Caption(音乐描述)
|
| 397 |
+
- BPM
|
| 398 |
+
- 调性
|
| 399 |
+
- 拍号
|
| 400 |
+
|
| 401 |
+
**跳过 Metas** 选项将跳过 LLM 标注并使用 N/A 值。
|
| 402 |
+
|
| 403 |
+
#### 步骤 4:预览和编辑
|
| 404 |
+
|
| 405 |
+
使用滑块选择样本并手动编辑:
|
| 406 |
+
- Caption
|
| 407 |
+
- 歌词
|
| 408 |
+
- BPM、调性、拍号
|
| 409 |
+
- 语言
|
| 410 |
+
- 纯音乐标志
|
| 411 |
+
|
| 412 |
+
点击 **保存更改** 更新样本。
|
| 413 |
+
|
| 414 |
+
#### 步骤 5:保存数据集
|
| 415 |
+
|
| 416 |
+
输入保存路径并点击 **保存数据集** 导出为 JSON。
|
| 417 |
+
|
| 418 |
+
#### 步骤 6:预处理
|
| 419 |
+
|
| 420 |
+
将数据集转换为预计算张量以加快训练:
|
| 421 |
+
1. 可选加载现有数据集 JSON
|
| 422 |
+
2. 设置张量输出目录
|
| 423 |
+
3. 点击 **预处理**
|
| 424 |
+
|
| 425 |
+
这会将音频编码为 VAE 潜变量,将文本编码为嵌入,并运行条件编码器。
|
| 426 |
+
|
| 427 |
+
### 训练 LoRA 选项卡
|
| 428 |
+
|
| 429 |
+
#### 数据集选择
|
| 430 |
+
|
| 431 |
+
输入预处理张量目录路径并点击 **加载数据集**。
|
| 432 |
+
|
| 433 |
+
#### LoRA 设置
|
| 434 |
+
|
| 435 |
+
| 设置 | 默认值 | 说明 |
|
| 436 |
+
|---------|---------|-------------|
|
| 437 |
+
| **LoRA 秩 (r)** | 64 | LoRA 容量。越高 = 容量越大,内存越多 |
|
| 438 |
+
| **LoRA Alpha** | 128 | 缩放因子(通常是秩的 2 倍)|
|
| 439 |
+
| **LoRA Dropout** | 0.1 | 用于正则化的 dropout 率 |
|
| 440 |
+
|
| 441 |
+
#### 训练参数
|
| 442 |
+
|
| 443 |
+
| 设置 | 默认值 | 说明 |
|
| 444 |
+
|---------|---------|-------------|
|
| 445 |
+
| **学习率** | 1e-4 | 优化学习率 |
|
| 446 |
+
| **最大 Epochs** | 500 | 最大训练 epochs |
|
| 447 |
+
| **批量大小** | 1 | 训练批量大小 |
|
| 448 |
+
| **梯度累积** | 1 | 有效批次 = batch_size × accumulation |
|
| 449 |
+
| **每 N Epochs 保存** | 200 | 检查点保存频率 |
|
| 450 |
+
| **偏移** | 3.0 | turbo 模型的时间步偏移 |
|
| 451 |
+
| **种子** | 42 | 用于可重复性的随机种子 |
|
| 452 |
+
|
| 453 |
+
#### 训练控制
|
| 454 |
+
|
| 455 |
+
- **开始训练** - 开始训练过程
|
| 456 |
+
- **停止训练** - 中断训练
|
| 457 |
+
- **训练进度** - 显示当前 epoch 和损失
|
| 458 |
+
- **训练日志** - 详细训练输出
|
| 459 |
+
- **训练损失图** - 可视化损失曲线
|
| 460 |
+
|
| 461 |
+
#### 导出 LoRA
|
| 462 |
+
|
| 463 |
+
训练后,导出最终适配器:
|
| 464 |
+
1. 输入导出路径
|
| 465 |
+
2. 点击 **导出 LoRA**
|
| 466 |
+
|
| 467 |
+
---
|
| 468 |
+
|
| 469 |
+
## 技巧与最佳实践
|
| 470 |
+
|
| 471 |
+
### 获得最佳质量
|
| 472 |
+
|
| 473 |
+
1. **使用 thinking 模式** - 保持"Think"复选框启用以获得 LM 增强的生成
|
| 474 |
+
2. **具体描述 caption** - 包含风格、乐器、情绪和风格细节
|
| 475 |
+
3. **让 LM 检测元数据** - 将 BPM/调性/时长留空以自动检测
|
| 476 |
+
4. **使用批量生成** - 生成 2-4 个变体并选择最好的
|
| 477 |
+
|
| 478 |
+
### 加快生成速度
|
| 479 |
+
|
| 480 |
+
1. **使用 turbo 模型** - 选择 `acestep-v15-turbo` 或 `acestep-v15-turbo-rl`
|
| 481 |
+
2. **保持推理步数为 8** - 这是 turbo 的最佳默认值
|
| 482 |
+
3. **减少批量大小** - 如果需要快速结果,降低批量大小
|
| 483 |
+
4. **禁用 AutoGen** - 手动控制批次生成
|
| 484 |
+
|
| 485 |
+
### 获得一致结果
|
| 486 |
+
|
| 487 |
+
1. **设置特定种子** - 取消勾选"随机种子"并输入种子值
|
| 488 |
+
2. **保存好的结果** - 使用"保存"导出参数以便重现
|
| 489 |
+
3. **使用"应用这些设置"** - 从好的批次恢复参数
|
| 490 |
+
|
| 491 |
+
### 长格式音乐
|
| 492 |
+
|
| 493 |
+
1. **设置明确的时长** - 以秒为单位指定时长
|
| 494 |
+
2. **使用 repaint 任务** - 初始生成后修复有问题的部分
|
| 495 |
+
3. **链式生成** - 使用"发送到源"在之前的结果上构建
|
| 496 |
+
|
| 497 |
+
### 风格一致性
|
| 498 |
+
|
| 499 |
+
1. **训练 LoRA** - 为您的风格创建自定义适配器
|
| 500 |
+
2. **使用参考音频** - 在音频上传中上传风格参考
|
| 501 |
+
3. **使用一致的 caption** - 保持相似的描述性语言
|
| 502 |
+
|
| 503 |
+
### 故障排除
|
| 504 |
+
|
| 505 |
+
**没有生成音频:**
|
| 506 |
+
- 检查模型是否已初始化(绿色状态消息)
|
| 507 |
+
- 如果使用 thinking 模式,确保 5Hz LM 已初始化
|
| 508 |
+
- 检查状态输出中的错误消息
|
| 509 |
+
|
| 510 |
+
**结果质量差:**
|
| 511 |
+
- 增加推理步数(对于 base 模型)
|
| 512 |
+
- 调整引导比例
|
| 513 |
+
- 尝试不同的种子
|
| 514 |
+
- 使 caption 更具体
|
| 515 |
+
|
| 516 |
+
**内存不足:**
|
| 517 |
+
- 减少批量大小
|
| 518 |
+
- 启用 CPU 卸载
|
| 519 |
+
- 减少 LM 批处理块大小
|
| 520 |
+
|
| 521 |
+
**LM 不工作:**
|
| 522 |
+
- 确保初始化期间勾选了"初始化 5Hz LM"
|
| 523 |
+
- 检查是否选择了有效的 LM 模型路径
|
| 524 |
+
- 验证 vllm 或 PyTorch 后端可用
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
## 键盘快捷键
|
| 529 |
+
|
| 530 |
+
Gradio 界面支持标准 Web 快捷键:
|
| 531 |
+
- **Tab** - 在输入字段之间移动
|
| 532 |
+
- **Enter** - 提交文本输入
|
| 533 |
+
- **Space** - 切换复选框
|
| 534 |
+
|
| 535 |
+
---
|
| 536 |
+
|
| 537 |
+
## 语言支持
|
| 538 |
+
|
| 539 |
+
界面支持多种 UI 语言:
|
| 540 |
+
- **英文** (en)
|
| 541 |
+
- **中文** (zh)
|
| 542 |
+
- **日文** (ja)
|
| 543 |
+
|
| 544 |
+
在服务配置区域选择您的首选语言。
|
| 545 |
+
|
| 546 |
+
---
|
| 547 |
+
|
| 548 |
+
更多信息,请参阅:
|
| 549 |
+
- 主 README:[`../../README.md`](../../README.md)
|
| 550 |
+
- REST API 文档:[`API.md`](API.md)
|
| 551 |
+
- Python 推理 API:[`INFERENCE.md`](INFERENCE.md)
|
docs/zh/INFERENCE.md
ADDED
|
@@ -0,0 +1,1049 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ACE-Step 推理 API 文档
|
| 2 |
+
|
| 3 |
+
**Language / 语言 / 言語:** [English](../en/INFERENCE.md) | [中文](INFERENCE.md) | [日本語](../ja/INFERENCE.md)
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
本文档提供 ACE-Step 推理 API 的综合文档,包括所有支持任务类型的参数规范。
|
| 8 |
+
|
| 9 |
+
## 目录
|
| 10 |
+
|
| 11 |
+
- [快速开始](#快速开始)
|
| 12 |
+
- [API 概述](#api-概述)
|
| 13 |
+
- [GenerationParams 参数](#generationparams-参数)
|
| 14 |
+
- [GenerationConfig 参数](#generationconfig-参数)
|
| 15 |
+
- [任务类型](#任务类型)
|
| 16 |
+
- [辅助函数](#辅助函数)
|
| 17 |
+
- [完整示例](#完整示例)
|
| 18 |
+
- [最佳实践](#最佳实践)
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## 快速开始
|
| 23 |
+
|
| 24 |
+
### 基本用法
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from acestep.handler import AceStepHandler
|
| 28 |
+
from acestep.llm_inference import LLMHandler
|
| 29 |
+
from acestep.inference import GenerationParams, GenerationConfig, generate_music
|
| 30 |
+
|
| 31 |
+
# 初始化处理器
|
| 32 |
+
dit_handler = AceStepHandler()
|
| 33 |
+
llm_handler = LLMHandler()
|
| 34 |
+
|
| 35 |
+
# 初始化服务
|
| 36 |
+
dit_handler.initialize_service(
|
| 37 |
+
project_root="/path/to/project",
|
| 38 |
+
config_path="acestep-v15-turbo-rl",
|
| 39 |
+
device="cuda"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
llm_handler.initialize(
|
| 43 |
+
checkpoint_dir="/path/to/checkpoints",
|
| 44 |
+
lm_model_path="acestep-5Hz-lm-0.6B-v3",
|
| 45 |
+
backend="vllm",
|
| 46 |
+
device="cuda"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
# 配置生成参数
|
| 50 |
+
params = GenerationParams(
|
| 51 |
+
caption="欢快的电子舞曲,重低音",
|
| 52 |
+
bpm=128,
|
| 53 |
+
duration=30,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# 配置生成设置
|
| 57 |
+
config = GenerationConfig(
|
| 58 |
+
batch_size=2,
|
| 59 |
+
audio_format="flac",
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# 生成音乐
|
| 63 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/path/to/output")
|
| 64 |
+
|
| 65 |
+
# 访问结果
|
| 66 |
+
if result.success:
|
| 67 |
+
for audio in result.audios:
|
| 68 |
+
print(f"已生成:{audio['path']}")
|
| 69 |
+
print(f"Key:{audio['key']}")
|
| 70 |
+
print(f"Seed:{audio['params']['seed']}")
|
| 71 |
+
else:
|
| 72 |
+
print(f"错误:{result.error}")
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## API 概述
|
| 78 |
+
|
| 79 |
+
### 主要函数
|
| 80 |
+
|
| 81 |
+
#### generate_music
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
def generate_music(
|
| 85 |
+
dit_handler,
|
| 86 |
+
llm_handler,
|
| 87 |
+
params: GenerationParams,
|
| 88 |
+
config: GenerationConfig,
|
| 89 |
+
save_dir: Optional[str] = None,
|
| 90 |
+
progress=None,
|
| 91 |
+
) -> GenerationResult
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
使用 ACE-Step 模型生成音乐的主函数。
|
| 95 |
+
|
| 96 |
+
#### understand_music
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
def understand_music(
|
| 100 |
+
llm_handler,
|
| 101 |
+
audio_codes: str,
|
| 102 |
+
temperature: float = 0.85,
|
| 103 |
+
top_k: Optional[int] = None,
|
| 104 |
+
top_p: Optional[float] = None,
|
| 105 |
+
repetition_penalty: float = 1.0,
|
| 106 |
+
use_constrained_decoding: bool = True,
|
| 107 |
+
constrained_decoding_debug: bool = False,
|
| 108 |
+
) -> UnderstandResult
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
分析音频语义代码并提取元数据(caption、lyrics、BPM、调性等)。
|
| 112 |
+
|
| 113 |
+
#### create_sample
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
def create_sample(
|
| 117 |
+
llm_handler,
|
| 118 |
+
query: str,
|
| 119 |
+
instrumental: bool = False,
|
| 120 |
+
vocal_language: Optional[str] = None,
|
| 121 |
+
temperature: float = 0.85,
|
| 122 |
+
top_k: Optional[int] = None,
|
| 123 |
+
top_p: Optional[float] = None,
|
| 124 |
+
repetition_penalty: float = 1.0,
|
| 125 |
+
use_constrained_decoding: bool = True,
|
| 126 |
+
constrained_decoding_debug: bool = False,
|
| 127 |
+
) -> CreateSampleResult
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
从自然语言描述生成完整的音乐样本(caption、lyrics、元数据)。
|
| 131 |
+
|
| 132 |
+
#### format_sample
|
| 133 |
+
|
| 134 |
+
```python
|
| 135 |
+
def format_sample(
|
| 136 |
+
llm_handler,
|
| 137 |
+
caption: str,
|
| 138 |
+
lyrics: str,
|
| 139 |
+
user_metadata: Optional[Dict[str, Any]] = None,
|
| 140 |
+
temperature: float = 0.85,
|
| 141 |
+
top_k: Optional[int] = None,
|
| 142 |
+
top_p: Optional[float] = None,
|
| 143 |
+
repetition_penalty: float = 1.0,
|
| 144 |
+
use_constrained_decoding: bool = True,
|
| 145 |
+
constrained_decoding_debug: bool = False,
|
| 146 |
+
) -> FormatSampleResult
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
格式化和增强用户提供的 caption 和 lyrics,生成结构化元数据。
|
| 150 |
+
|
| 151 |
+
### 配置对象
|
| 152 |
+
|
| 153 |
+
API 使用两个配置数据类:
|
| 154 |
+
|
| 155 |
+
**GenerationParams** - 包含所有音乐生成参数:
|
| 156 |
+
|
| 157 |
+
```python
|
| 158 |
+
@dataclass
|
| 159 |
+
class GenerationParams:
|
| 160 |
+
# 任务和指令
|
| 161 |
+
task_type: str = "text2music"
|
| 162 |
+
instruction: str = "Fill the audio semantic mask based on the given conditions:"
|
| 163 |
+
|
| 164 |
+
# 音频上传
|
| 165 |
+
reference_audio: Optional[str] = None
|
| 166 |
+
src_audio: Optional[str] = None
|
| 167 |
+
|
| 168 |
+
# LM 代码提示
|
| 169 |
+
audio_codes: str = ""
|
| 170 |
+
|
| 171 |
+
# 文本输入
|
| 172 |
+
caption: str = ""
|
| 173 |
+
lyrics: str = ""
|
| 174 |
+
instrumental: bool = False
|
| 175 |
+
|
| 176 |
+
# 元数据
|
| 177 |
+
vocal_language: str = "unknown"
|
| 178 |
+
bpm: Optional[int] = None
|
| 179 |
+
keyscale: str = ""
|
| 180 |
+
timesignature: str = ""
|
| 181 |
+
duration: float = -1.0
|
| 182 |
+
|
| 183 |
+
# 高级设置
|
| 184 |
+
inference_steps: int = 8
|
| 185 |
+
seed: int = -1
|
| 186 |
+
guidance_scale: float = 7.0
|
| 187 |
+
use_adg: bool = False
|
| 188 |
+
cfg_interval_start: float = 0.0
|
| 189 |
+
cfg_interval_end: float = 1.0
|
| 190 |
+
shift: float = 1.0 # 新增:时间步偏移因子
|
| 191 |
+
infer_method: str = "ode" # 新增:扩散推理方法
|
| 192 |
+
timesteps: Optional[List[float]] = None # 新增:自定义时间步
|
| 193 |
+
|
| 194 |
+
repainting_start: float = 0.0
|
| 195 |
+
repainting_end: float = -1
|
| 196 |
+
audio_cover_strength: float = 1.0
|
| 197 |
+
|
| 198 |
+
# 5Hz 语言模型参数
|
| 199 |
+
thinking: bool = True
|
| 200 |
+
lm_temperature: float = 0.85
|
| 201 |
+
lm_cfg_scale: float = 2.0
|
| 202 |
+
lm_top_k: int = 0
|
| 203 |
+
lm_top_p: float = 0.9
|
| 204 |
+
lm_negative_prompt: str = "NO USER INPUT"
|
| 205 |
+
use_cot_metas: bool = True
|
| 206 |
+
use_cot_caption: bool = True
|
| 207 |
+
use_cot_lyrics: bool = False
|
| 208 |
+
use_cot_language: bool = True
|
| 209 |
+
use_constrained_decoding: bool = True
|
| 210 |
+
|
| 211 |
+
# CoT 生成的值(由 LM 自动填充)
|
| 212 |
+
cot_bpm: Optional[int] = None
|
| 213 |
+
cot_keyscale: str = ""
|
| 214 |
+
cot_timesignature: str = ""
|
| 215 |
+
cot_duration: Optional[float] = None
|
| 216 |
+
cot_vocal_language: str = "unknown"
|
| 217 |
+
cot_caption: str = ""
|
| 218 |
+
cot_lyrics: str = ""
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
**GenerationConfig** - 包含批处理和输出配置:
|
| 222 |
+
|
| 223 |
+
```python
|
| 224 |
+
@dataclass
|
| 225 |
+
class GenerationConfig:
|
| 226 |
+
batch_size: int = 2
|
| 227 |
+
allow_lm_batch: bool = False
|
| 228 |
+
use_random_seed: bool = True
|
| 229 |
+
seeds: Optional[List[int]] = None
|
| 230 |
+
lm_batch_chunk_size: int = 8
|
| 231 |
+
constrained_decoding_debug: bool = False
|
| 232 |
+
audio_format: str = "flac"
|
| 233 |
+
```
|
| 234 |
+
|
| 235 |
+
### 结果对象
|
| 236 |
+
|
| 237 |
+
**GenerationResult** - 音乐生成结果:
|
| 238 |
+
|
| 239 |
+
```python
|
| 240 |
+
@dataclass
|
| 241 |
+
class GenerationResult:
|
| 242 |
+
# 音频输出
|
| 243 |
+
audios: List[Dict[str, Any]] # 音频字典列表
|
| 244 |
+
|
| 245 |
+
# 生成信息
|
| 246 |
+
status_message: str # 生成状态消息
|
| 247 |
+
extra_outputs: Dict[str, Any] # 额外输出(latents、masks、lm_metadata、time_costs)
|
| 248 |
+
|
| 249 |
+
# 成功状态
|
| 250 |
+
success: bool # 生成是否成功
|
| 251 |
+
error: Optional[str] # 失败时的错误消息
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
**音频字典结构:**
|
| 255 |
+
|
| 256 |
+
`audios` 列表中的每个项目包含:
|
| 257 |
+
|
| 258 |
+
```python
|
| 259 |
+
{
|
| 260 |
+
"path": str, # 保存的音频文件路径
|
| 261 |
+
"tensor": Tensor, # 音频张量 [channels, samples],CPU,float32
|
| 262 |
+
"key": str, # 唯一音频键(基于参数的 UUID)
|
| 263 |
+
"sample_rate": int, # 采样率(默认:48000)
|
| 264 |
+
"params": Dict, # 此音频的生成参数(包括 seed、audio_codes 等)
|
| 265 |
+
}
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
**UnderstandResult** - 音乐理解结果:
|
| 269 |
+
|
| 270 |
+
```python
|
| 271 |
+
@dataclass
|
| 272 |
+
class UnderstandResult:
|
| 273 |
+
# 元数据字段
|
| 274 |
+
caption: str = ""
|
| 275 |
+
lyrics: str = ""
|
| 276 |
+
bpm: Optional[int] = None
|
| 277 |
+
duration: Optional[float] = None
|
| 278 |
+
keyscale: str = ""
|
| 279 |
+
language: str = ""
|
| 280 |
+
timesignature: str = ""
|
| 281 |
+
|
| 282 |
+
# 状态
|
| 283 |
+
status_message: str = ""
|
| 284 |
+
success: bool = True
|
| 285 |
+
error: Optional[str] = None
|
| 286 |
+
```
|
| 287 |
+
|
| 288 |
+
**CreateSampleResult** - 样本创建结果:
|
| 289 |
+
|
| 290 |
+
```python
|
| 291 |
+
@dataclass
|
| 292 |
+
class CreateSampleResult:
|
| 293 |
+
# 元数据字段
|
| 294 |
+
caption: str = ""
|
| 295 |
+
lyrics: str = ""
|
| 296 |
+
bpm: Optional[int] = None
|
| 297 |
+
duration: Optional[float] = None
|
| 298 |
+
keyscale: str = ""
|
| 299 |
+
language: str = ""
|
| 300 |
+
timesignature: str = ""
|
| 301 |
+
instrumental: bool = False
|
| 302 |
+
|
| 303 |
+
# 状态
|
| 304 |
+
status_message: str = ""
|
| 305 |
+
success: bool = True
|
| 306 |
+
error: Optional[str] = None
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
**FormatSampleResult** - 样本格式化结果:
|
| 310 |
+
|
| 311 |
+
```python
|
| 312 |
+
@dataclass
|
| 313 |
+
class FormatSampleResult:
|
| 314 |
+
# 元数据字段
|
| 315 |
+
caption: str = ""
|
| 316 |
+
lyrics: str = ""
|
| 317 |
+
bpm: Optional[int] = None
|
| 318 |
+
duration: Optional[float] = None
|
| 319 |
+
keyscale: str = ""
|
| 320 |
+
language: str = ""
|
| 321 |
+
timesignature: str = ""
|
| 322 |
+
|
| 323 |
+
# 状态
|
| 324 |
+
status_message: str = ""
|
| 325 |
+
success: bool = True
|
| 326 |
+
error: Optional[str] = None
|
| 327 |
+
```
|
| 328 |
+
|
| 329 |
+
---
|
| 330 |
+
|
| 331 |
+
## GenerationParams 参数
|
| 332 |
+
|
| 333 |
+
### 文本输入
|
| 334 |
+
|
| 335 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 336 |
+
|-----------|------|---------|-------------|
|
| 337 |
+
| `caption` | `str` | `""` | 期望音乐的文本描述。可以是简单提示如"放松的钢琴音乐",或包含风格、情绪、乐器等的详细描述。最多 512 字符。|
|
| 338 |
+
| `lyrics` | `str` | `""` | 人声音乐的歌词文本。纯音乐使用 `"[Instrumental]"`。支持多种语言。最多 4096 字符。|
|
| 339 |
+
| `instrumental` | `bool` | `False` | 如果为 True,无论歌词如何都生成纯音乐。|
|
| 340 |
+
|
| 341 |
+
### 音乐元数据
|
| 342 |
+
|
| 343 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 344 |
+
|-----------|------|---------|-------------|
|
| 345 |
+
| `bpm` | `Optional[int]` | `None` | 每分钟节拍数(30-300)。`None` 启用通过 LM 自动检测。|
|
| 346 |
+
| `keyscale` | `str` | `""` | 音乐调性(例如"C Major"、"Am"、"F# minor")。空字符串启用自动检测。|
|
| 347 |
+
| `timesignature` | `str` | `""` | 拍号(2 表示 '2/4',3 表示 '3/4',4 表示 '4/4',6 表示 '6/8')。空字符串启用自动检测。|
|
| 348 |
+
| `vocal_language` | `str` | `"unknown"` | 人声语言代码(ISO 639-1)。支持:`"en"`、`"zh"`、`"ja"`、`"es"`、`"fr"` 等。使用 `"unknown"` 自动检测。|
|
| 349 |
+
| `duration` | `float` | `-1.0` | 目标音频长度(秒)(10-600)。如果 <= 0 或 None,模型根据歌词长度自动选择。|
|
| 350 |
+
|
| 351 |
+
### 生成参数
|
| 352 |
+
|
| 353 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 354 |
+
|-----------|------|---------|-------------|
|
| 355 |
+
| `inference_steps` | `int` | `8` | 去噪步数。Turbo 模型:1-20(推荐 8)。Base 模型:1-200(推荐 32-64)。越高 = 质量越好但更慢。|
|
| 356 |
+
| `guidance_scale` | `float` | `7.0` | 无分类器引导比例(1.0-15.0)。较高的值增加对文本提示的遵循度。仅支持非 turbo 模型。典型范围:5.0-9.0。|
|
| 357 |
+
| `seed` | `int` | `-1` | 用于可重复性的随机种子。使用 `-1` 表示随机种子,或任何正整数表示固定种子。|
|
| 358 |
+
|
| 359 |
+
### 高级 DiT 参数
|
| 360 |
+
|
| 361 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 362 |
+
|-----------|------|---------|-------------|
|
| 363 |
+
| `use_adg` | `bool` | `False` | 使用自适应双引导(仅 base 模型)。以速度为代价提高质量。|
|
| 364 |
+
| `cfg_interval_start` | `float` | `0.0` | CFG 应用起始比例(0.0-1.0)。控制何时开始应用无分类器引导。|
|
| 365 |
+
| `cfg_interval_end` | `float` | `1.0` | CFG 应用结束比例(0.0-1.0)。控制何时停止应用无分类器引导。|
|
| 366 |
+
| `shift` | `float` | `1.0` | 时间步偏移因子(范围 1.0-5.0,默认 1.0)。当 != 1.0 时,对时间步应用 `t = shift * t / (1 + (shift - 1) * t)`。turbo 模型推荐 3.0。|
|
| 367 |
+
| `infer_method` | `str` | `"ode"` | 扩散推理方法。`"ode"`(Euler)更快且确定性。`"sde"`(随机)可能产生不同的带方差结果。|
|
| 368 |
+
| `timesteps` | `Optional[List[float]]` | `None` | 自定义时间步,从 1.0 到 0.0 的浮点数列表(例如 `[0.97, 0.76, 0.615, 0.5, 0.395, 0.28, 0.18, 0.085, 0]`)。如果提供,覆盖 `inference_steps` 和 `shift`。|
|
| 369 |
+
|
| 370 |
+
### 任务特定参数
|
| 371 |
+
|
| 372 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 373 |
+
|-----------|------|---------|-------------|
|
| 374 |
+
| `task_type` | `str` | `"text2music"` | 生成任务类型。详见[任务类型](#任务类型)部分。|
|
| 375 |
+
| `instruction` | `str` | `"Fill the audio semantic mask based on the given conditions:"` | 任务特定指令提示。|
|
| 376 |
+
| `reference_audio` | `Optional[str]` | `None` | 用于风格迁移或续写任务的参考音频文件路径。|
|
| 377 |
+
| `src_audio` | `Optional[str]` | `None` | 用于音频到音频任务(cover、repaint 等)的源音频文件路径。|
|
| 378 |
+
| `audio_codes` | `str` | `""` | 预提取的 5Hz 音频语义代码字符串。仅供高级使用。|
|
| 379 |
+
| `repainting_start` | `float` | `0.0` | 重绘开始时间(秒)(用于 repaint/lego 任务)。|
|
| 380 |
+
| `repainting_end` | `float` | `-1` | 重绘结束时间(秒)。使用 `-1` 表示音频末尾。|
|
| 381 |
+
| `audio_cover_strength` | `float` | `1.0` | 音频 cover/代码影响强度(0.0-1.0)。风格迁移任务设置较小值(0.2)。|
|
| 382 |
+
|
| 383 |
+
### 5Hz 语言模型参数
|
| 384 |
+
|
| 385 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 386 |
+
|-----------|------|---------|-------------|
|
| 387 |
+
| `thinking` | `bool` | `True` | 启用 5Hz 语言模型"思维链"推理用于语义/音乐元数据和代码。|
|
| 388 |
+
| `lm_temperature` | `float` | `0.85` | LM 采样温度(0.0-2.0)。越高 = 更有创意/多样,越低 = 更保守。|
|
| 389 |
+
| `lm_cfg_scale` | `float` | `2.0` | LM 无分类器引导比例。越高 = 更强的提示遵循度。|
|
| 390 |
+
| `lm_top_k` | `int` | `0` | LM top-k 采样。`0` 禁用 top-k 过滤。典型值:40-100。|
|
| 391 |
+
| `lm_top_p` | `float` | `0.9` | LM 核采样(0.0-1.0)。`1.0` 禁用核采样。典型值:0.9-0.95。|
|
| 392 |
+
| `lm_negative_prompt` | `str` | `"NO USER INPUT"` | LM 引导的负面提示。帮助避免不想要的特征。|
|
| 393 |
+
| `use_cot_metas` | `bool` | `True` | 使用 LM CoT 推理生成元数据(BPM、调性、时长等)。|
|
| 394 |
+
| `use_cot_caption` | `bool` | `True` | 使用 LM CoT 推理优化用户 caption。|
|
| 395 |
+
| `use_cot_language` | `bool` | `True` | 使用 LM CoT 推理检测人声语言。|
|
| 396 |
+
| `use_cot_lyrics` | `bool` | `False` | (保留供将来使用)使用 LM CoT 生成/优化歌词。|
|
| 397 |
+
| `use_constrained_decoding` | `bool` | `True` | 启用结构化 LM 输出的约束解码。|
|
| 398 |
+
|
| 399 |
+
### CoT 生成的值
|
| 400 |
+
|
| 401 |
+
这些字段在启用 CoT 推理时由 LM 自动填充:
|
| 402 |
+
|
| 403 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 404 |
+
|-----------|------|---------|-------------|
|
| 405 |
+
| `cot_bpm` | `Optional[int]` | `None` | LM 生成的 BPM 值。|
|
| 406 |
+
| `cot_keyscale` | `str` | `""` | LM 生成的调性。|
|
| 407 |
+
| `cot_timesignature` | `str` | `""` | LM 生成的拍号。|
|
| 408 |
+
| `cot_duration` | `Optional[float]` | `None` | LM 生成的时长。|
|
| 409 |
+
| `cot_vocal_language` | `str` | `"unknown"` | LM 检测的人声语言。|
|
| 410 |
+
| `cot_caption` | `str` | `""` | LM 优化的 caption。|
|
| 411 |
+
| `cot_lyrics` | `str` | `""` | LM 生成/优化的歌词。|
|
| 412 |
+
|
| 413 |
+
---
|
| 414 |
+
|
| 415 |
+
## GenerationConfig 参数
|
| 416 |
+
|
| 417 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 418 |
+
|-----------|------|---------|-------------|
|
| 419 |
+
| `batch_size` | `int` | `2` | 并行生成的样本数量(1-8)。较高的值需要更多 GPU 内存。|
|
| 420 |
+
| `allow_lm_batch` | `bool` | `False` | 允许 LM 批处理。当 `batch_size >= 2` 且 `thinking=True` 时更快。|
|
| 421 |
+
| `use_random_seed` | `bool` | `True` | 是否使用随机种子。`True` 每次不同结果,`False` 可重复结果。|
|
| 422 |
+
| `seeds` | `Optional[List[int]]` | `None` | 批量生成的种子列表。如果提供的种子少于 batch_size,将用随机种子填充。也可以是单个 int。|
|
| 423 |
+
| `lm_batch_chunk_size` | `int` | `8` | 每个 LM 推理块的最大批处理大小(GPU 内存限制)。|
|
| 424 |
+
| `constrained_decoding_debug` | `bool` | `False` | 启用约束解码的调试日志。|
|
| 425 |
+
| `audio_format` | `str` | `"flac"` | 输出音频格式。选项:`"mp3"`、`"wav"`、`"flac"`。默认 FLAC 以快速保存。|
|
| 426 |
+
|
| 427 |
+
---
|
| 428 |
+
|
| 429 |
+
## 任务类型
|
| 430 |
+
|
| 431 |
+
ACE-Step 支持 6 种不同的生成任���类型,每种都针对特定用例进行了优化。
|
| 432 |
+
|
| 433 |
+
### 1. Text2Music(默认)
|
| 434 |
+
|
| 435 |
+
**目的**:从文本描述和可选元数据生成音乐。
|
| 436 |
+
|
| 437 |
+
**关键参数**:
|
| 438 |
+
```python
|
| 439 |
+
params = GenerationParams(
|
| 440 |
+
task_type="text2music",
|
| 441 |
+
caption="充满活力的摇滚音乐,电吉他",
|
| 442 |
+
lyrics="[Instrumental]", # 或实际歌词
|
| 443 |
+
bpm=140,
|
| 444 |
+
duration=30,
|
| 445 |
+
)
|
| 446 |
+
```
|
| 447 |
+
|
| 448 |
+
**必需**:
|
| 449 |
+
- `caption` 或 `lyrics`(至少一个)
|
| 450 |
+
|
| 451 |
+
**可选但推荐**:
|
| 452 |
+
- `bpm`:控制节奏
|
| 453 |
+
- `keyscale`:控制音乐调性
|
| 454 |
+
- `timesignature`:控制节拍结构
|
| 455 |
+
- `duration`:控制长度
|
| 456 |
+
- `vocal_language`:控制人声特征
|
| 457 |
+
|
| 458 |
+
**用例**:
|
| 459 |
+
- 从文本描述生成音乐
|
| 460 |
+
- 从提示创建伴奏
|
| 461 |
+
- 生成带歌词的歌曲
|
| 462 |
+
|
| 463 |
+
---
|
| 464 |
+
|
| 465 |
+
### 2. Cover
|
| 466 |
+
|
| 467 |
+
**目的**:转换现有音频,保持结构但改变风格/音色。
|
| 468 |
+
|
| 469 |
+
**关键参数**:
|
| 470 |
+
```python
|
| 471 |
+
params = GenerationParams(
|
| 472 |
+
task_type="cover",
|
| 473 |
+
src_audio="original_song.mp3",
|
| 474 |
+
caption="爵士钢琴版本",
|
| 475 |
+
audio_cover_strength=0.8, # 0.0-1.0
|
| 476 |
+
)
|
| 477 |
+
```
|
| 478 |
+
|
| 479 |
+
**必需**:
|
| 480 |
+
- `src_audio`:源音频文件路径
|
| 481 |
+
- `caption`:期望风格/转换的描述
|
| 482 |
+
|
| 483 |
+
**可选**:
|
| 484 |
+
- `audio_cover_strength`:控制原始音频的影响
|
| 485 |
+
- `1.0`:强烈保持原始结构
|
| 486 |
+
- `0.5`:平衡转换
|
| 487 |
+
- `0.1`:宽松解读
|
| 488 |
+
- `lyrics`:新歌词(如果要更改人声)
|
| 489 |
+
|
| 490 |
+
**用例**:
|
| 491 |
+
- 创建不同风格的翻唱
|
| 492 |
+
- 在保持旋律的同时更改乐器
|
| 493 |
+
- 风格转换
|
| 494 |
+
|
| 495 |
+
---
|
| 496 |
+
|
| 497 |
+
### 3. Repaint
|
| 498 |
+
|
| 499 |
+
**目的**:重新生成音频的特定时间段,保持其余部分不变。
|
| 500 |
+
|
| 501 |
+
**关键参数**:
|
| 502 |
+
```python
|
| 503 |
+
params = GenerationParams(
|
| 504 |
+
task_type="repaint",
|
| 505 |
+
src_audio="original.mp3",
|
| 506 |
+
repainting_start=10.0, # 秒
|
| 507 |
+
repainting_end=20.0, # 秒
|
| 508 |
+
caption="带钢琴独奏的平滑过渡",
|
| 509 |
+
)
|
| 510 |
+
```
|
| 511 |
+
|
| 512 |
+
**必需**:
|
| 513 |
+
- `src_audio`:源音频文件路径
|
| 514 |
+
- `repainting_start`:开始时间(秒)
|
| 515 |
+
- `repainting_end`:结束时间(秒)(使用 `-1` 表示文件末尾)
|
| 516 |
+
- `caption`:重绘部分期望内容的描述
|
| 517 |
+
|
| 518 |
+
**用例**:
|
| 519 |
+
- 修复生成音乐的特定部分
|
| 520 |
+
- 为歌曲的某些部分添加变化
|
| 521 |
+
- 创建平滑过渡
|
| 522 |
+
- 替换有问题的片段
|
| 523 |
+
|
| 524 |
+
---
|
| 525 |
+
|
| 526 |
+
### 4. Lego(仅 Base 模型)
|
| 527 |
+
|
| 528 |
+
**目的**:在现有音频的上下文中生成特定乐器轨道。
|
| 529 |
+
|
| 530 |
+
**关键参数**:
|
| 531 |
+
```python
|
| 532 |
+
params = GenerationParams(
|
| 533 |
+
task_type="lego",
|
| 534 |
+
src_audio="backing_track.mp3",
|
| 535 |
+
instruction="Generate the guitar track based on the audio context:",
|
| 536 |
+
caption="带有蓝调感觉的主音吉他旋律",
|
| 537 |
+
repainting_start=0.0,
|
| 538 |
+
repainting_end=-1,
|
| 539 |
+
)
|
| 540 |
+
```
|
| 541 |
+
|
| 542 |
+
**必需**:
|
| 543 |
+
- `src_audio`:源/伴奏音频路径
|
| 544 |
+
- `instruction`:必须指定轨道类型(例如"Generate the {TRACK_NAME} track...")
|
| 545 |
+
- `caption`:期望轨道特征的描述
|
| 546 |
+
|
| 547 |
+
**可用轨道**:
|
| 548 |
+
- `"vocals"`、`"backing_vocals"`、`"drums"`、`"bass"`、`"guitar"`、`"keyboard"`、
|
| 549 |
+
- `"percussion"`、`"strings"`、`"synth"`、`"fx"`、`"brass"`、`"woodwinds"`
|
| 550 |
+
|
| 551 |
+
**用例**:
|
| 552 |
+
- 添加特定乐器轨道
|
| 553 |
+
- 在伴奏轨道上叠加额外乐器
|
| 554 |
+
- 迭代创建多轨作品
|
| 555 |
+
|
| 556 |
+
---
|
| 557 |
+
|
| 558 |
+
### 5. Extract(仅 Base 模型)
|
| 559 |
+
|
| 560 |
+
**目的**:从混音音频中提取/分离特定乐器轨道。
|
| 561 |
+
|
| 562 |
+
**关键参数**:
|
| 563 |
+
```python
|
| 564 |
+
params = GenerationParams(
|
| 565 |
+
task_type="extract",
|
| 566 |
+
src_audio="full_mix.mp3",
|
| 567 |
+
instruction="Extract the vocals track from the audio:",
|
| 568 |
+
)
|
| 569 |
+
```
|
| 570 |
+
|
| 571 |
+
**必需**:
|
| 572 |
+
- `src_audio`:混音音频文件路径
|
| 573 |
+
- `instruction`:必须指定要提取的轨道
|
| 574 |
+
|
| 575 |
+
**可用轨道**:与 Lego 任务相同
|
| 576 |
+
|
| 577 |
+
**用例**:
|
| 578 |
+
- 音轨分离
|
| 579 |
+
- 分离特定乐器
|
| 580 |
+
- 创建混音
|
| 581 |
+
- 分析单独轨道
|
| 582 |
+
|
| 583 |
+
---
|
| 584 |
+
|
| 585 |
+
### 6. Complete(仅 Base 模型)
|
| 586 |
+
|
| 587 |
+
**目的**:用指定的乐器完成/扩展部分轨道。
|
| 588 |
+
|
| 589 |
+
**关键参数**:
|
| 590 |
+
```python
|
| 591 |
+
params = GenerationParams(
|
| 592 |
+
task_type="complete",
|
| 593 |
+
src_audio="incomplete_track.mp3",
|
| 594 |
+
instruction="Complete the input track with drums, bass, guitar:",
|
| 595 |
+
caption="摇滚风格完成",
|
| 596 |
+
)
|
| 597 |
+
```
|
| 598 |
+
|
| 599 |
+
**必需**:
|
| 600 |
+
- `src_audio`:不完整/部分轨道的路径
|
| 601 |
+
- `instruction`:必须指定要添加的轨道
|
| 602 |
+
- `caption`:期望风格的描述
|
| 603 |
+
|
| 604 |
+
**用例**:
|
| 605 |
+
- 编排不完整的作品
|
| 606 |
+
- 添加伴奏轨道
|
| 607 |
+
- 自动完成音乐想法
|
| 608 |
+
|
| 609 |
+
---
|
| 610 |
+
|
| 611 |
+
## 辅助函数
|
| 612 |
+
|
| 613 |
+
### understand_music
|
| 614 |
+
|
| 615 |
+
分析音频代码以提取音乐元数据。
|
| 616 |
+
|
| 617 |
+
```python
|
| 618 |
+
from acestep.inference import understand_music
|
| 619 |
+
|
| 620 |
+
result = understand_music(
|
| 621 |
+
llm_handler=llm_handler,
|
| 622 |
+
audio_codes="<|audio_code_123|><|audio_code_456|>...",
|
| 623 |
+
temperature=0.85,
|
| 624 |
+
use_constrained_decoding=True,
|
| 625 |
+
)
|
| 626 |
+
|
| 627 |
+
if result.success:
|
| 628 |
+
print(f"Caption:{result.caption}")
|
| 629 |
+
print(f"歌词:{result.lyrics}")
|
| 630 |
+
print(f"BPM:{result.bpm}")
|
| 631 |
+
print(f"调性:{result.keyscale}")
|
| 632 |
+
print(f"时长:{result.duration}s")
|
| 633 |
+
print(f"语言:{result.language}")
|
| 634 |
+
else:
|
| 635 |
+
print(f"错误:{result.error}")
|
| 636 |
+
```
|
| 637 |
+
|
| 638 |
+
**用例**:
|
| 639 |
+
- 分析现有音乐
|
| 640 |
+
- 从音频代码提取元数据
|
| 641 |
+
- 逆向工程生成参数
|
| 642 |
+
|
| 643 |
+
---
|
| 644 |
+
|
| 645 |
+
### create_sample
|
| 646 |
+
|
| 647 |
+
从自然语言描述生成完整的音乐样本。这是"简单模式"/"灵感模式"功能。
|
| 648 |
+
|
| 649 |
+
```python
|
| 650 |
+
from acestep.inference import create_sample
|
| 651 |
+
|
| 652 |
+
result = create_sample(
|
| 653 |
+
llm_handler=llm_handler,
|
| 654 |
+
query="一首适合安静夜晚的柔和孟加拉情歌",
|
| 655 |
+
instrumental=False,
|
| 656 |
+
vocal_language="bn", # 可选:限制为孟加拉语
|
| 657 |
+
temperature=0.85,
|
| 658 |
+
)
|
| 659 |
+
|
| 660 |
+
if result.success:
|
| 661 |
+
print(f"Caption:{result.caption}")
|
| 662 |
+
print(f"歌词:{result.lyrics}")
|
| 663 |
+
print(f"BPM:{result.bpm}")
|
| 664 |
+
print(f"时长:{result.duration}s")
|
| 665 |
+
print(f"调性:{result.keyscale}")
|
| 666 |
+
print(f"是否纯音乐:{result.instrumental}")
|
| 667 |
+
|
| 668 |
+
# 与 generate_music 一起使用
|
| 669 |
+
params = GenerationParams(
|
| 670 |
+
caption=result.caption,
|
| 671 |
+
lyrics=result.lyrics,
|
| 672 |
+
bpm=result.bpm,
|
| 673 |
+
duration=result.duration,
|
| 674 |
+
keyscale=result.keyscale,
|
| 675 |
+
vocal_language=result.language,
|
| 676 |
+
)
|
| 677 |
+
else:
|
| 678 |
+
print(f"错误:{result.error}")
|
| 679 |
+
```
|
| 680 |
+
|
| 681 |
+
**参数**:
|
| 682 |
+
|
| 683 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 684 |
+
|-----------|------|---------|-------------|
|
| 685 |
+
| `query` | `str` | 必需 | 期望音乐的自然语言描述 |
|
| 686 |
+
| `instrumental` | `bool` | `False` | 是否生成纯音乐 |
|
| 687 |
+
| `vocal_language` | `Optional[str]` | `None` | 将歌词限制为特定语言(例如"en"、"zh"、"bn")|
|
| 688 |
+
| `temperature` | `float` | `0.85` | 采样温度 |
|
| 689 |
+
| `top_k` | `Optional[int]` | `None` | Top-k 采样(None 禁用)|
|
| 690 |
+
| `top_p` | `Optional[float]` | `None` | Top-p 采样(None 禁用)|
|
| 691 |
+
| `repetition_penalty` | `float` | `1.0` | 重复惩罚 |
|
| 692 |
+
| `use_constrained_decoding` | `bool` | `True` | 使用基于 FSM 的约束解码 |
|
| 693 |
+
|
| 694 |
+
---
|
| 695 |
+
|
| 696 |
+
### format_sample
|
| 697 |
+
|
| 698 |
+
格式化和增强用户提供的 caption 和 lyrics,生成结构化元数据。
|
| 699 |
+
|
| 700 |
+
```python
|
| 701 |
+
from acestep.inference import format_sample
|
| 702 |
+
|
| 703 |
+
result = format_sample(
|
| 704 |
+
llm_handler=llm_handler,
|
| 705 |
+
caption="拉丁流行,雷鬼音",
|
| 706 |
+
lyrics="[Verse 1]\nBailando en la noche...",
|
| 707 |
+
user_metadata={"bpm": 95}, # 可选:约束特定值
|
| 708 |
+
temperature=0.85,
|
| 709 |
+
)
|
| 710 |
+
|
| 711 |
+
if result.success:
|
| 712 |
+
print(f"增强后的 Caption:{result.caption}")
|
| 713 |
+
print(f"格式化后的歌词:{result.lyrics}")
|
| 714 |
+
print(f"BPM:{result.bpm}")
|
| 715 |
+
print(f"时长:{result.duration}s")
|
| 716 |
+
print(f"调性:{result.keyscale}")
|
| 717 |
+
print(f"检测到的语言:{result.language}")
|
| 718 |
+
else:
|
| 719 |
+
print(f"错误:{result.error}")
|
| 720 |
+
```
|
| 721 |
+
|
| 722 |
+
**参数**:
|
| 723 |
+
|
| 724 |
+
| 参数 | 类型 | 默认值 | 说明 |
|
| 725 |
+
|-----------|------|---------|-------------|
|
| 726 |
+
| `caption` | `str` | 必需 | 用户的 caption/描述 |
|
| 727 |
+
| `lyrics` | `str` | 必需 | 用户的带结构标签的歌词 |
|
| 728 |
+
| `user_metadata` | `Optional[Dict]` | `None` | 约束特定元数据值(bpm、duration、keyscale、timesignature、language)|
|
| 729 |
+
| `temperature` | `float` | `0.85` | 采样温度 |
|
| 730 |
+
| `top_k` | `Optional[int]` | `None` | Top-k 采样(None 禁用)|
|
| 731 |
+
| `top_p` | `Optional[float]` | `None` | Top-p 采样(None 禁用)|
|
| 732 |
+
| `repetition_penalty` | `float` | `1.0` | 重复惩罚 |
|
| 733 |
+
| `use_constrained_decoding` | `bool` | `True` | 使用基于 FSM 的约束解码 |
|
| 734 |
+
|
| 735 |
+
---
|
| 736 |
+
|
| 737 |
+
## 完整示例
|
| 738 |
+
|
| 739 |
+
### 示例 1:简单文本到音乐生成
|
| 740 |
+
|
| 741 |
+
```python
|
| 742 |
+
from acestep.inference import GenerationParams, GenerationConfig, generate_music
|
| 743 |
+
|
| 744 |
+
params = GenerationParams(
|
| 745 |
+
task_type="text2music",
|
| 746 |
+
caption="宁静的氛围音乐,柔和的钢琴和弦乐",
|
| 747 |
+
duration=60,
|
| 748 |
+
bpm=80,
|
| 749 |
+
keyscale="C Major",
|
| 750 |
+
)
|
| 751 |
+
|
| 752 |
+
config = GenerationConfig(
|
| 753 |
+
batch_size=2, # 生成 2 个变体
|
| 754 |
+
audio_format="flac",
|
| 755 |
+
)
|
| 756 |
+
|
| 757 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 758 |
+
|
| 759 |
+
if result.success:
|
| 760 |
+
for i, audio in enumerate(result.audios, 1):
|
| 761 |
+
print(f"变体 {i}:{audio['path']}")
|
| 762 |
+
```
|
| 763 |
+
|
| 764 |
+
### 示例 2:带歌词的歌曲生成
|
| 765 |
+
|
| 766 |
+
```python
|
| 767 |
+
params = GenerationParams(
|
| 768 |
+
task_type="text2music",
|
| 769 |
+
caption="流行民谣,情感人声",
|
| 770 |
+
lyrics="""Verse 1:
|
| 771 |
+
今天走在街上
|
| 772 |
+
想着你曾说过的话
|
| 773 |
+
一切都变得不同了
|
| 774 |
+
但我会找到自己的路
|
| 775 |
+
|
| 776 |
+
Chorus:
|
| 777 |
+
我在前进,我很坚强
|
| 778 |
+
这就是我属于的地方
|
| 779 |
+
""",
|
| 780 |
+
vocal_language="zh",
|
| 781 |
+
bpm=72,
|
| 782 |
+
duration=45,
|
| 783 |
+
)
|
| 784 |
+
|
| 785 |
+
config = GenerationConfig(batch_size=1)
|
| 786 |
+
|
| 787 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 788 |
+
```
|
| 789 |
+
|
| 790 |
+
### 示例 3:使用自定义时间步
|
| 791 |
+
|
| 792 |
+
```python
|
| 793 |
+
params = GenerationParams(
|
| 794 |
+
task_type="text2music",
|
| 795 |
+
caption="复杂和声的爵士融合",
|
| 796 |
+
# 自定义 9 步调度
|
| 797 |
+
timesteps=[0.97, 0.76, 0.615, 0.5, 0.395, 0.28, 0.18, 0.085, 0],
|
| 798 |
+
thinking=True,
|
| 799 |
+
)
|
| 800 |
+
|
| 801 |
+
config = GenerationConfig(batch_size=1)
|
| 802 |
+
|
| 803 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 804 |
+
```
|
| 805 |
+
|
| 806 |
+
### 示例 4:使用 Shift 参数(Turbo 模型)
|
| 807 |
+
|
| 808 |
+
```python
|
| 809 |
+
params = GenerationParams(
|
| 810 |
+
task_type="text2music",
|
| 811 |
+
caption="欢快的电子舞曲",
|
| 812 |
+
inference_steps=8,
|
| 813 |
+
shift=3.0, # Turbo 模型推荐
|
| 814 |
+
infer_method="ode",
|
| 815 |
+
)
|
| 816 |
+
|
| 817 |
+
config = GenerationConfig(batch_size=2)
|
| 818 |
+
|
| 819 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 820 |
+
```
|
| 821 |
+
|
| 822 |
+
### 示例 5:使用 create_sample 的简单模式
|
| 823 |
+
|
| 824 |
+
```python
|
| 825 |
+
from acestep.inference import create_sample, GenerationParams, GenerationConfig, generate_music
|
| 826 |
+
|
| 827 |
+
# 步骤 1:从描述创建样本
|
| 828 |
+
sample = create_sample(
|
| 829 |
+
llm_handler=llm_handler,
|
| 830 |
+
query="充满活力的韩国流行舞曲,带有朗朗上口的 Hook",
|
| 831 |
+
vocal_language="ko",
|
| 832 |
+
)
|
| 833 |
+
|
| 834 |
+
if sample.success:
|
| 835 |
+
# 步骤 2:使用样本生成音乐
|
| 836 |
+
params = GenerationParams(
|
| 837 |
+
caption=sample.caption,
|
| 838 |
+
lyrics=sample.lyrics,
|
| 839 |
+
bpm=sample.bpm,
|
| 840 |
+
duration=sample.duration,
|
| 841 |
+
keyscale=sample.keyscale,
|
| 842 |
+
vocal_language=sample.language,
|
| 843 |
+
thinking=True,
|
| 844 |
+
)
|
| 845 |
+
|
| 846 |
+
config = GenerationConfig(batch_size=2)
|
| 847 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 848 |
+
```
|
| 849 |
+
|
| 850 |
+
### 示例 6:格式化和增强用户输入
|
| 851 |
+
|
| 852 |
+
```python
|
| 853 |
+
from acestep.inference import format_sample, GenerationParams, GenerationConfig, generate_music
|
| 854 |
+
|
| 855 |
+
# 步骤 1:格式化用户输入
|
| 856 |
+
formatted = format_sample(
|
| 857 |
+
llm_handler=llm_handler,
|
| 858 |
+
caption="摇滚民谣",
|
| 859 |
+
lyrics="[Verse]\n在黑暗中我找到了自己的路...",
|
| 860 |
+
)
|
| 861 |
+
|
| 862 |
+
if formatted.success:
|
| 863 |
+
# 步骤 2:使用增强后的输入生成
|
| 864 |
+
params = GenerationParams(
|
| 865 |
+
caption=formatted.caption,
|
| 866 |
+
lyrics=formatted.lyrics,
|
| 867 |
+
bpm=formatted.bpm,
|
| 868 |
+
duration=formatted.duration,
|
| 869 |
+
keyscale=formatted.keyscale,
|
| 870 |
+
thinking=True,
|
| 871 |
+
use_cot_metas=False, # 已格式化,跳过元数据 CoT
|
| 872 |
+
)
|
| 873 |
+
|
| 874 |
+
config = GenerationConfig(batch_size=2)
|
| 875 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 876 |
+
```
|
| 877 |
+
|
| 878 |
+
---
|
| 879 |
+
|
| 880 |
+
## 最佳实践
|
| 881 |
+
|
| 882 |
+
### 1. Caption 写作
|
| 883 |
+
|
| 884 |
+
**好的 Caption**:
|
| 885 |
+
```python
|
| 886 |
+
# 具体且描述性强
|
| 887 |
+
caption="欢快的电子舞曲,重低音和合成器主旋律"
|
| 888 |
+
|
| 889 |
+
# 包含情绪和风格
|
| 890 |
+
caption="忧郁的独立民谣,原声吉他和柔和的人声"
|
| 891 |
+
|
| 892 |
+
# 指定乐器
|
| 893 |
+
caption="爵士三重奏,钢琴、立式贝斯和刷子鼓"
|
| 894 |
+
```
|
| 895 |
+
|
| 896 |
+
**避免**:
|
| 897 |
+
```python
|
| 898 |
+
# 太模糊
|
| 899 |
+
caption="好音乐"
|
| 900 |
+
|
| 901 |
+
# 矛盾
|
| 902 |
+
caption="快慢音乐" # 节奏冲突
|
| 903 |
+
```
|
| 904 |
+
|
| 905 |
+
### 2. 参数调优
|
| 906 |
+
|
| 907 |
+
**最佳质量**:
|
| 908 |
+
- 使用 base 模型,`inference_steps=64` 或更高
|
| 909 |
+
- 启用 `use_adg=True`
|
| 910 |
+
- 设置 `guidance_scale=7.0-9.0`
|
| 911 |
+
- 设置 `shift=3.0` 以获得更好的时间步分布
|
| 912 |
+
- 使用无损音频格式(`audio_format="wav"`)
|
| 913 |
+
|
| 914 |
+
**追求速度**:
|
| 915 |
+
- 使用 turbo 模型,`inference_steps=8`
|
| 916 |
+
- 禁用 ADG(`use_adg=False`)
|
| 917 |
+
- 使用 `infer_method="ode"`(默认)
|
| 918 |
+
- 使用压缩格式(`audio_format="mp3"`)或默认 FLAC
|
| 919 |
+
|
| 920 |
+
**一致性**:
|
| 921 |
+
- 在 config 中设置 `use_random_seed=False`
|
| 922 |
+
- 使用固定的 `seeds` 列表或在 params 中使用单个 `seed`
|
| 923 |
+
- 保持较低的 `lm_temperature`(0.7-0.85)
|
| 924 |
+
|
| 925 |
+
**多样性**:
|
| 926 |
+
- 在 config 中设置 `use_random_seed=True`
|
| 927 |
+
- 增加 `lm_temperature`(0.9-1.1)
|
| 928 |
+
- 使用 `batch_size > 1` 获得变体
|
| 929 |
+
|
| 930 |
+
### 3. 时长指南
|
| 931 |
+
|
| 932 |
+
- **纯音乐**:30-180 秒效果良好
|
| 933 |
+
- **带歌词**:推荐自动检测(设置 `duration=-1` 或保持默认)
|
| 934 |
+
- **短片段**:最少 10-20 秒
|
| 935 |
+
- **长格式**:最多 600 秒(10 分钟)
|
| 936 |
+
|
| 937 |
+
### 4. LM 使用
|
| 938 |
+
|
| 939 |
+
**何时启用 LM(`thinking=True`)**:
|
| 940 |
+
- 需要自动元数据检测
|
| 941 |
+
- 想要 caption 优化
|
| 942 |
+
- 从最少输入生成
|
| 943 |
+
- 需要多样化输出
|
| 944 |
+
|
| 945 |
+
**何时禁用 LM(`thinking=False`)**:
|
| 946 |
+
- 已有精确的元数据
|
| 947 |
+
- 需要更快的生成
|
| 948 |
+
- 想要完全控制参数
|
| 949 |
+
|
| 950 |
+
### 5. 批处理
|
| 951 |
+
|
| 952 |
+
```python
|
| 953 |
+
# 高效批量生成
|
| 954 |
+
config = GenerationConfig(
|
| 955 |
+
batch_size=8, # 支持的最大值
|
| 956 |
+
allow_lm_batch=True, # 启用以提速(当 thinking=True 时)
|
| 957 |
+
lm_batch_chunk_size=4, # 根据 GPU 内存调整
|
| 958 |
+
)
|
| 959 |
+
```
|
| 960 |
+
|
| 961 |
+
### 6. 错误处理
|
| 962 |
+
|
| 963 |
+
```python
|
| 964 |
+
result = generate_music(dit_handler, llm_handler, params, config, save_dir="/output")
|
| 965 |
+
|
| 966 |
+
if not result.success:
|
| 967 |
+
print(f"生成失败:{result.error}")
|
| 968 |
+
print(f"状态:{result.status_message}")
|
| 969 |
+
else:
|
| 970 |
+
# 处理成功结果
|
| 971 |
+
for audio in result.audios:
|
| 972 |
+
path = audio['path']
|
| 973 |
+
key = audio['key']
|
| 974 |
+
seed = audio['params']['seed']
|
| 975 |
+
# ... 处理音频文件
|
| 976 |
+
```
|
| 977 |
+
|
| 978 |
+
### 7. 内存管理
|
| 979 |
+
|
| 980 |
+
对于大批量大小或长时长:
|
| 981 |
+
- 监控 GPU 内存使用
|
| 982 |
+
- 如果出现 OOM 错误,减少 `batch_size`
|
| 983 |
+
- 减少 `lm_batch_chunk_size` 用于 LM 操作
|
| 984 |
+
- 考虑在初始化期间使用 `offload_to_cpu=True`
|
| 985 |
+
|
| 986 |
+
---
|
| 987 |
+
|
| 988 |
+
## 故障排除
|
| 989 |
+
|
| 990 |
+
### 常见问题
|
| 991 |
+
|
| 992 |
+
**问题**:内存不足错误
|
| 993 |
+
- **解决方案**:减少 `batch_size`、`inference_steps`,或启用 CPU 卸载
|
| 994 |
+
|
| 995 |
+
**问题**:结果质量差
|
| 996 |
+
- **解决方案**:增加 `inference_steps`,调整 `guidance_scale`,使用 base 模型
|
| 997 |
+
|
| 998 |
+
**问题**:结果与提示不匹配
|
| 999 |
+
- **解决方案**:使 caption 更具体,增加 `guidance_scale`,启用 LM 优化(`thinking=True`)
|
| 1000 |
+
|
| 1001 |
+
**问题**:生成缓慢
|
| 1002 |
+
- **解决方案**:使用 turbo 模型,减少 `inference_steps`,禁用 ADG
|
| 1003 |
+
|
| 1004 |
+
**问题**:LM 不生成代码
|
| 1005 |
+
- **解决方案**:验证 `llm_handler` 已初始化,检查 `thinking=True` 和 `use_cot_metas=True`
|
| 1006 |
+
|
| 1007 |
+
**问题**:种子不被尊重
|
| 1008 |
+
- **解决方案**:在 config 中设置 `use_random_seed=False` 并提供 `seeds` 列表或在 params 中提供 `seed`
|
| 1009 |
+
|
| 1010 |
+
**问题**:自定义时间步不工作
|
| 1011 |
+
- **解决方案**:确保时间步是从 1.0 到 0.0 的浮点数列表,正确排序
|
| 1012 |
+
|
| 1013 |
+
---
|
| 1014 |
+
|
| 1015 |
+
## 版本历史
|
| 1016 |
+
|
| 1017 |
+
- **v1.5.2**:当前版本
|
| 1018 |
+
- 添加了 `shift` 参数用于时间步偏移
|
| 1019 |
+
- 添加了 `infer_method` 参数用于 ODE/SDE 选择
|
| 1020 |
+
- 添加了 `timesteps` 参数用于自定义时间步调度
|
| 1021 |
+
- 添加了 `understand_music()` 函数用于音频分析
|
| 1022 |
+
- 添加了 `create_sample()` 函数用于简单模式生成
|
| 1023 |
+
- 添加了 `format_sample()` 函数用于输入增强
|
| 1024 |
+
- 添加了 `UnderstandResult`、`CreateSampleResult`、`FormatSampleResult` 数据类
|
| 1025 |
+
|
| 1026 |
+
- **v1.5.1**:上一版本
|
| 1027 |
+
- 将 `GenerationConfig` 拆分为 `GenerationParams` 和 `GenerationConfig`
|
| 1028 |
+
- 重命名参数以保持一致性(`key_scale` → `keyscale`、`time_signature` → `timesignature`、`audio_duration` → `duration`、`use_llm_thinking` → `thinking`、`audio_code_string` → `audio_codes`)
|
| 1029 |
+
- 添加了 `instrumental` 参数
|
| 1030 |
+
- 添加了 `use_constrained_decoding` 参数
|
| 1031 |
+
- 添加了 CoT 自动填充字段(`cot_*`)
|
| 1032 |
+
- 将默认 `audio_format` 更改为 "flac"
|
| 1033 |
+
- 将默认 `batch_size` 更改为 2
|
| 1034 |
+
- 将默认 `thinking` 更改为 True
|
| 1035 |
+
- 简化了 `GenerationResult` 结构,统一 `audios` 列表
|
| 1036 |
+
- 在 `extra_outputs` 中添加了统一的 `time_costs`
|
| 1037 |
+
|
| 1038 |
+
- **v1.5**:初始版本
|
| 1039 |
+
- 引入了 `GenerationConfig` 和 `GenerationResult` 数据类
|
| 1040 |
+
- 简化了参数传递
|
| 1041 |
+
- 添加了综合文档
|
| 1042 |
+
|
| 1043 |
+
---
|
| 1044 |
+
|
| 1045 |
+
更多信息,请参阅:
|
| 1046 |
+
- 主 README:[`../../README.md`](../../README.md)
|
| 1047 |
+
- REST API 文档:[`API.md`](API.md)
|
| 1048 |
+
- Gradio 演示指南:[`GRADIO_GUIDE.md`](GRADIO_GUIDE.md)
|
| 1049 |
+
- 项目仓库:[ACE-Step-1.5](https://github.com/yourusername/ACE-Step-1.5)
|