Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/main/voice/gen_wav_arrays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""
Regenerate sit_up_wav.c and thank_you_good_work_wav.c from WAV files.
Run from repo root: python3 src/main/voice/gen_wav_arrays.py
"""
import os

WAV_DIR = os.path.join(os.path.dirname(__file__))

CLIPS = [
("sit_up.wav", "sit_up_wav", "sit_up_wav.c"),
("thank_you_good_work.wav", "thank_you_good_work_wav", "thank_you_good_work_wav.c"),
]

COLS = 16

for wav_file, sym, out_file in CLIPS:
wav_path = os.path.join(WAV_DIR, wav_file)
out_path = os.path.join(WAV_DIR, out_file)

with open(wav_path, "rb") as f:
data = f.read()

lines = ["#include <stdint.h>", "#include <stddef.h>", ""]
lines.append(f"// Auto-generated from voice/{wav_file} — do not edit manually")
lines.append(f"const uint8_t {sym}_data[] = {{")

for i in range(0, len(data), COLS):
chunk = data[i:i + COLS]
hex_vals = ", ".join(f"0x{b:02x}" for b in chunk)
lines.append(f" {hex_vals},")

lines.append("};")
lines.append(f"const uint32_t {sym}_len = {len(data)}u;")
lines.append("")

with open(out_path, "w") as f:
f.write("\n".join(lines))

print(f"wrote {out_file} ({len(data)} bytes from {wav_file})")
Binary file modified src/main/voice/sit_up.wav
Binary file not shown.
Loading