File size: 2,185 Bytes
3f79c45
 
aeea10c
 
d326c2d
3f79c45
 
 
 
 
 
 
 
 
 
 
 
 
 
aeea10c
 
 
 
 
 
 
3f79c45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aeea10c
 
 
 
3f79c45
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
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Narration for the landing page demo (Nora Vale, Mission Control). Writes public/demo-vo/*.mp3 + durations.json.

The screens show the product; the voice never explains it, it only says how it feels: exploring,
excited, mesmerized. 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": "Captain's log. Something wonderful is on the horizon.",
    "paste": "Take a breath. That flutter of excitement? That's how every great expedition begins.",
    "orbit": "And there it is. Everything you've made, shimmering... impossible to look away.",
    "research": "A question sparks, and suddenly you're wide awake.",
    "audio": "Lean back. Let it wash over you.",
    "launchkit": "Your pulse quickens. You can't wait to share this.",
    "launchpad": "Three, two, one... and you're flying.",
    "outro": "Notestack. Clear skies ahead.",
}

voice_id = next(v["voice_id"] for v in tts.list_voices() if v["name"].startswith("Nora Vale"))
vs = tts.VoiceSettings(stability=0.55, similarity_boost=0.8, style=0.3, speed=0.93)
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))