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

Function summary_json

tests/chatterbox/chatterbox_python_warm_bench.py:75–91  ·  view source on GitHub ↗
(audio: np.ndarray, sample_rate: int, wall_ms: float)

Source from the content-addressed store, hash-verified

73
74
75def summary_json(audio: np.ndarray, sample_rate: int, wall_ms: float) -> str:
76 audio = np.asarray(audio, dtype=np.float32).reshape(-1)
77 count = max(1, int(audio.size))
78 payload = {
79 "family": "chatterbox",
80 "sample_rate": int(sample_rate),
81 "channels": 1,
82 "samples": int(audio.size),
83 "duration_sec": float(audio.size / sample_rate) if sample_rate else 0.0,
84 "sum": float(audio.sum(dtype=np.float64)) if audio.size else 0.0,
85 "mean_abs": float(np.mean(np.abs(audio))) if audio.size else 0.0,
86 "rms": float(np.sqrt(np.sum(audio.astype(np.float64) ** 2) / count)) if audio.size else 0.0,
87 "min": float(audio.min()) if audio.size else 0.0,
88 "max": float(audio.max()) if audio.size else 0.0,
89 "synthesize_wall_ms": float(wall_ms),
90 }
91 return json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
92
93
94def main() -> int:

Callers 1

mainFunction · 0.70

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected