notepilot / scripts /extract_debug_audio.py
jasonmdong's picture
Sync from GitHub via hub-sync
11330a4 verified
Raw History Blame Contribute Delete
1.02 kB
#!/usr/bin/env python3
"""Extract embedded compressed recordings from one NotePilot debug bundle."""
import base64
import json
import sys
from pathlib import Path
def main() -> int:
if len(sys.argv) != 3:
print('usage: extract_debug_audio.py bundle.json output-directory', file=sys.stderr)
return 2
bundle = json.loads(Path(sys.argv[1]).read_text())
out = Path(sys.argv[2]); out.mkdir(parents=True, exist_ok=True)
audio = bundle.get('audio', {})
count = 0
for key, filename in (('microphone', 'mic.webm'), ('digitalOutput', 'output.webm')):
entry = audio.get(key, {})
encoded = entry.get('base64')
if not encoded:
continue
data = base64.b64decode(encoded, validate=True)
(out / filename).write_bytes(data)
print(out / filename)
count += 1
if not count:
print('no embedded compressed audio found', file=sys.stderr)
return 1
return 0
if __name__ == '__main__':
raise SystemExit(main())