NoteStack-Test / renderer /scripts /make_demo_vo.py
Arslan1997's picture
adding new demo + landing page improvements
bfe94d3
Raw History Blame Contribute Delete
1.95 kB
"""Narration for the landing page demo (Nora Vale, Mission Control). Writes public/demo-vo/*.mp3 + durations.json.
The screens show the product, one feature at a time; the voice stays sparse and frames the film as a
journey of knowledge and discovery. Also writes src/compositions/demoVo.ts; scenes stretch to fit their lines.
make_demo_music.py writes a 47.5 s score; raise its TOTAL and rerun it if the demo grows past that.
cd backend && PYTHONPATH=. .venv/Scripts/python ../renderer/scripts/make_demo_vo.py
"""
import json
import uuid
from pathlib import Path
from app.services import tts
OUT = Path(__file__).resolve().parents[1] / "public" / "demo-vo"
OUT.mkdir(parents=True, exist_ok=True)
LINES = {
"warp": "Every great journey begins with a single question.",
"sync": "Gather everything you know.",
"map": "Somewhere in all you have written, a whole world is waiting to be discovered.",
"kit": "Knowledge was always meant to travel further.",
"outro": "Notestack. Begin your journey.",
}
voice_id = next(v["voice_id"] for v in tts.list_voices() if v["name"].startswith("Nora Vale"))
vs = tts.VoiceSettings(stability=0.6, similarity_boost=0.8, style=0.2, speed=0.9)
ws = uuid.UUID(int=0)
keys = list(LINES)
durations = {}
for i, key in enumerate(keys):
prev_text = LINES[keys[i - 1]] if i else None
next_text = LINES[keys[i + 1]] if i + 1 < len(keys) else None
clip = tts.synthesize(ws, LINES[key], voice_id, vs, prev_text, next_text)
(OUT / f"{key}.mp3").write_bytes(clip)
durations[key] = round(tts.mp3_seconds(clip), 2)
(OUT / "durations.json").write_text(json.dumps(durations, indent=2))
(Path(__file__).resolve().parents[1] / "src" / "compositions" / "demoVo.ts").write_text(
"// Generated by scripts/make_demo_vo.py: narration clip lengths in seconds. Do not edit by hand.\n"
f"export const DEMO_VO_SECONDS = {json.dumps(durations)} as const;\n"
)
print(json.dumps(durations))