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

Function audio_summary

tests/miocodec/miocodec_python_warm_bench.py:87–103  ·  view source on GitHub ↗
(audio: np.ndarray, sample_rate: int, wall_ms: float)

Source from the content-addressed store, hash-verified

85
86
87def audio_summary(audio: np.ndarray, sample_rate: int, wall_ms: float) -> dict[str, Any]:
88 flat = np.asarray(audio, dtype=np.float32).reshape(-1)
89 if flat.size == 0:
90 raise RuntimeError("MioCodec warmbench received empty decoded audio")
91 return {
92 "family": "miocodec",
93 "sample_rate": int(sample_rate),
94 "channels": 1,
95 "samples": int(flat.size),
96 "duration_sec": float(flat.size / sample_rate) if sample_rate else 0.0,
97 "sum": float(np.sum(flat, dtype=np.float64)),
98 "mean_abs": float(np.mean(np.abs(flat), dtype=np.float64)),
99 "rms": float(np.sqrt(np.mean(np.square(flat, dtype=np.float64)))),
100 "min": float(np.min(flat)),
101 "max": float(np.max(flat)),
102 "roundtrip_wall_ms": float(wall_ms),
103 }
104
105
106def write_audio(path: Path, audio: np.ndarray, sample_rate: int) -> None:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected