| 50 | |
| 51 | |
| 52 | def summarize_audio(audio: np.ndarray, sample_rate: int) -> dict[str, Any]: |
| 53 | if audio.ndim == 1: |
| 54 | channels = 1 |
| 55 | frames = int(audio.shape[0]) |
| 56 | flat = audio.astype(np.float32, copy=False) |
| 57 | else: |
| 58 | frames = int(audio.shape[0]) |
| 59 | channels = int(audio.shape[1]) |
| 60 | flat = audio.astype(np.float32, copy=False).reshape(-1) |
| 61 | if flat.size == 0: |
| 62 | raise RuntimeError("ACE-Step warmbench summary received empty audio") |
| 63 | return { |
| 64 | "sample_rate": int(sample_rate), |
| 65 | "channels": channels, |
| 66 | "samples": int(flat.size), |
| 67 | "frames": frames, |
| 68 | "sum": float(np.sum(flat, dtype=np.float64)), |
| 69 | "mean_abs": float(np.mean(np.abs(flat), dtype=np.float64)), |
| 70 | "rms": float(np.sqrt(np.mean(np.square(flat), dtype=np.float64))), |
| 71 | "min": float(np.min(flat)), |
| 72 | "max": float(np.max(flat)), |
| 73 | } |
| 74 | |
| 75 | |
| 76 | def load_requests(args: argparse.Namespace) -> list[dict[str, Any]]: |