"""Generate hf/index.html for the 0-32s style-validation slice.""" import json from pathlib import Path ROOT = Path(r"D:\PromptEngineer48\In-Progress\P11-Editor\edit") words = [w for w in json.load(open(ROOT/"transcripts/LMSTUDIO-MTP1.json", encoding="utf-8"))["words"] if w.get("type") == "word"] # ---- captions: 2-word UPPERCASE chunks, 0.16 .. 24.0 ---- CAP_END = 24.0 cw = [w for w in words if w["start"] < CAP_END] chunks = [] i = 0 while i < len(cw): pair = cw[i:i+2] txt = " ".join(p["text"] for p in pair) txt = txt.replace(",", "").replace(".", "").replace('"', "").strip().upper() chunks.append({"t": pair[0]["start"], "txt": txt}) i += 2 # end time = next chunk start (or CAP_END) for j, c in enumerate(chunks): c["end"] = chunks[j+1]["t"] if j+1 < len(chunks) else CAP_END cap_divs = "\n".join( f'
{c["txt"]}
' for j, c in enumerate(chunks) ) cap_tw = [] for j, c in enumerate(chunks): cap_tw.append( f'tl.fromTo("#cap{j}",{{opacity:0,scale:0.92,y:12,xPercent:-50}},' f'{{opacity:1,scale:1,y:0,xPercent:-50,duration:0.13,ease:"back.out(2)",overwrite:"auto"}},{c["t"]:.2f});' ) cap_tw.append(f'tl.to("#cap{j}",{{opacity:0,duration:0.08,overwrite:"auto"}},{c["end"]-0.02:.2f});') cap_tw = "\n ".join(cap_tw) # ---- SFX (each on its own track) ---- sfx = [ ("op_whoosh", "whoosh.mp3", 0.10, 0.5, 7), ("riser", "riser.mp3", 6.00, 0.6, 2), ("pop", "pop.mp3", 7.94, 0.8, 3), ("impact", "impact.mp3", 12.98,0.85,4), ("ding", "ding.mp3", 14.45,0.7, 5), ("whoosh", "whoosh.mp3", 24.20,0.8, 6), ] sfx_els = "\n".join( f' ' for (n, f, t, v, ti) in sfx ) HTML = f"""
{sfx_els} {cap_divs}
Tokens / second
Without MTP62tok/s
With MTP78tok/s
+25% FASTER
WHAT IS MTP?
MULTI-TOKEN PREDICTION
""" (ROOT/"hf"/"index.html").write_text(HTML, encoding="utf-8") print(f"wrote hf/index.html ({len(chunks)} caption chunks)")