Spaces:
Running
on
Zero
Running
on
Zero
Merge branch 'dev' into main
Browse files- acestep/api_server.py +17 -9
acestep/api_server.py
CHANGED
|
@@ -102,9 +102,13 @@ class GenerateMusicRequest(BaseModel):
|
|
| 102 |
cfg_interval_start: float = 0.0
|
| 103 |
cfg_interval_end: float = 1.0
|
| 104 |
infer_method: str = "ode" # "ode" or "sde" - diffusion inference method
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
timesteps: Optional[str] = Field(
|
| 106 |
default=None,
|
| 107 |
-
description="Custom timesteps (comma-separated, e.g., '0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0')"
|
| 108 |
)
|
| 109 |
|
| 110 |
audio_format: str = "mp3"
|
|
@@ -748,6 +752,15 @@ def create_app() -> FastAPI:
|
|
| 748 |
print(f"[api_server] Warning: format_sample failed: {format_result.error}, using original input")
|
| 749 |
|
| 750 |
print(f"[api_server] Before GenerationParams: thinking={thinking}, sample_mode={sample_mode}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
print(f"[api_server] Caption/Lyrics to use: caption_len={len(caption)}, lyrics_len={len(lyrics)}")
|
| 752 |
|
| 753 |
# Build GenerationParams using unified interface
|
|
@@ -766,12 +779,13 @@ def create_app() -> FastAPI:
|
|
| 766 |
keyscale=key_scale,
|
| 767 |
timesignature=time_signature,
|
| 768 |
duration=audio_duration if audio_duration else -1.0,
|
| 769 |
-
inference_steps=
|
| 770 |
seed=req.seed,
|
| 771 |
guidance_scale=req.guidance_scale,
|
| 772 |
use_adg=req.use_adg,
|
| 773 |
cfg_interval_start=req.cfg_interval_start,
|
| 774 |
cfg_interval_end=req.cfg_interval_end,
|
|
|
|
| 775 |
infer_method=req.infer_method,
|
| 776 |
timesteps=parsed_timesteps,
|
| 777 |
repainting_start=req.repainting_start,
|
|
@@ -1049,6 +1063,7 @@ def create_app() -> FastAPI:
|
|
| 1049 |
cfg_interval_start=_to_float(get("cfg_interval_start"), 0.0) or 0.0,
|
| 1050 |
cfg_interval_end=_to_float(get("cfg_interval_end"), 1.0) or 1.0,
|
| 1051 |
infer_method=str(_get_any("infer_method", "inferMethod", default="ode") or "ode"),
|
|
|
|
| 1052 |
audio_format=str(get("audio_format", "mp3") or "mp3"),
|
| 1053 |
use_tiled_decode=_to_bool(_get_any("use_tiled_decode", "useTiledDecode"), True),
|
| 1054 |
lm_model_path=str(get("lm_model_path") or "").strip() or None,
|
|
@@ -1301,12 +1316,5 @@ def main() -> None:
|
|
| 1301 |
workers=1,
|
| 1302 |
)
|
| 1303 |
|
| 1304 |
-
|
| 1305 |
-
if __name__ == "__main__":
|
| 1306 |
-
main()
|
| 1307 |
-
,
|
| 1308 |
-
)
|
| 1309 |
-
|
| 1310 |
-
|
| 1311 |
if __name__ == "__main__":
|
| 1312 |
main()
|
|
|
|
| 102 |
cfg_interval_start: float = 0.0
|
| 103 |
cfg_interval_end: float = 1.0
|
| 104 |
infer_method: str = "ode" # "ode" or "sde" - diffusion inference method
|
| 105 |
+
shift: float = Field(
|
| 106 |
+
default=3.0,
|
| 107 |
+
description="Timestep shift factor (range 1.0~5.0, default 3.0). Only effective for base models, not turbo models."
|
| 108 |
+
)
|
| 109 |
timesteps: Optional[str] = Field(
|
| 110 |
default=None,
|
| 111 |
+
description="Custom timesteps (comma-separated, e.g., '0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0'). Overrides inference_steps and shift."
|
| 112 |
)
|
| 113 |
|
| 114 |
audio_format: str = "mp3"
|
|
|
|
| 752 |
print(f"[api_server] Warning: format_sample failed: {format_result.error}, using original input")
|
| 753 |
|
| 754 |
print(f"[api_server] Before GenerationParams: thinking={thinking}, sample_mode={sample_mode}")
|
| 755 |
+
# Parse timesteps string to list of floats if provided
|
| 756 |
+
parsed_timesteps = None
|
| 757 |
+
if req.timesteps and req.timesteps.strip():
|
| 758 |
+
try:
|
| 759 |
+
parsed_timesteps = [float(t.strip()) for t in req.timesteps.split(",") if t.strip()]
|
| 760 |
+
except ValueError:
|
| 761 |
+
print(f"[api_server] Warning: Failed to parse timesteps '{req.timesteps}', using default")
|
| 762 |
+
parsed_timesteps = None
|
| 763 |
+
|
| 764 |
print(f"[api_server] Caption/Lyrics to use: caption_len={len(caption)}, lyrics_len={len(lyrics)}")
|
| 765 |
|
| 766 |
# Build GenerationParams using unified interface
|
|
|
|
| 779 |
keyscale=key_scale,
|
| 780 |
timesignature=time_signature,
|
| 781 |
duration=audio_duration if audio_duration else -1.0,
|
| 782 |
+
inference_steps=req.inference_steps,
|
| 783 |
seed=req.seed,
|
| 784 |
guidance_scale=req.guidance_scale,
|
| 785 |
use_adg=req.use_adg,
|
| 786 |
cfg_interval_start=req.cfg_interval_start,
|
| 787 |
cfg_interval_end=req.cfg_interval_end,
|
| 788 |
+
shift=req.shift,
|
| 789 |
infer_method=req.infer_method,
|
| 790 |
timesteps=parsed_timesteps,
|
| 791 |
repainting_start=req.repainting_start,
|
|
|
|
| 1063 |
cfg_interval_start=_to_float(get("cfg_interval_start"), 0.0) or 0.0,
|
| 1064 |
cfg_interval_end=_to_float(get("cfg_interval_end"), 1.0) or 1.0,
|
| 1065 |
infer_method=str(_get_any("infer_method", "inferMethod", default="ode") or "ode"),
|
| 1066 |
+
shift=_to_float(_get_any("shift"), 3.0) or 3.0,
|
| 1067 |
audio_format=str(get("audio_format", "mp3") or "mp3"),
|
| 1068 |
use_tiled_decode=_to_bool(_get_any("use_tiled_decode", "useTiledDecode"), True),
|
| 1069 |
lm_model_path=str(get("lm_model_path") or "").strip() or None,
|
|
|
|
| 1316 |
workers=1,
|
| 1317 |
)
|
| 1318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1319 |
if __name__ == "__main__":
|
| 1320 |
main()
|