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

Function write_wav

tests/chatterbox/chatterbox_python_warm_bench.py:63–72  ·  view source on GitHub ↗
(path: Path, sample_rate: int, audio: np.ndarray)

Source from the content-addressed store, hash-verified

61
62
63def write_wav(path: Path, sample_rate: int, audio: np.ndarray) -> None:
64 path.parent.mkdir(parents=True, exist_ok=True)
65 audio = np.asarray(audio, dtype=np.float32).reshape(-1)
66 audio = np.clip(audio, -1.0, 1.0)
67 pcm = (audio * 32767.0).astype(np.int16)
68 with wave.open(str(path), "wb") as handle:
69 handle.setnchannels(1)
70 handle.setsampwidth(2)
71 handle.setframerate(sample_rate)
72 handle.writeframes(pcm.tobytes())
73
74
75def summary_json(audio: np.ndarray, sample_rate: int, wall_ms: float) -> str:

Callers 1

mainFunction · 0.70

Calls 1

openMethod · 0.80

Tested by

no test coverage detected