#!/usr/bin/env python3 """Export the pilot readings plus their quiet atmosphere for listening outside Lumen.""" import json import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[1] PACKAGE = ROOT / 'assets/stories/midnight-invitation' OUT = ROOT / 'artifacts/audio-pilot' OUT.mkdir(parents=True, exist_ok=True) tracks = json.loads((PACKAGE/'audio/narration_manifest.json').read_text())['tracks'] for page, scene, name in [ ('midnight.feather.memory', 'threshold', '01-at-the-door'), ('midnight.candle.entry', 'kitchen', '02-in-the-kitchen'), ]: track = tracks[page] # Same speech-time atmosphere gain as the app's default .7 volume setting. duration = track['durationMs'] / 1000 subprocess.run(['ffmpeg','-v','error','-y','-i',str(ROOT/track['asset']), '-stream_loop','-1','-i',str(PACKAGE/f'audio/ambience_{scene}.wav'), '-filter_complex',f'[1:a]volume=0.07,afade=t=in:d=0.5,afade=t=out:st={duration-.8}:d=0.8[bed];[0:a][bed]amix=inputs=2:duration=first:normalize=0[out]', '-map','[out]','-c:a','pcm_s16le',str(OUT/f'{name}.wav')],check=True) print(OUT/f'{name}.wav')