File size: 1,950 Bytes
3f79c45
 
bfe94d3
 
d326c2d
3f79c45
 
 
 
 
 
 
 
 
 
 
 
 
 
bfe94d3
 
 
 
 
3f79c45
 
 
bfe94d3
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
"""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))