[Test] Add Stable Audio offline e2e TeaCache Test (#2377)

Signed-off-by: Zhang <jianmusings@gmail.com>
Signed-off-by: Zhang Jian <jianmusings@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Zhang JianandClaude Opus 4.6 authored and GitHub committed 2026-04-14 15:05:12 +08:00
1 parent 48c30bc399
commit 17acd0589a
13 files changed
+156 -93

No files matched your search

@@ -23,6 +23,7 @@ python text_to_audio.py \
--guidance-scale 7.0 \
--audio-length 10.0 \
--num-inference-steps 100 \
--cache-backend tea_cache \
--output stable_audio_output.wav
```
@@ -34,4 +35,5 @@ Key arguments:
- `--guidance-scale`: classifier-free guidance scale.
- `--audio-length`: audio duration in seconds.
- `--num-inference-steps`: diffusion sampling steps.(more steps = higher quality, slower).
- `--cache-backend`: cache acceleration backend. Stable Audio currently supports `tea_cache`.
- `--output`: path to save the generated WAV file.
@@ -11,6 +11,7 @@ Usage:
python text_to_audio.py --prompt "The sound of a dog barking"
python text_to_audio.py --prompt "A piano playing a gentle melody" --audio-length 10.0
python text_to_audio.py --prompt "Thunder and rain sounds" --negative-prompt "Low quality"
python text_to_audio.py --prompt "A soft synth pad" --cache-backend tea_cache
"""
import argparse
@@ -90,6 +91,23 @@ def parse_args() -> argparse.Namespace:
default=44100,
help="Sample rate for output audio (Stable Audio uses 44100 Hz).",
)
parser.add_argument(
"--cache-backend",
type=str,
default=None,
choices=["tea_cache"],
help=(
"Cache backend to use for acceleration. "
"Stable Audio currently supports 'tea_cache'. "
"Default: None (no cache acceleration)."
),
)
parser.add_argument(
"--tea-cache-rel-l1-thresh",
type=float,
default=0.2,
help="[tea_cache] Threshold for accumulated relative L1 distance.",
)
parser.add_argument(
"--enable-diffusion-pipeline-profiler",
action="store_true",
@@ -124,6 +142,11 @@ def save_audio(audio_data: np.ndarray, output_path: str, sample_rate: int = 4410
def main():
args = parse_args()
generator = torch.Generator(device=current_omni_platform.device_type).manual_seed(args.seed)
cache_config = None
if args.cache_backend == "tea_cache":
cache_config = {
"rel_l1_thresh": args.tea_cache_rel_l1_thresh,
}
print(f"\n{'=' * 60}")
print("Stable Audio Open - Text-to-Audio Generation")
@@ -134,12 +157,15 @@ def main():
print(f" Audio length: {args.audio_length}s")
print(f" Inference steps: {args.num_inference_steps}")
print(f" Guidance scale: {args.guidance_scale}")
print(f" Cache backend: {args.cache_backend if args.cache_backend else 'None (no acceleration)'}")
print(f" Seed: {args.seed}")
print(f"{'=' * 60}\n")
# Initialize Omni with Stable Audio model
omni = Omni(
model=args.model,
cache_backend=args.cache_backend,
cache_config=cache_config,
enable_diffusion_pipeline_profiler=args.enable_diffusion_pipeline_profiler,
)