explainer-studio 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. explainer_studio-0.1.5.dist-info/METADATA +149 -0
  2. explainer_studio-0.1.5.dist-info/RECORD +37 -0
  3. explainer_studio-0.1.5.dist-info/WHEEL +4 -0
  4. explainer_studio-0.1.5.dist-info/entry_points.txt +2 -0
  5. explainer_studio-0.1.5.dist-info/licenses/LICENSE +41 -0
  6. studio/__init__.py +0 -0
  7. studio/build.py +196 -0
  8. studio/chatterbox_worker.py +96 -0
  9. studio/cli.py +265 -0
  10. studio/common.py +160 -0
  11. studio/data/brand/brand.css +145 -0
  12. studio/data/brand/fonts/JetBrainsMono.ttf +0 -0
  13. studio/data/brand/fonts/OFL-JetBrainsMono.txt +93 -0
  14. studio/data/brand/fonts/OFL-PTSerif.txt +93 -0
  15. studio/data/brand/fonts/OFL-SourceSans3.txt +93 -0
  16. studio/data/brand/fonts/PTSerif-Bold.ttf +0 -0
  17. studio/data/brand/fonts/PTSerif-BoldItalic.ttf +0 -0
  18. studio/data/brand/fonts/PTSerif-Italic.ttf +0 -0
  19. studio/data/brand/fonts/PTSerif-Regular.ttf +0 -0
  20. studio/data/brand/fonts/SourceSans3-Bold.ttf +0 -0
  21. studio/data/brand/fonts/SourceSans3-Italic.ttf +0 -0
  22. studio/data/brand/fonts/SourceSans3.ttf +0 -0
  23. studio/data/brand/frame.md +108 -0
  24. studio/data/brand/pronunciations.yaml +8 -0
  25. studio/data/brand/vendor/gsap.min.js +11 -0
  26. studio/data/templates/scenes/blank.html +46 -0
  27. studio/data/templates/scenes/outro.html +50 -0
  28. studio/data/templates/scenes/points.html +55 -0
  29. studio/data/templates/scenes/quote.html +41 -0
  30. studio/data/templates/scenes/stat.html +57 -0
  31. studio/data/templates/scenes/title.html +46 -0
  32. studio/data/templates/script.md +51 -0
  33. studio/data/templates/thumbnail.html +28 -0
  34. studio/music.py +66 -0
  35. studio/render.py +271 -0
  36. studio/script.py +158 -0
  37. studio/voice.py +633 -0
studio/cli.py ADDED
@@ -0,0 +1,265 @@
1
+ """studio: script -> narration -> HyperFrames scenes -> mastered MP4 + captions + chapters.
2
+
3
+ uv run studio new <slug> "Title" scaffold episodes/<slug>/ with a starter script
4
+ uv run studio status <slug> scenes, word counts, estimated vs actual length
5
+ uv run studio sync <slug> narrate (cached), align, stub scenes, write index.html
6
+ uv run studio preview <slug> open HyperFrames Studio on the episode
7
+ uv run studio check <slug> HyperFrames lint + layout/contrast audits
8
+ uv run studio render <slug> [--draft] render changed scenes, assemble, master -> out/
9
+ uv run studio thumbnail <slug> screenshot thumbnail/thumbnail.html -> out/
10
+ uv run studio voices <slug> audition Kokoro blends or Chatterbox clips on one scene -> out/voice-samples/
11
+ uv run studio music <slug> --prompt generate an instrumental music bed (ElevenLabs Music) sized to the episode
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import html
18
+ import json
19
+ import re
20
+ import shutil
21
+ import subprocess
22
+ import tempfile
23
+ from pathlib import Path
24
+
25
+ import numpy as np
26
+ import soundfile as sf
27
+
28
+ from . import build as builder
29
+ from . import music, voice
30
+ from . import render as renderer
31
+ from .common import EPISODES, OUT, ROOT, TEMPLATES, die, episode_dir, hf, info, require_tools
32
+ from .script import Script, parse
33
+
34
+ AUDITION = [
35
+ "bf_emma*0.6 + bf_isabella*0.4",
36
+ "bf_emma*0.7 + bf_alice*0.3",
37
+ "bf_emma*0.5 + bf_isabella*0.3 + bf_lily*0.2",
38
+ "bf_isabella*0.6 + bf_emma*0.4",
39
+ "bf_emma",
40
+ "bm_george",
41
+ ]
42
+
43
+
44
+ def cmd_new(a):
45
+ slug = a.slug
46
+ if not slug.replace("-", "").isalnum() or slug != slug.lower():
47
+ die("slug must be lowercase letters, digits and hyphens, e.g. paris-commune")
48
+ ep = EPISODES / slug
49
+ if ep.exists():
50
+ die(f"{ep} already exists")
51
+ (ep / "scenes").mkdir(parents=True)
52
+ (ep / "audio" / "recorded").mkdir(parents=True)
53
+ (ep / "assets" / "media").mkdir(parents=True)
54
+ title = a.title or slug.replace("-", " ").title()
55
+ (ep / "script.md").write_text((TEMPLATES / "script.md").read_text().replace("__TITLE__", title))
56
+ builder.ensure_project_files(ep)
57
+ builder.sync_brand(ep)
58
+ info(f"created episodes/{slug}/ - write the script in episodes/{slug}/script.md, then: studio sync {slug}")
59
+
60
+
61
+ def cmd_status(a):
62
+ ep = episode_dir(a.slug)
63
+ script = parse(ep / "script.md")
64
+ timing = json.loads((ep / "timing.json").read_text()) if (ep / "timing.json").exists() else None
65
+ actual = {s["id"]: s for s in timing["scenes"]} if timing else {}
66
+ total_words = 0
67
+ info(f"{script.meta.get('title', a.slug)} voice={script.setting('tts')}:{script.setting('voice')}\n")
68
+ info(f" {'scene':<18}{'template':<10}{'words':>6}{'est s':>8}{'actual s':>10} cues")
69
+ for sc in script.scenes:
70
+ n = len(sc.words)
71
+ total_words += n
72
+ est = n / 2.5 + 1.5 if n else sc.min_duration
73
+ act = actual.get(sc.id, {}).get("duration")
74
+ file_flag = "" if (ep / "scenes" / f"{sc.id}.html").exists() else " (no scene file yet)"
75
+ info(f" {sc.id:<18}{sc.template:<10}{n:>6}{est:>8.1f}{(f'{act:.1f}' if act else '-'):>10} "
76
+ f"{', '.join(sc.cues) or '-'}{file_flag}")
77
+ est_total = total_words / 2.5 + 1.5 * len(script.scenes)
78
+ info(f"\n {total_words} words, estimated {est_total / 60:.1f} min"
79
+ + (f", actual {timing['duration'] / 60:.1f} min ({timing['duration']:.1f}s)" if timing else ", not yet synced"))
80
+
81
+
82
+ def _sync(slug: str, only: set[str] | None = None):
83
+ ep = episode_dir(slug)
84
+ script = parse(ep / "script.md")
85
+ info(f"narration ({script.setting('tts')}:{script.setting('voice')})")
86
+ vo = voice.voice_all(ep, script, only)
87
+ info("building project")
88
+ timing = builder.build(ep, script, vo)
89
+ info(f" {len(timing['scenes'])} scenes, {timing['duration']:.1f}s ({timing['duration'] / 60:.1f} min)")
90
+ return ep, script, timing
91
+
92
+
93
+ def cmd_sync(a):
94
+ _sync(a.slug, set(a.scene) if a.scene else None)
95
+
96
+
97
+ def cmd_preview(a):
98
+ ep, _, _ = _sync(a.slug)
99
+ subprocess.run(hf("preview", *a.args), cwd=ep)
100
+
101
+
102
+ def cmd_check(a):
103
+ ep, _, _ = _sync(a.slug)
104
+ proc = subprocess.run(hf("check", *a.args), cwd=ep)
105
+ raise SystemExit(proc.returncode)
106
+
107
+
108
+ def cmd_render(a):
109
+ require_tools()
110
+ ep, script, timing = _sync(a.slug)
111
+ info("rendering")
112
+ renderer.render_episode(ep, script, timing, a.draft, set(a.force) if a.force else None, a.force is not None)
113
+
114
+
115
+ def cmd_thumbnail(a):
116
+ ep = episode_dir(a.slug)
117
+ script = parse(ep / "script.md")
118
+ builder.sync_brand(ep)
119
+ page = ep / "thumbnail" / "thumbnail.html"
120
+ if not page.exists():
121
+ page.parent.mkdir(exist_ok=True)
122
+ title = html.escape(str(script.meta.get("title", a.slug)))
123
+ page.write_text((TEMPLATES / "thumbnail.html").read_text()
124
+ .replace("__HEADLINE__", title).replace("__TAG__", "Explainer"))
125
+ info(f"created {page.relative_to(ROOT)} - edit it, then run this again")
126
+ browser = shutil.which("chromium") or shutil.which("google-chrome") or shutil.which("chrome")
127
+ if not browser:
128
+ die("chromium not found")
129
+ OUT.mkdir(exist_ok=True)
130
+ with tempfile.TemporaryDirectory() as tmp:
131
+ png = Path(tmp) / "t.png"
132
+ subprocess.run([browser, "--headless=new", "--disable-gpu", "--hide-scrollbars",
133
+ "--force-device-scale-factor=1", "--window-size=1280,720",
134
+ "--virtual-time-budget=3000", f"--screenshot={png}", page.as_uri()],
135
+ capture_output=True, timeout=120)
136
+ if not png.exists():
137
+ die("thumbnail screenshot failed")
138
+ dst = OUT / f"{a.slug}-thumbnail.jpg"
139
+ subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(png), "-q:v", "2", str(dst)], check=True)
140
+ info(f"out/{dst.name}")
141
+
142
+
143
+ def cmd_voices(a):
144
+ """Synthesise one scene with each candidate voice (current settings otherwise), loudness-matched."""
145
+ ep = episode_dir(a.slug)
146
+ script = parse(ep / "script.md")
147
+ scene = next((sc for sc in script.scenes if sc.id == a.scene), None) if a.scene else \
148
+ next((sc for sc in script.scenes if sc.chunks), None)
149
+ if not scene or not scene.chunks:
150
+ die(f"no narrated scene '{a.scene}' in {a.slug}")
151
+ table = voice.load_pronunciations(script)
152
+ dst = OUT / "voice-samples"
153
+ dst.mkdir(parents=True, exist_ok=True)
154
+ if voice.engine_class(script) is voice.Chatterbox:
155
+ if a.speed:
156
+ info(" warning: --speed is ignored by Chatterbox (pacing comes from the reference clip)")
157
+ # One worker for every clip: the model loads once and only the conditioning changes.
158
+ # --voices paths are tried against the current directory first, then the studio root.
159
+ specs = [str(Path(v).resolve()) if Path(v).exists() else v for v in a.voices or []] or \
160
+ [str(p.relative_to(ROOT)) for p in sorted((ROOT / "brand" / "voices").glob("*.wav"))] + ["default"]
161
+ tts = voice.Chatterbox(Script({**script.meta, "voice": "default"}, script.scenes))
162
+ for n, spec in enumerate(specs, 1):
163
+ ref = voice.chatterbox_ref(Script({**script.meta, "voice": spec}, script.scenes))
164
+ tts.ref = str(ref) if ref else None
165
+ audition(tts, scene, table, dst / f"{n}-{ref.stem if ref else 'default'}.wav")
166
+ return
167
+ for n, spec in enumerate(a.voices or AUDITION, 1):
168
+ meta = {**script.meta, "tts": "kokoro", "voice": spec, **({"speed": a.speed} if a.speed else {})}
169
+ tts = voice.Kokoro(Script(meta, script.scenes))
170
+ name = re.sub(r"[^a-z0-9]+", "-", voice.voice_spec(spec).lower()).strip("-")
171
+ audition(tts, scene, table, dst / f"{n}-{name}.wav")
172
+
173
+
174
+ def cmd_music(a):
175
+ """Generate a music bed with ElevenLabs Music, sized to the synced episode, and print the `music:` line."""
176
+ ep = episode_dir(a.slug)
177
+ script = parse(ep / "script.md")
178
+ prompt = a.prompt or script.setting("music_prompt")
179
+ if not prompt:
180
+ die("give --prompt, or set music_prompt: in the script's front matter")
181
+ if not 1 <= a.variants <= 4:
182
+ die("--variants must be 1-4")
183
+ info(f"music ({a.model})")
184
+ out = Path(a.out).resolve() if a.out else None
185
+ paths = music.make_beds(ep, str(prompt), a.name, a.length, a.model, a.variants, out)
186
+ rel = [str(p.relative_to(ROOT)) if p.is_relative_to(ROOT) else str(p) for p in paths]
187
+ info(f"\n audition, then set in script.md: music: {rel[0]}")
188
+ info(" log the track in brand/music/CREDITS.md (source: ElevenLabs Music, prompt, date)")
189
+
190
+
191
+ def audition(tts, scene, table: dict, out: Path) -> None:
192
+ with tempfile.TemporaryDirectory() as tmp:
193
+ pieces = []
194
+ for i, chunk in enumerate(scene.chunks):
195
+ wav = Path(tmp) / f"{i}.wav"
196
+ tts.synth_to(voice.respell(" ".join(chunk.words), table), wav)
197
+ pieces += [voice.read_mono(wav), np.zeros(int(chunk.gap_after * voice.SAMPLE_RATE), np.float32)]
198
+ raw = Path(tmp) / "all.wav"
199
+ sf.write(str(raw), np.concatenate(pieces), voice.SAMPLE_RATE)
200
+ subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(raw), "-af", "loudnorm=I=-16:TP=-1.5",
201
+ "-ar", str(voice.SAMPLE_RATE), str(out)], check=True)
202
+ info(f" {out.relative_to(ROOT)}")
203
+
204
+
205
+ def main():
206
+ p = argparse.ArgumentParser(prog="studio", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
207
+ sub = p.add_subparsers(dest="cmd", required=True)
208
+
209
+ s = sub.add_parser("new", help="scaffold a new episode")
210
+ s.add_argument("slug")
211
+ s.add_argument("title", nargs="?")
212
+ s.set_defaults(fn=cmd_new)
213
+
214
+ s = sub.add_parser("status", help="scene table and length estimate")
215
+ s.add_argument("slug")
216
+ s.set_defaults(fn=cmd_status)
217
+
218
+ s = sub.add_parser("sync", help="narrate, align, stub scenes, write index.html")
219
+ s.add_argument("slug")
220
+ s.add_argument("--scene", nargs="*", help="only re-narrate these scenes (others reuse cached timings)")
221
+ s.set_defaults(fn=cmd_sync)
222
+
223
+ s = sub.add_parser("preview", help="sync, then open HyperFrames Studio")
224
+ s.add_argument("slug")
225
+ s.add_argument("args", nargs=argparse.REMAINDER, help="extra args for `hyperframes preview`")
226
+ s.set_defaults(fn=cmd_preview)
227
+
228
+ s = sub.add_parser("check", help="sync, then hyperframes check")
229
+ s.add_argument("slug")
230
+ s.add_argument("args", nargs=argparse.REMAINDER)
231
+ s.set_defaults(fn=cmd_check)
232
+
233
+ s = sub.add_parser("render", help="render changed scenes and master the episode to out/")
234
+ s.add_argument("slug")
235
+ s.add_argument("--draft", action="store_true", help="fast draft quality -> out/<slug>-draft.mp4")
236
+ s.add_argument("--force", nargs="*", metavar="SCENE", help="re-render these scenes (or all, if none named)")
237
+ s.set_defaults(fn=cmd_render)
238
+
239
+ s = sub.add_parser("thumbnail", help="render thumbnail/thumbnail.html to out/<slug>-thumbnail.jpg")
240
+ s.add_argument("slug")
241
+ s.set_defaults(fn=cmd_thumbnail)
242
+
243
+ s = sub.add_parser("voices", help="audition Kokoro blends (or Chatterbox clips, with tts: chatterbox) -> out/voice-samples/")
244
+ s.add_argument("slug")
245
+ s.add_argument("--scene", help="scene id (default: the first narrated scene)")
246
+ s.add_argument("--voices", nargs="+", metavar="SPEC", help="voices or blends, e.g. 'bf_emma*0.6 + bf_lily*0.4'; for Chatterbox, clip paths or 'default'")
247
+ s.add_argument("--speed", type=float, help="override the script's speed for these samples")
248
+ s.set_defaults(fn=cmd_voices)
249
+
250
+ s = sub.add_parser("music", help="generate an instrumental music bed (ElevenLabs Music) sized to the episode")
251
+ s.add_argument("slug")
252
+ s.add_argument("--prompt", help="style, instruments, mood (default: music_prompt: in the script); don't name artists or songs")
253
+ s.add_argument("--name", default="bed", help="file name in the episode's audio/music/ (default: bed)")
254
+ s.add_argument("--length", type=int, metavar="SEC", help="bed length (default: the synced episode length + 2s)")
255
+ s.add_argument("--model", default=music.MODEL, help=f"ElevenLabs Music model (default: {music.MODEL})")
256
+ s.add_argument("--variants", type=int, default=1, help="make N different takes (1-4) to audition, suffixed -a, -b…")
257
+ s.add_argument("--out", metavar="PATH", help="write here instead, e.g. brand/music/my-bed.mp3 to share across episodes")
258
+ s.set_defaults(fn=cmd_music)
259
+
260
+ a = p.parse_args()
261
+ a.fn(a)
262
+
263
+
264
+ if __name__ == "__main__":
265
+ main()
studio/common.py ADDED
@@ -0,0 +1,160 @@
1
+ """Paths, settings and small helpers shared by the studio commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import os
8
+ import shutil
9
+ import subprocess
10
+ import sys
11
+ from pathlib import Path
12
+
13
+
14
+ def _workspace() -> Path:
15
+ """$STUDIO_ROOT, else the nearest directory at or above the cwd holding episodes/, else the cwd."""
16
+ if env := os.environ.get("STUDIO_ROOT"):
17
+ return Path(env).expanduser().resolve()
18
+ cwd = Path.cwd().resolve()
19
+ return next((d for d in (cwd, *cwd.parents) if (d / "episodes").is_dir()), cwd)
20
+
21
+
22
+ # House style bundled with the package: studio/data/ in a wheel, the source tree in a checkout.
23
+ _HERE = Path(__file__).resolve().parent
24
+ PKG_DATA = _HERE / "data" if (_HERE / "data").is_dir() else _HERE.parents[1]
25
+
26
+ # The workspace holds episodes/, out/, .env and any brand/music or brand/voices. A workspace brand/
27
+ # or templates/ (as in a repo checkout) overrides the bundled copy.
28
+ ROOT = _workspace()
29
+ BRAND = ROOT / "brand" if (ROOT / "brand" / "brand.css").exists() else PKG_DATA / "brand"
30
+ TEMPLATES = ROOT / "templates" if (ROOT / "templates" / "script.md").exists() else PKG_DATA / "templates"
31
+ EPISODES = ROOT / "episodes"
32
+ OUT = ROOT / "out"
33
+
34
+ # Pin the HyperFrames CLI so renders are reproducible. Bump deliberately, then run `studio check`.
35
+ HF_VERSION = os.environ.get("STUDIO_HF_VERSION", "0.8.153")
36
+ # Chatterbox TTS runs in its own uv environment (it pins torch and numpy<2); pinned for the same reason.
37
+ CHATTERBOX_VERSION = os.environ.get("STUDIO_CHATTERBOX_VERSION", "0.1.7")
38
+
39
+ # Episode defaults; any of these can be overridden in a script's front matter.
40
+ DEFAULTS = {
41
+ "tts": "kokoro", # TTS engine: kokoro (local), chatterbox (local, cloned) or elevenlabs (cloud; key in .env)
42
+ # Kokoro voice or weighted blend, an ElevenLabs voice ID, or a Chatterbox reference clip (or "default")
43
+ "voice": "bf_emma*0.6 + bf_isabella*0.4",
44
+ "speed": 0.85, # Kokoro voices differ: the default blend is ~165 wpm at 0.85, bm_george ~155 at 1.0
45
+ "g2p": "misaki", # Kokoro phonemizer: misaki (what Kokoro was trained on) or espeak
46
+ "sentence_pause": 0.38, # Kokoro: silence between sentences, seconds
47
+ "clause_pause": 0.12, # Kokoro: silence where an over-long sentence is split at a comma
48
+ "voice_fx": True, # Kokoro: gentle EQ/compression/room on the dry voice (voice.VOICE_FX)
49
+ "tts_model": "eleven_multilingual_v2", # ElevenLabs model
50
+ "voice_settings": None, # ElevenLabs: {stability, similarity_boost, style, use_speaker_boost}
51
+ "chatterbox_model": "turbo", # Chatterbox: turbo (350M, faster) or standard (500M, honours the next two)
52
+ "exaggeration": 0.5, # Chatterbox standard: emotional intensity (0.25-2)
53
+ "cfg_weight": 0.5, # Chatterbox standard: lower is slower and more deliberate
54
+ "temperature": 0.8, # Chatterbox: sampling temperature
55
+ "seed": 0, # Chatterbox: random seed, so a re-synthesis is repeatable
56
+ "format": "landscape", # landscape (1920x1080, YouTube) or reel (1080x1920: Reels, TikTok, Shorts)
57
+ "burn_captions": False, # burn word-highlighted captions into the video (on for reels; most autoplay muted)
58
+ "fps": 30,
59
+ "pad_in": 0.6, # silence before a scene's narration starts
60
+ "pad_out": 0.9, # silence after it ends (the exit fade lives here)
61
+ "paragraph_gap": 0.45, # pause between paragraphs inside a scene
62
+ "music": None, # path to a music bed, relative to the studio root
63
+ "music_prompt": None, # default prompt for `studio music` (ElevenLabs Music)
64
+ "music_db": -24, # music level under narration, before ducking
65
+ "music_fade_in": 2, # seconds; 0 keeps a hit on the bed's first beat
66
+ "loudness": -14, # integrated LUFS target (YouTube normalises to -14)
67
+ "true_peak": -1.5,
68
+ }
69
+
70
+ SAMPLE_RATE = 48000
71
+ FORMATS = {"landscape": (1920, 1080), "reel": (1080, 1920)}
72
+
73
+
74
+ def die(msg: str) -> None:
75
+ print(f"error: {msg}", file=sys.stderr)
76
+ sys.exit(1)
77
+
78
+
79
+ def info(msg: str) -> None:
80
+ print(msg, flush=True)
81
+
82
+
83
+ def sha(*parts) -> str:
84
+ h = hashlib.sha256()
85
+ for p in parts:
86
+ if isinstance(p, Path):
87
+ h.update(p.read_bytes())
88
+ elif isinstance(p, bytes):
89
+ h.update(p)
90
+ else:
91
+ h.update(json.dumps(p, sort_keys=True, default=str).encode())
92
+ h.update(b"\0")
93
+ return h.hexdigest()
94
+
95
+
96
+ def tree_hash(folder: Path) -> str:
97
+ """Hash every file under folder by path, size and mtime (cheap; good enough for cache keys)."""
98
+ if not folder.exists():
99
+ return ""
100
+ entries = sorted(
101
+ (str(p.relative_to(folder)), p.stat().st_size, int(p.stat().st_mtime))
102
+ for p in folder.rglob("*")
103
+ if p.is_file()
104
+ )
105
+ return sha(entries)
106
+
107
+
108
+ def run(cmd: list[str], cwd: Path | None = None, quiet: bool = False, env: dict | None = None) -> str:
109
+ full_env = {**os.environ, **(env or {})}
110
+ proc = subprocess.run(cmd, cwd=cwd, env=full_env, text=True, capture_output=True)
111
+ if proc.returncode != 0:
112
+ tail = (proc.stdout + proc.stderr).strip().splitlines()[-25:]
113
+ die(f"command failed ({proc.returncode}): {' '.join(cmd[:6])} ...\n" + "\n".join(tail))
114
+ if not quiet and proc.stderr.strip():
115
+ pass
116
+ return proc.stdout
117
+
118
+
119
+ def hf(*args: str) -> list[str]:
120
+ """argv for the pinned HyperFrames CLI."""
121
+ return ["npx", "--yes", f"hyperframes@{HF_VERSION}", *args]
122
+
123
+
124
+ def hf_env() -> dict:
125
+ # Let the CLI's own tts/transcribe find kokoro-onnx in this studio's venv.
126
+ return {"HYPERFRAMES_PYTHON": sys.executable}
127
+
128
+
129
+ def load_env() -> None:
130
+ """Read ROOT/.env (KEY=value, optional `export`, quotes, # comments) without overriding the environment."""
131
+ path = ROOT / ".env"
132
+ if not path.exists():
133
+ return
134
+ for line in path.read_text().splitlines():
135
+ line = line.strip()
136
+ if not line or line.startswith("#") or "=" not in line:
137
+ continue
138
+ key, _, value = line.removeprefix("export ").partition("=")
139
+ key, value = key.strip(), value.strip()
140
+ if len(value) >= 2 and value[0] == value[-1] and value[0] in "'\"":
141
+ value = value[1:-1]
142
+ os.environ.setdefault(key, value)
143
+
144
+
145
+ def ffprobe_duration(path: Path) -> float:
146
+ out = run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", str(path)])
147
+ return float(out.strip())
148
+
149
+
150
+ def episode_dir(slug: str) -> Path:
151
+ d = EPISODES / slug
152
+ if not (d / "script.md").exists():
153
+ die(f"no episode '{slug}' (expected {d / 'script.md'})")
154
+ return d
155
+
156
+
157
+ def require_tools() -> None:
158
+ for tool in ("ffmpeg", "ffprobe", "npx"):
159
+ if not shutil.which(tool):
160
+ die(f"'{tool}' not found on PATH")
@@ -0,0 +1,145 @@
1
+ /* Explainer house style, after wsws.org. Tokens mirror brand/frame.md.
2
+ `studio sync` copies this file (with fonts/ and gsap) into each episode's assets/brand/. */
3
+
4
+ @font-face { font-family: "PT Serif"; src: url("fonts/PTSerif-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; }
5
+ @font-face { font-family: "PT Serif"; src: url("fonts/PTSerif-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; }
6
+ @font-face { font-family: "PT Serif"; src: url("fonts/PTSerif-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; }
7
+ @font-face { font-family: "PT Serif"; src: url("fonts/PTSerif-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; }
8
+ @font-face { font-family: "Source Sans 3"; src: url("fonts/SourceSans3.ttf") format("truetype"); font-weight: 200 900; font-style: normal; }
9
+ @font-face { font-family: "Source Sans 3"; src: url("fonts/SourceSans3-Italic.ttf") format("truetype"); font-weight: 200 900; font-style: italic; }
10
+ @font-face { font-family: "JetBrains Mono"; src: url("fonts/JetBrainsMono.ttf") format("truetype"); font-weight: 100 800; }
11
+
12
+ :root {
13
+ --paper: #ffffff;
14
+ --panel: #f4f4f4;
15
+ --ink: #231f20;
16
+ --ink-2: #333333;
17
+ --ink-soft: #555555;
18
+ --rule: #cccccc;
19
+ --red: #e71e25;
20
+ --red-wash: #ffdfdf;
21
+ --tag: #1b2129;
22
+
23
+ --font-serif: "PT Serif", Georgia, serif;
24
+ --font-sans: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
25
+ --font-mono: "JetBrains Mono", ui-monospace, monospace;
26
+
27
+ --safe-x: 192px; /* title-safe inset (10%) */
28
+ --safe-y: 108px;
29
+ --hairline: 2px solid var(--rule);
30
+ }
31
+
32
+ /* Full-bleed white page. */
33
+ .paper { position: absolute; inset: 0; background: var(--paper); }
34
+
35
+ /* Title-safe content box. Put scene content inside one of these. */
36
+ .stage {
37
+ position: absolute;
38
+ inset: var(--safe-y) var(--safe-x);
39
+ color: var(--ink-2);
40
+ font-family: var(--font-serif);
41
+ }
42
+
43
+ /* Reel (9:16, 1080x1920) content box. Platform UI covers the top ~200px, the right ~140px
44
+ (like/comment/share) and the bottom ~480px (caption, handle, audio). Burned captions sit
45
+ in the band y 1220-1440, so scene content ends by y 1180. */
46
+ .stage-reel {
47
+ position: absolute;
48
+ inset: 220px 72px 740px 72px;
49
+ color: var(--ink-2);
50
+ font-family: var(--font-serif);
51
+ }
52
+
53
+ /* Heavy ink rule + uppercase label, like the site's "TOP STORIES" head.
54
+ <div class="section-head"><div class="section-rule"></div><div class="label">History</div></div>
55
+ Draw the rule on with scaleX (transform-origin is left). */
56
+ .section-head { display: flex; flex-direction: column; gap: 18px; }
57
+ .section-rule { height: 6px; background: var(--ink); transform-origin: left center; }
58
+
59
+ .label {
60
+ font-family: var(--font-sans);
61
+ font-weight: 700;
62
+ font-size: 26px;
63
+ letter-spacing: 0.12em;
64
+ text-transform: uppercase;
65
+ color: var(--ink);
66
+ }
67
+
68
+ /* Dark category tag ("PERSPECTIVE"). */
69
+ .tag {
70
+ display: inline-block;
71
+ align-self: flex-start;
72
+ background: var(--tag);
73
+ color: #ffffff;
74
+ font-family: var(--font-sans);
75
+ font-weight: 700;
76
+ font-size: 24px;
77
+ letter-spacing: 0.12em;
78
+ text-transform: uppercase;
79
+ padding: 10px 18px 9px;
80
+ }
81
+
82
+ .headline {
83
+ font-family: var(--font-serif);
84
+ font-weight: 700;
85
+ font-size: 104px;
86
+ line-height: 1.12;
87
+ color: var(--ink);
88
+ margin: 0;
89
+ }
90
+
91
+ .standfirst {
92
+ font-family: var(--font-serif);
93
+ font-style: italic;
94
+ font-weight: 400;
95
+ font-size: 48px;
96
+ line-height: 1.35;
97
+ color: var(--ink-soft);
98
+ margin: 0;
99
+ }
100
+
101
+ .body {
102
+ font-family: var(--font-serif);
103
+ font-weight: 400;
104
+ font-size: 46px;
105
+ line-height: 1.4;
106
+ color: var(--ink-2);
107
+ margin: 0;
108
+ }
109
+
110
+ /* Source / byline / date line. */
111
+ .byline {
112
+ font-family: var(--font-sans);
113
+ font-weight: 600;
114
+ font-size: 28px;
115
+ color: var(--ink-soft);
116
+ }
117
+
118
+ /* Blockquote with red left rule. */
119
+ .quote {
120
+ border-left: 6px solid var(--red);
121
+ padding-left: 56px;
122
+ font-family: var(--font-serif);
123
+ color: var(--ink);
124
+ }
125
+
126
+ .italic { font-style: italic; }
127
+ .soft { color: var(--ink-soft); }
128
+ .red { color: var(--red); }
129
+ .sans { font-family: var(--font-sans); }
130
+ .mono { font-family: var(--font-mono); font-weight: 500; }
131
+ .hairline { height: 0; border-top: var(--hairline); }
132
+ .panel { background: var(--panel); padding: 40px 48px; }
133
+
134
+ /* Highlight wash: <span id="x-key" class="hl">phrase</span>
135
+ Sweep it in on a cue: tl.to("#x-key", { backgroundSize: "100% 82%", duration: 0.5 }, cue("key")) */
136
+ .hl {
137
+ background-image: linear-gradient(var(--red-wash), var(--red-wash));
138
+ background-repeat: no-repeat;
139
+ background-position: left 70%;
140
+ background-size: 0% 82%;
141
+ padding: 0 0.06em;
142
+ margin: 0 -0.06em;
143
+ -webkit-box-decoration-break: clone;
144
+ box-decoration-break: clone;
145
+ }
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+
5
+ This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.