Spaces:
Sleeping
Sleeping
File size: 1,024 Bytes
11330a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #!/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())
|