commit 16789be0efef4f08ac934a13a2f10116cb097730
parent 83e9965238d4712f1d9713cdc93f4ba8763d3a44
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 3 Nov 2026 14:13:09 -0500
umtool: the word zoom marks on the read lane worked out once per change, not per frame; a word pair too different in length is not scored
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx
@@ -284,6 +284,14 @@ export default function PostNarrationPanel({
const tMedia = useMemo(() => projectFileMedia({ project, path: picked?.file ?? "", seconds: picked?.seconds || 1 }), [project, picked?.file, picked?.seconds]);
const tPeaks = usePeaks(picked ? tMedia : { ...tMedia, peaksUrl: null });
const [showWhole, setShowWhole] = useState(false);
+ // The word zooms on the read (word-zoom.mjs): worked out once per change, not per frame.
+ const zoomSpans = useMemo(
+ () =>
+ wordZoomTimes(entry, render)
+ .filter((z) => typeof z.t === "number")
+ .map((z) => ({ i: z.i, ...zoomSpan((entry.fx as Array<Record<string, unknown>>)[z.i], z.t as number) })),
+ [entry, render],
+ );
const sch = plan.narration ?? null;
const total = plan.total;
const pct = (v: number) => `${(v / Math.max(0.1, total)) * 100}%`;
@@ -465,10 +473,9 @@ export default function PostNarrationPanel({
))}
</div>
{/* The word zooms on the read: from the lead-in to back out (word-zoom.mjs). */}
- {(wordZoomTimes(entry, render) as Array<{ i: number; t?: number }>).filter((z) => typeof z.t === "number").map((z) => {
- const sp = zoomSpan((entry.fx as Array<Record<string, unknown>>)[z.i], z.t as number);
- return <div key={`z${z.i}`} className="pointer-events-none absolute inset-y-0 border-x-2 border-amber-300 bg-amber-300/10" style={{ left: pct(sp.t0), width: pct(sp.t3 - sp.t0) }} title={`word zoom ${z.i + 1}`} data-post-lane-zoom={z.i} />;
- })}
+ {zoomSpans.map((sp) => (
+ <div key={`z${sp.i}`} className="pointer-events-none absolute inset-y-0 border-x-2 border-amber-300 bg-amber-300/10" style={{ left: pct(sp.t0), width: pct(sp.t3 - sp.t0) }} title={`word zoom ${sp.i + 1}`} data-post-lane-zoom={sp.i} />
+ ))}
<div className="absolute inset-y-0 w-px bg-[var(--color-signal,#e33)]" style={{ left: pct(s) }} />
</div>
</div>
diff --git a/umtool/report-to-video/word-zoom.mjs b/umtool/report-to-video/word-zoom.mjs
@@ -188,7 +188,10 @@ export function wordSimilarity(a, b) {
const y = spoken(b);
if (!x || !y) return 0;
if (x === y) return 1;
- return Math.max(0, 1 - lev(x, y) / Math.max(x.length, y.length));
+ const max = Math.max(x.length, y.length);
+ // The edit distance is at least the difference in length: past half the longer, no pair (skip the work).
+ if (Math.abs(x.length - y.length) > max * (1 - ALIGN_MIN)) return 0;
+ return Math.max(0, 1 - lev(x, y) / max);
}
/** Below this, two words are not the same word. */