(input_data: ACEStepInput)
| 48 | |
| 49 | @app.post("/generate", response_model=ACEStepOutput) |
| 50 | async def generate_audio(input_data: ACEStepInput): |
| 51 | try: |
| 52 | # Initialize pipeline |
| 53 | model_demo = initialize_pipeline( |
| 54 | input_data.checkpoint_path, |
| 55 | input_data.bf16, |
| 56 | input_data.torch_compile, |
| 57 | input_data.device_id |
| 58 | ) |
| 59 | |
| 60 | # Prepare parameters |
| 61 | params = ( |
| 62 | input_data.audio_duration, |
| 63 | input_data.prompt, |
| 64 | input_data.lyrics, |
| 65 | input_data.infer_step, |
| 66 | input_data.guidance_scale, |
| 67 | input_data.scheduler_type, |
| 68 | input_data.cfg_type, |
| 69 | input_data.omega_scale, |
| 70 | ", ".join(map(str, input_data.actual_seeds)), |
| 71 | input_data.guidance_interval, |
| 72 | input_data.guidance_interval_decay, |
| 73 | input_data.min_guidance_scale, |
| 74 | input_data.use_erg_tag, |
| 75 | input_data.use_erg_lyric, |
| 76 | input_data.use_erg_diffusion, |
| 77 | ", ".join(map(str, input_data.oss_steps)), |
| 78 | input_data.guidance_scale_text, |
| 79 | input_data.guidance_scale_lyric, |
| 80 | ) |
| 81 | |
| 82 | # Generate output path if not provided |
| 83 | output_path = input_data.output_path or f"output_{uuid.uuid4().hex}.wav" |
| 84 | |
| 85 | # Run pipeline |
| 86 | model_demo( |
| 87 | *params, |
| 88 | save_path=output_path |
| 89 | ) |
| 90 | |
| 91 | return ACEStepOutput( |
| 92 | status="success", |
| 93 | output_path=output_path, |
| 94 | message="Audio generated successfully" |
| 95 | ) |
| 96 | |
| 97 | except Exception as e: |
| 98 | raise HTTPException(status_code=500, detail=f"Error generating audio: {str(e)}") |
| 99 | |
| 100 | @app.get("/health") |
| 101 | async def health_check(): |
nothing calls this directly
no test coverage detected