MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / summarize_audio

Function summarize_audio

tests/stable_audio/stable_audio_python_warm_bench.py:274–292  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

272
273
274def summarize_audio(path: Path) -> dict[str, Any]:
275 waveform, sample_rate = torchaudio.load(str(path))
276 if waveform.numel() == 0:
277 raise RuntimeError("Stable Audio warmbench received empty audio")
278 audio = waveform.detach().cpu().numpy().astype(np.float64, copy=False)
279 channels = int(waveform.shape[0])
280 frames = int(waveform.shape[1])
281 return {
282 "sample_rate": int(sample_rate),
283 "channels": channels,
284 "samples": int(waveform.numel()),
285 "frames": frames,
286 "duration_sec": float(frames / sample_rate),
287 "sum": float(np.sum(audio, dtype=np.float64)),
288 "mean_abs": float(np.mean(np.abs(audio), dtype=np.float64)),
289 "rms": float(np.sqrt(np.mean(np.square(audio, dtype=np.float64)))),
290 "min": float(np.min(audio)),
291 "max": float(np.max(audio)),
292 }
293
294
295def load_audio(path: Path) -> tuple[int, torch.Tensor]:

Callers 1

save_batch_audioFunction · 0.70

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected