33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Export lighthouse-story listening previews with the app's quiet atmosphere."""
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
OUT = ROOT / 'artifacts/mara-qwen/listening'
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
scripts = json.loads((ROOT / 'assets/narration/scripts.json').read_text())
|
|
tracks = json.loads((ROOT / 'assets/audio/narration_manifest.json').read_text())['tracks']
|
|
for page, scene, filename in [
|
|
('cottage.window', 'cottage', '01-by-the-cottage-window.wav'),
|
|
('campaign.8.before', 'tower', '02-at-the-lighthouse.wav'),
|
|
('campaign.10.after', 'tower', '03-the-light-returns.wav'),
|
|
]:
|
|
track = tracks[page]
|
|
assert track['engine'] == 'qwen3-voice-design'
|
|
assert track['text'] == next(r['text'] for r in scripts if r['pageId'] == page)
|
|
duration = track['durationMs'] / 1000
|
|
target = OUT / filename
|
|
subprocess.run([
|
|
'ffmpeg', '-v', 'error', '-y', '-i', str(ROOT / track['asset']),
|
|
'-stream_loop', '-1', '-i', str(ROOT / f'assets/audio/ambience_{scene}.wav'),
|
|
'-filter_complex', f'[1:a]volume=0.07,afade=t=in:d=0.5,'
|
|
f'afade=t=out:st={max(0, duration-.8)}:d=0.8[bed];'
|
|
'[0:a][bed]amix=inputs=2:duration=first:normalize=0[out]',
|
|
'-map', '[out]', '-c:a', 'pcm_s16le', str(target),
|
|
], check=True)
|
|
print(target)
|
|
(ROOT / 'artifacts/mara-qwen/listen.m3u').write_text(
|
|
'#EXTM3U\n' + '\n'.join('pages/' + tracks[r['pageId']]['file'] for r in scripts) + '\n')
|