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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate hf/index.html for the 0-32s style-validation slice."""
|
| 2 |
+
import json
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
ROOT = Path(r"D:\PromptEngineer48\In-Progress\P11-Editor\edit")
|
| 6 |
+
words = [w for w in json.load(open(ROOT/"transcripts/LMSTUDIO-MTP1.json", encoding="utf-8"))["words"]
|
| 7 |
+
if w.get("type") == "word"]
|
| 8 |
+
|
| 9 |
+
# ---- captions: 2-word UPPERCASE chunks, 0.16 .. 24.0 ----
|
| 10 |
+
CAP_END = 24.0
|
| 11 |
+
cw = [w for w in words if w["start"] < CAP_END]
|
| 12 |
+
chunks = []
|
| 13 |
+
i = 0
|
| 14 |
+
while i < len(cw):
|
| 15 |
+
pair = cw[i:i+2]
|
| 16 |
+
txt = " ".join(p["text"] for p in pair)
|
| 17 |
+
txt = txt.replace(",", "").replace(".", "").replace('"', "").strip().upper()
|
| 18 |
+
chunks.append({"t": pair[0]["start"], "txt": txt})
|
| 19 |
+
i += 2
|
| 20 |
+
# end time = next chunk start (or CAP_END)
|
| 21 |
+
for j, c in enumerate(chunks):
|
| 22 |
+
c["end"] = chunks[j+1]["t"] if j+1 < len(chunks) else CAP_END
|
| 23 |
+
|
| 24 |
+
cap_divs = "\n".join(
|
| 25 |
+
f' <div class="cap" id="cap{j}">{c["txt"]}</div>' for j, c in enumerate(chunks)
|
| 26 |
+
)
|
| 27 |
+
cap_tw = []
|
| 28 |
+
for j, c in enumerate(chunks):
|
| 29 |
+
cap_tw.append(
|
| 30 |
+
f'tl.fromTo("#cap{j}",{{opacity:0,scale:0.92,y:12,xPercent:-50}},'
|
| 31 |
+
f'{{opacity:1,scale:1,y:0,xPercent:-50,duration:0.13,ease:"back.out(2)",overwrite:"auto"}},{c["t"]:.2f});'
|
| 32 |
+
)
|
| 33 |
+
cap_tw.append(f'tl.to("#cap{j}",{{opacity:0,duration:0.08,overwrite:"auto"}},{c["end"]-0.02:.2f});')
|
| 34 |
+
cap_tw = "\n ".join(cap_tw)
|
| 35 |
+
|
| 36 |
+
# ---- SFX (each on its own track) ----
|
| 37 |
+
sfx = [
|
| 38 |
+
("op_whoosh", "whoosh.mp3", 0.10, 0.5, 7),
|
| 39 |
+
("riser", "riser.mp3", 6.00, 0.6, 2),
|
| 40 |
+
("pop", "pop.mp3", 7.94, 0.8, 3),
|
| 41 |
+
("impact", "impact.mp3", 12.98,0.85,4),
|
| 42 |
+
("ding", "ding.mp3", 14.45,0.7, 5),
|
| 43 |
+
("whoosh", "whoosh.mp3", 24.20,0.8, 6),
|
| 44 |
+
]
|
| 45 |
+
sfx_els = "\n".join(
|
| 46 |
+
f' <audio id="sfx_{n}" src="../assets/sfx/{f}" data-start="{t}" '
|
| 47 |
+
f'data-track-index="{ti}" data-volume="{v}"></audio>'
|
| 48 |
+
for (n, f, t, v, ti) in sfx
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
HTML = f"""<!doctype html>
|
| 52 |
+
<html lang="en">
|
| 53 |
+
<head>
|
| 54 |
+
<meta charset="utf-8" />
|
| 55 |
+
<style>
|
| 56 |
+
* {{ margin:0; padding:0; box-sizing:border-box; }}
|
| 57 |
+
#root {{
|
| 58 |
+
position:relative; width:1920px; height:1080px; overflow:hidden;
|
| 59 |
+
background:#0B0F14; font-family:"Inter",sans-serif;
|
| 60 |
+
}}
|
| 61 |
+
.zoom-wrap {{ position:absolute; inset:0; z-index:0; transform-origin:50% 42%; }}
|
| 62 |
+
.zoom-wrap video {{ width:1920px; height:1080px; object-fit:cover; display:block; }}
|
| 63 |
+
|
| 64 |
+
/* ---- captions ---- */
|
| 65 |
+
.cap {{
|
| 66 |
+
position:absolute; left:50%; bottom:96px;
|
| 67 |
+
z-index:30; opacity:0;
|
| 68 |
+
font-family:"Inter",sans-serif; font-weight:900; font-size:58px; letter-spacing:1px;
|
| 69 |
+
color:#fff; white-space:nowrap;
|
| 70 |
+
text-shadow:0 4px 18px rgba(0,0,0,0.85), 0 2px 4px rgba(0,0,0,0.9);
|
| 71 |
+
padding:10px 26px;
|
| 72 |
+
}}
|
| 73 |
+
|
| 74 |
+
/* ---- glass recipe ---- */
|
| 75 |
+
.glass {{
|
| 76 |
+
background:rgba(255,255,255,0.07);
|
| 77 |
+
backdrop-filter:blur(22px) saturate(130%);
|
| 78 |
+
-webkit-backdrop-filter:blur(22px) saturate(130%);
|
| 79 |
+
border:1px solid rgba(255,255,255,0.18);
|
| 80 |
+
border-radius:26px;
|
| 81 |
+
box-shadow:0 24px 60px rgba(0,0,0,0.45);
|
| 82 |
+
}}
|
| 83 |
+
|
| 84 |
+
/* ---- hook counter card ---- */
|
| 85 |
+
.hook-card {{
|
| 86 |
+
position:absolute; left:50%; top:50%;
|
| 87 |
+
z-index:20; opacity:0; width:760px; padding:46px 56px;
|
| 88 |
+
display:flex; flex-direction:column; gap:22px;
|
| 89 |
+
}}
|
| 90 |
+
.hook-label {{ font-family:"Inter",sans-serif; font-weight:700; font-size:24px;
|
| 91 |
+
letter-spacing:5px; color:#9AA7B4; text-transform:uppercase; }}
|
| 92 |
+
.row {{ display:flex; align-items:baseline; justify-content:space-between; }}
|
| 93 |
+
.row .tag {{ font-family:"Inter",sans-serif; font-weight:600; font-size:34px;
|
| 94 |
+
letter-spacing:2px; text-transform:uppercase; }}
|
| 95 |
+
.row .num {{ font-family:"Inter",sans-serif; font-weight:700; font-size:118px;
|
| 96 |
+
line-height:0.9; font-variant-numeric:tabular-nums; }}
|
| 97 |
+
.row .unit {{ font-family:"Inter",sans-serif; font-weight:700; font-size:30px; color:#9AA7B4;
|
| 98 |
+
margin-left:10px; }}
|
| 99 |
+
#r_no {{ opacity:0; }} #r_yes {{ opacity:0; }}
|
| 100 |
+
#r_no .tag, #r_no .num {{ color:#F87171; }}
|
| 101 |
+
#r_yes .tag, #r_yes .num {{ color:#A3E635; }}
|
| 102 |
+
.badge {{
|
| 103 |
+
position:absolute; right:-34px; top:-34px; opacity:0;
|
| 104 |
+
font-family:"Inter",sans-serif; font-weight:700; font-size:34px;
|
| 105 |
+
color:#0B0F14; background:#A3E635; padding:14px 26px; border-radius:18px;
|
| 106 |
+
box-shadow:0 12px 30px rgba(163,230,53,0.45); transform:rotate(-6deg);
|
| 107 |
+
}}
|
| 108 |
+
|
| 109 |
+
/* ---- "WHAT IS MTP?" title card ---- */
|
| 110 |
+
.mtp-card {{
|
| 111 |
+
position:absolute; left:50%; top:50%;
|
| 112 |
+
z-index:25; opacity:0; padding:64px 90px; text-align:center;
|
| 113 |
+
display:flex; flex-direction:column; align-items:center; gap:18px;
|
| 114 |
+
}}
|
| 115 |
+
.mtp-title {{ font-family:"Inter",sans-serif; font-weight:700; font-size:120px;
|
| 116 |
+
color:#fff; letter-spacing:1px; }}
|
| 117 |
+
.mtp-underline {{ height:8px; width:0; background:#22D3EE; border-radius:6px;
|
| 118 |
+
box-shadow:0 0 22px rgba(34,211,238,0.8); }}
|
| 119 |
+
.mtp-sub {{ font-family:"Inter",sans-serif; font-weight:700; font-size:42px; color:#22D3EE;
|
| 120 |
+
letter-spacing:3px; opacity:0; }}
|
| 121 |
+
</style>
|
| 122 |
+
</head>
|
| 123 |
+
<body>
|
| 124 |
+
<div id="root" data-composition-id="root" data-width="1920" data-height="1080" data-start="0" data-duration="32">
|
| 125 |
+
<div class="zoom-wrap">
|
| 126 |
+
<video id="bg" src="base_slice.mp4" data-start="0" data-duration="32" data-track-index="0" muted playsinline></video>
|
| 127 |
+
</div>
|
| 128 |
+
<audio id="voice" src="base_slice.mp4" data-start="0" data-duration="32" data-track-index="1" data-volume="1"></audio>
|
| 129 |
+
{sfx_els}
|
| 130 |
+
|
| 131 |
+
<!-- captions -->
|
| 132 |
+
{cap_divs}
|
| 133 |
+
|
| 134 |
+
<!-- hook counter -->
|
| 135 |
+
<div class="hook-card glass">
|
| 136 |
+
<div class="hook-label">Tokens / second</div>
|
| 137 |
+
<div class="row" id="r_no"><span class="tag">Without MTP</span><span><span class="num">62</span><span class="unit">tok/s</span></span></div>
|
| 138 |
+
<div class="row" id="r_yes"><span class="tag">With MTP</span><span><span class="num">78</span><span class="unit">tok/s</span></span></div>
|
| 139 |
+
<div class="badge" id="badge">+25% FASTER</div>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<!-- what is MTP -->
|
| 143 |
+
<div class="mtp-card glass">
|
| 144 |
+
<div class="mtp-title">WHAT IS MTP?</div>
|
| 145 |
+
<div class="mtp-underline" id="mtpu"></div>
|
| 146 |
+
<div class="mtp-sub" id="mtps">MULTI-TOKEN PREDICTION</div>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
| 150 |
+
<script>
|
| 151 |
+
window.__timelines = window.__timelines || {{}};
|
| 152 |
+
const tl = gsap.timeline({{ paused: true }});
|
| 153 |
+
|
| 154 |
+
// center the cards via GSAP (xPercent/yPercent) so tweens don't wipe centering
|
| 155 |
+
tl.set(".hook-card", {{ xPercent: -50, yPercent: -50 }}, 0);
|
| 156 |
+
tl.set(".mtp-card", {{ xPercent: -50, yPercent: -50 }}, 0);
|
| 157 |
+
|
| 158 |
+
// background zoom: punch in on the numbers, release before concept
|
| 159 |
+
tl.set(".zoom-wrap", {{ scale: 1.0, transformOrigin: "50% 42%" }}, 0);
|
| 160 |
+
tl.to(".zoom-wrap", {{ scale: 1.30, duration: 2.0, ease: "power2.inOut" }}, 6.2);
|
| 161 |
+
tl.to(".zoom-wrap", {{ scale: 1.0, duration: 1.6, ease: "power2.inOut" }}, 19.4);
|
| 162 |
+
tl.to(".zoom-wrap", {{ scale: 1.06, duration: 4.0, ease: "sine.inOut" }}, 24.2);
|
| 163 |
+
|
| 164 |
+
// hook counter
|
| 165 |
+
tl.fromTo(".hook-card", {{opacity:0,scale:0.9,y:30}}, {{opacity:1,scale:1,y:0,duration:0.5,ease:"back.out(1.6)"}}, 6.5);
|
| 166 |
+
tl.fromTo("#r_no", {{opacity:0,x:-40}}, {{opacity:1,x:0,duration:0.4,ease:"power3.out"}}, 7.94);
|
| 167 |
+
tl.fromTo("#r_yes", {{opacity:0,x:-40}}, {{opacity:1,x:0,duration:0.4,ease:"power3.out"}}, 12.98);
|
| 168 |
+
tl.fromTo("#badge", {{opacity:0,scale:0.4,rotation:-30}}, {{opacity:1,scale:1,rotation:-6,duration:0.5,ease:"back.out(3)"}}, 14.45);
|
| 169 |
+
tl.to(".hook-card", {{opacity:0,scale:0.96,y:-24,duration:0.4,ease:"power2.in"}}, 19.2);
|
| 170 |
+
|
| 171 |
+
// what is MTP card
|
| 172 |
+
tl.fromTo(".mtp-card", {{opacity:0,scale:0.88,filter:"blur(14px)"}}, {{opacity:1,scale:1,filter:"blur(0px)",duration:0.6,ease:"power3.out"}}, 24.2);
|
| 173 |
+
tl.to("#mtpu", {{width:560,duration:0.5,ease:"power2.out"}}, 24.6);
|
| 174 |
+
tl.fromTo("#mtps", {{opacity:0,y:18}}, {{opacity:1,y:0,duration:0.45,ease:"power2.out"}}, 24.9);
|
| 175 |
+
|
| 176 |
+
// captions
|
| 177 |
+
{cap_tw}
|
| 178 |
+
|
| 179 |
+
window.__timelines["root"] = tl;
|
| 180 |
+
</script>
|
| 181 |
+
</div>
|
| 182 |
+
</body>
|
| 183 |
+
</html>
|
| 184 |
+
"""
|
| 185 |
+
|
| 186 |
+
(ROOT/"hf"/"index.html").write_text(HTML, encoding="utf-8")
|
| 187 |
+
print(f"wrote hf/index.html ({len(chunks)} caption chunks)")
|