Spaces:
Sleeping
Per-feature LLM toggles, section titles, redesigned upload page
Browse filesllm_extract: LLMToggles dataclass with alt_text/key_terms/math/section_title
flags. Disabled toggles drop the field from BOTH the prompt and the
Pydantic response schema (built dynamically via pydantic.create_model)
so we don't pay output tokens for fields we'd discard. Disabling all
of them skips the LLM call entirely. Section titles is a new field —
the LLM generates an ≤8-word descriptive title per segment, which the
orchestrator overrides on seg.section_title (replacing the generic
'Segment 3 — 4:25' default).
main.py: four new Form() bools (llm_alt_text/key_terms/math_equations/
section_title) plumbed into PipelineInputs.llm_toggles on both /jobs
and the legacy /process endpoint.
index.html: full redesign. Two-column hero with a polished form card +
side panel of features/tips. Drop-zone file inputs that show name,
size, video duration/resolution, transcript cue count + first cue
after selection. Output formats render as radio cards with
description copy. AI-assist section pairs the API key with four
toggle cards (one per LLM feature) so users can see what each costs
and turn off what they don't want. Tuning sliders moved into a
collapsed Advanced disclosure to reduce visual noise. Progress panel
gets a stage-pill row showing the pipeline phases as they advance.
Color palette + typography match the editor's maroon-and-serif look.
- app/main.py +21 -0
- app/pipeline/llm_extract.py +113 -43
- app/pipeline/orchestrator.py +22 -8
- app/templates/index.html +740 -276
|
@@ -17,6 +17,7 @@ from fastapi.templating import Jinja2Templates
|
|
| 17 |
|
| 18 |
from .jobs import Job, JobResult, registry
|
| 19 |
from .pipeline import bundle_zip, render_guide, render_review
|
|
|
|
| 20 |
from .pipeline.orchestrator import (
|
| 21 |
PipelineError,
|
| 22 |
PipelineInputs,
|
|
@@ -175,6 +176,10 @@ async def start_job(
|
|
| 175 |
subtitle: str | None = Form(None),
|
| 176 |
module: str | None = Form(None),
|
| 177 |
anthropic_api_key: str | None = Form(None),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
) -> JSONResponse:
|
| 179 |
video_suffix = Path(video.filename or "").suffix.lower()
|
| 180 |
transcript_suffix = Path(transcript.filename or "").suffix.lower()
|
|
@@ -207,6 +212,12 @@ async def start_job(
|
|
| 207 |
face_threshold=face_threshold,
|
| 208 |
inline_images=(format in ("single", "review")),
|
| 209 |
anthropic_api_key=(anthropic_api_key or None),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
)
|
| 211 |
|
| 212 |
job = registry.create()
|
|
@@ -325,6 +336,10 @@ async def process(
|
|
| 325 |
subtitle: str | None = Form(None),
|
| 326 |
module: str | None = Form(None),
|
| 327 |
anthropic_api_key: str | None = Form(None),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
) -> Response:
|
| 329 |
video_suffix = Path(video.filename or "").suffix.lower()
|
| 330 |
transcript_suffix = Path(transcript.filename or "").suffix.lower()
|
|
@@ -358,6 +373,12 @@ async def process(
|
|
| 358 |
face_threshold=face_threshold,
|
| 359 |
inline_images=(format in ("single", "review")),
|
| 360 |
anthropic_api_key=(anthropic_api_key or None),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
)
|
| 362 |
try:
|
| 363 |
result = run_pipeline(inputs)
|
|
|
|
| 17 |
|
| 18 |
from .jobs import Job, JobResult, registry
|
| 19 |
from .pipeline import bundle_zip, render_guide, render_review
|
| 20 |
+
from .pipeline.llm_extract import LLMToggles
|
| 21 |
from .pipeline.orchestrator import (
|
| 22 |
PipelineError,
|
| 23 |
PipelineInputs,
|
|
|
|
| 176 |
subtitle: str | None = Form(None),
|
| 177 |
module: str | None = Form(None),
|
| 178 |
anthropic_api_key: str | None = Form(None),
|
| 179 |
+
llm_alt_text: bool = Form(True),
|
| 180 |
+
llm_key_terms: bool = Form(True),
|
| 181 |
+
llm_math_equations: bool = Form(True),
|
| 182 |
+
llm_section_title: bool = Form(True),
|
| 183 |
) -> JSONResponse:
|
| 184 |
video_suffix = Path(video.filename or "").suffix.lower()
|
| 185 |
transcript_suffix = Path(transcript.filename or "").suffix.lower()
|
|
|
|
| 212 |
face_threshold=face_threshold,
|
| 213 |
inline_images=(format in ("single", "review")),
|
| 214 |
anthropic_api_key=(anthropic_api_key or None),
|
| 215 |
+
llm_toggles=LLMToggles(
|
| 216 |
+
alt_text=llm_alt_text,
|
| 217 |
+
key_terms=llm_key_terms,
|
| 218 |
+
math_equations=llm_math_equations,
|
| 219 |
+
section_title=llm_section_title,
|
| 220 |
+
),
|
| 221 |
)
|
| 222 |
|
| 223 |
job = registry.create()
|
|
|
|
| 336 |
subtitle: str | None = Form(None),
|
| 337 |
module: str | None = Form(None),
|
| 338 |
anthropic_api_key: str | None = Form(None),
|
| 339 |
+
llm_alt_text: bool = Form(True),
|
| 340 |
+
llm_key_terms: bool = Form(True),
|
| 341 |
+
llm_math_equations: bool = Form(True),
|
| 342 |
+
llm_section_title: bool = Form(True),
|
| 343 |
) -> Response:
|
| 344 |
video_suffix = Path(video.filename or "").suffix.lower()
|
| 345 |
transcript_suffix = Path(transcript.filename or "").suffix.lower()
|
|
|
|
| 373 |
face_threshold=face_threshold,
|
| 374 |
inline_images=(format in ("single", "review")),
|
| 375 |
anthropic_api_key=(anthropic_api_key or None),
|
| 376 |
+
llm_toggles=LLMToggles(
|
| 377 |
+
alt_text=llm_alt_text,
|
| 378 |
+
key_terms=llm_key_terms,
|
| 379 |
+
math_equations=llm_math_equations,
|
| 380 |
+
section_title=llm_section_title,
|
| 381 |
+
),
|
| 382 |
)
|
| 383 |
try:
|
| 384 |
result = run_pipeline(inputs)
|
|
@@ -18,7 +18,7 @@ from dataclasses import dataclass
|
|
| 18 |
from pathlib import Path
|
| 19 |
from typing import Callable
|
| 20 |
|
| 21 |
-
from pydantic import BaseModel
|
| 22 |
|
| 23 |
from .metadata import KeyTerm, MathEquation
|
| 24 |
|
|
@@ -28,36 +28,78 @@ DEFAULT_MODEL = "claude-opus-4-7"
|
|
| 28 |
DEFAULT_MAX_CONCURRENCY = 4
|
| 29 |
_API_KEY_ENV = "ANTHROPIC_API_KEY"
|
| 30 |
|
| 31 |
-
# System prompt is byte-stable across all segments in a run, so prefix caching
|
| 32 |
-
# kicks in after the first call. Keep dynamic content out of this string.
|
| 33 |
-
_SYSTEM_PROMPT = """You analyze single frames from instructional video lectures and return structured JSON.
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
Example good: "Title slide introducing the section on combining specialized AI models into systems
|
| 41 |
-
that go beyond a single monolithic model."
|
| 42 |
-
- One or two sentences, ≤200 characters. Plain prose, no markdown, no leading "Image of"/"Slide showing".
|
| 43 |
-
- If the frame is purely an instructor talking-head with no slide content, say so plainly
|
| 44 |
-
(e.g. "Instructor speaking to camera; no slide content on screen.").
|
| 45 |
-
- Never invent details that aren't visible in the frame or supported by the narration.
|
| 46 |
|
| 47 |
-
2. key_terms — terms or named concepts that the lecturer is teaching in THIS segment.
|
| 48 |
-
- Include only terms a student should remember or that are defined here.
|
| 49 |
-
- Keep definitions concise (one sentence, ≤25 words). Plain prose, no markdown.
|
| 50 |
-
- Skip generic English vocabulary, slide chrome, or section labels (e.g. "Outline", "Agenda").
|
| 51 |
-
- Empty list if nothing on this slide rises to the bar.
|
| 52 |
|
| 53 |
-
|
| 54 |
-
- latex: a clean LaTeX expression suitable for MathJax (no $ delimiters; no \\begin{equation}).
|
| 55 |
-
- aria_label: a plain-English screen-reader description of the equation.
|
| 56 |
-
- Skip equations that are only spoken, not on screen.
|
| 57 |
-
- Skip simple inline labels like axis ticks or single numbers.
|
| 58 |
-
- Empty list if the slide has no displayed equation.
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
class _ExtractedKeyTerm(BaseModel):
|
|
@@ -70,20 +112,37 @@ class _ExtractedMathEquation(BaseModel):
|
|
| 70 |
aria_label: str
|
| 71 |
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
@dataclass
|
| 80 |
class ExtractionResult:
|
| 81 |
-
alt_text: str
|
| 82 |
-
key_terms: list[KeyTerm]
|
| 83 |
-
math_equations: list[MathEquation]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
-
_EMPTY = ExtractionResult(
|
| 87 |
|
| 88 |
|
| 89 |
def _resolve_api_key(api_key: str | None) -> str | None:
|
|
@@ -148,12 +207,16 @@ def extract_one(
|
|
| 148 |
*,
|
| 149 |
model: str = DEFAULT_MODEL,
|
| 150 |
api_key: str | None = None,
|
|
|
|
| 151 |
) -> ExtractionResult:
|
| 152 |
-
"""Extract
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
|
|
|
| 156 |
"""
|
|
|
|
|
|
|
| 157 |
resolved = _resolve_api_key(api_key)
|
| 158 |
if resolved is None:
|
| 159 |
return _EMPTY
|
|
@@ -165,7 +228,7 @@ def extract_one(
|
|
| 165 |
system=[
|
| 166 |
{
|
| 167 |
"type": "text",
|
| 168 |
-
"text":
|
| 169 |
"cache_control": {"type": "ephemeral"},
|
| 170 |
}
|
| 171 |
],
|
|
@@ -175,17 +238,22 @@ def extract_one(
|
|
| 175 |
"content": _build_user_content(image_path, narration, ocr_text),
|
| 176 |
}
|
| 177 |
],
|
| 178 |
-
output_format=
|
| 179 |
)
|
| 180 |
parsed = response.parsed_output
|
| 181 |
if parsed is None:
|
| 182 |
log.warning("LLM extraction returned no parsed output for %s", image_path.name)
|
| 183 |
return _EMPTY
|
| 184 |
return ExtractionResult(
|
| 185 |
-
alt_text=parsed
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
math_equations=[
|
| 188 |
-
MathEquation(latex=m.latex, aria_label=m.aria_label)
|
|
|
|
| 189 |
],
|
| 190 |
)
|
| 191 |
except Exception as exc: # pragma: no cover (network-dependent)
|
|
@@ -202,6 +270,7 @@ def extract_all(
|
|
| 202 |
max_workers: int = DEFAULT_MAX_CONCURRENCY,
|
| 203 |
on_progress: Callable[[int, int], None] | None = None,
|
| 204 |
api_key: str | None = None,
|
|
|
|
| 205 |
) -> list[ExtractionResult]:
|
| 206 |
"""Run extract_one across all segments in parallel, preserving input order.
|
| 207 |
|
|
@@ -211,7 +280,7 @@ def extract_all(
|
|
| 211 |
"""
|
| 212 |
n = len(image_paths)
|
| 213 |
results: list[ExtractionResult] = [_EMPTY] * n
|
| 214 |
-
if n == 0 or not is_enabled(api_key):
|
| 215 |
if on_progress:
|
| 216 |
on_progress(n, n)
|
| 217 |
return results
|
|
@@ -227,6 +296,7 @@ def extract_all(
|
|
| 227 |
ocr_texts[i] if i < len(ocr_texts) else "",
|
| 228 |
model=model,
|
| 229 |
api_key=api_key,
|
|
|
|
| 230 |
): i
|
| 231 |
for i in range(n)
|
| 232 |
}
|
|
|
|
| 18 |
from pathlib import Path
|
| 19 |
from typing import Callable
|
| 20 |
|
| 21 |
+
from pydantic import BaseModel, create_model
|
| 22 |
|
| 23 |
from .metadata import KeyTerm, MathEquation
|
| 24 |
|
|
|
|
| 28 |
DEFAULT_MAX_CONCURRENCY = 4
|
| 29 |
_API_KEY_ENV = "ANTHROPIC_API_KEY"
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
@dataclass(frozen=True)
|
| 33 |
+
class LLMToggles:
|
| 34 |
+
"""Per-feature opt-in flags. Disabling any one drops it from the LLM
|
| 35 |
+
request schema and prompt so the user is not billed for output tokens
|
| 36 |
+
they'd discard. Disabling all of them skips the LLM call entirely.
|
| 37 |
+
"""
|
| 38 |
+
alt_text: bool = True
|
| 39 |
+
key_terms: bool = True
|
| 40 |
+
math_equations: bool = True
|
| 41 |
+
section_title: bool = True
|
| 42 |
|
| 43 |
+
@property
|
| 44 |
+
def any_enabled(self) -> bool:
|
| 45 |
+
return any((self.alt_text, self.key_terms, self.math_equations, self.section_title))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
_DEFAULT_TOGGLES = LLMToggles()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
# System prompt is byte-stable across all segments in a run, so prefix caching
|
| 51 |
+
# kicks in after the first call. Keep dynamic content out of this string.
|
| 52 |
+
_FIELD_PROMPTS = {
|
| 53 |
+
"section_title": (
|
| 54 |
+
"section_title — a short, descriptive title for this segment (≤8 words). "
|
| 55 |
+
"Capture the main idea, not the slide chrome. Sentence case, no trailing punctuation."
|
| 56 |
+
),
|
| 57 |
+
"alt_text": (
|
| 58 |
+
"alt_text — a WCAG-grade alt-text draft for the frame.\n"
|
| 59 |
+
" - Convey the PURPOSE of the visual in the lecture's argument, not a transcription "
|
| 60 |
+
"of slide text. Bad: \"Slide containing 'Combining AI models'.\" "
|
| 61 |
+
"Good: \"Title slide introducing the section on combining specialized AI models.\"\n"
|
| 62 |
+
" - One or two sentences, ≤200 characters. Plain prose, no markdown, no leading "
|
| 63 |
+
"\"Image of\"/\"Slide showing\".\n"
|
| 64 |
+
" - If the frame is purely an instructor talking-head with no slide content, say so plainly.\n"
|
| 65 |
+
" - Never invent details that aren't visible in the frame or supported by the narration."
|
| 66 |
+
),
|
| 67 |
+
"key_terms": (
|
| 68 |
+
"key_terms — terms or named concepts that the lecturer is teaching in THIS segment.\n"
|
| 69 |
+
" - Include only terms a student should remember or that are defined here.\n"
|
| 70 |
+
" - Keep definitions concise (one sentence, ≤25 words). Plain prose, no markdown.\n"
|
| 71 |
+
" - Skip generic English vocabulary or section labels (\"Outline\", \"Agenda\").\n"
|
| 72 |
+
" - Empty list if nothing on this slide rises to the bar."
|
| 73 |
+
),
|
| 74 |
+
"math_equations": (
|
| 75 |
+
"math_equations — equations VISIBLY DISPLAYED on the slide.\n"
|
| 76 |
+
" - latex: a clean LaTeX expression suitable for MathJax (no $ delimiters; "
|
| 77 |
+
"no \\begin{equation}).\n"
|
| 78 |
+
" - aria_label: a plain-English screen-reader description of the equation.\n"
|
| 79 |
+
" - Skip equations that are only spoken, not on screen, or simple inline labels.\n"
|
| 80 |
+
" - Empty list if the slide has no displayed equation."
|
| 81 |
+
),
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
_SYSTEM_PREAMBLE = (
|
| 85 |
+
"You analyze single frames from instructional video lectures and return structured JSON.\n\n"
|
| 86 |
+
"For each frame you receive together with the spoken narration that accompanies it, extract:\n\n"
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
_SYSTEM_POSTAMBLE = (
|
| 90 |
+
"\n\nReturn ONLY the structured fields. Do not invent content that isn't on the slide "
|
| 91 |
+
"or in the narration."
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def _build_system_prompt(toggles: LLMToggles) -> str:
|
| 96 |
+
parts = []
|
| 97 |
+
n = 1
|
| 98 |
+
for key in ("section_title", "alt_text", "key_terms", "math_equations"):
|
| 99 |
+
if getattr(toggles, key):
|
| 100 |
+
parts.append(f"{n}. {_FIELD_PROMPTS[key]}")
|
| 101 |
+
n += 1
|
| 102 |
+
return _SYSTEM_PREAMBLE + "\n\n".join(parts) + _SYSTEM_POSTAMBLE
|
| 103 |
|
| 104 |
|
| 105 |
class _ExtractedKeyTerm(BaseModel):
|
|
|
|
| 112 |
aria_label: str
|
| 113 |
|
| 114 |
|
| 115 |
+
def _build_extraction_model(toggles: LLMToggles):
|
| 116 |
+
"""Pydantic model whose fields match the enabled toggles, so the LLM
|
| 117 |
+
schema only requests fields we'll actually use.
|
| 118 |
+
"""
|
| 119 |
+
fields: dict = {}
|
| 120 |
+
if toggles.section_title:
|
| 121 |
+
fields["section_title"] = (str, ...)
|
| 122 |
+
if toggles.alt_text:
|
| 123 |
+
fields["alt_text"] = (str, ...)
|
| 124 |
+
if toggles.key_terms:
|
| 125 |
+
fields["key_terms"] = (list[_ExtractedKeyTerm], ...)
|
| 126 |
+
if toggles.math_equations:
|
| 127 |
+
fields["math_equations"] = (list[_ExtractedMathEquation], ...)
|
| 128 |
+
return create_model("_SegmentExtraction", **fields)
|
| 129 |
|
| 130 |
|
| 131 |
@dataclass
|
| 132 |
class ExtractionResult:
|
| 133 |
+
alt_text: str = ""
|
| 134 |
+
key_terms: list[KeyTerm] = None # type: ignore[assignment]
|
| 135 |
+
math_equations: list[MathEquation] = None # type: ignore[assignment]
|
| 136 |
+
section_title: str = ""
|
| 137 |
+
|
| 138 |
+
def __post_init__(self) -> None:
|
| 139 |
+
if self.key_terms is None:
|
| 140 |
+
self.key_terms = []
|
| 141 |
+
if self.math_equations is None:
|
| 142 |
+
self.math_equations = []
|
| 143 |
|
| 144 |
|
| 145 |
+
_EMPTY = ExtractionResult()
|
| 146 |
|
| 147 |
|
| 148 |
def _resolve_api_key(api_key: str | None) -> str | None:
|
|
|
|
| 207 |
*,
|
| 208 |
model: str = DEFAULT_MODEL,
|
| 209 |
api_key: str | None = None,
|
| 210 |
+
toggles: LLMToggles = _DEFAULT_TOGGLES,
|
| 211 |
) -> ExtractionResult:
|
| 212 |
+
"""Extract enabled fields for a single segment. Empty on any failure.
|
| 213 |
|
| 214 |
+
Disabled toggles are dropped from both the prompt and the response schema
|
| 215 |
+
so we don't pay for tokens we'd discard. Any per-segment failure logs a
|
| 216 |
+
warning and returns _EMPTY — never aborts the pipeline.
|
| 217 |
"""
|
| 218 |
+
if not toggles.any_enabled:
|
| 219 |
+
return _EMPTY
|
| 220 |
resolved = _resolve_api_key(api_key)
|
| 221 |
if resolved is None:
|
| 222 |
return _EMPTY
|
|
|
|
| 228 |
system=[
|
| 229 |
{
|
| 230 |
"type": "text",
|
| 231 |
+
"text": _build_system_prompt(toggles),
|
| 232 |
"cache_control": {"type": "ephemeral"},
|
| 233 |
}
|
| 234 |
],
|
|
|
|
| 238 |
"content": _build_user_content(image_path, narration, ocr_text),
|
| 239 |
}
|
| 240 |
],
|
| 241 |
+
output_format=_build_extraction_model(toggles),
|
| 242 |
)
|
| 243 |
parsed = response.parsed_output
|
| 244 |
if parsed is None:
|
| 245 |
log.warning("LLM extraction returned no parsed output for %s", image_path.name)
|
| 246 |
return _EMPTY
|
| 247 |
return ExtractionResult(
|
| 248 |
+
alt_text=getattr(parsed, "alt_text", "") or "",
|
| 249 |
+
section_title=getattr(parsed, "section_title", "") or "",
|
| 250 |
+
key_terms=[
|
| 251 |
+
KeyTerm(term=k.term, definition=k.definition)
|
| 252 |
+
for k in getattr(parsed, "key_terms", []) or []
|
| 253 |
+
],
|
| 254 |
math_equations=[
|
| 255 |
+
MathEquation(latex=m.latex, aria_label=m.aria_label)
|
| 256 |
+
for m in getattr(parsed, "math_equations", []) or []
|
| 257 |
],
|
| 258 |
)
|
| 259 |
except Exception as exc: # pragma: no cover (network-dependent)
|
|
|
|
| 270 |
max_workers: int = DEFAULT_MAX_CONCURRENCY,
|
| 271 |
on_progress: Callable[[int, int], None] | None = None,
|
| 272 |
api_key: str | None = None,
|
| 273 |
+
toggles: LLMToggles = _DEFAULT_TOGGLES,
|
| 274 |
) -> list[ExtractionResult]:
|
| 275 |
"""Run extract_one across all segments in parallel, preserving input order.
|
| 276 |
|
|
|
|
| 280 |
"""
|
| 281 |
n = len(image_paths)
|
| 282 |
results: list[ExtractionResult] = [_EMPTY] * n
|
| 283 |
+
if n == 0 or not is_enabled(api_key) or not toggles.any_enabled:
|
| 284 |
if on_progress:
|
| 285 |
on_progress(n, n)
|
| 286 |
return results
|
|
|
|
| 296 |
ocr_texts[i] if i < len(ocr_texts) else "",
|
| 297 |
model=model,
|
| 298 |
api_key=api_key,
|
| 299 |
+
toggles=toggles,
|
| 300 |
): i
|
| 301 |
for i in range(n)
|
| 302 |
}
|
|
@@ -13,7 +13,7 @@ from pathlib import Path
|
|
| 13 |
from typing import Callable
|
| 14 |
|
| 15 |
from .filter import filter_instructor_frames
|
| 16 |
-
from .llm_extract import extract_all, is_enabled as llm_enabled
|
| 17 |
from .metadata import PageMetadata, SourceInfo, page_metadata_from_segments
|
| 18 |
from .ocr import ocr_frame
|
| 19 |
from .scenes import detect_and_extract
|
|
@@ -54,6 +54,7 @@ class PipelineInputs:
|
|
| 54 |
inline_images: bool = False
|
| 55 |
# Per-job credential for LLM extraction; never logged or persisted.
|
| 56 |
anthropic_api_key: str | None = field(default=None, repr=False)
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
@dataclass
|
|
@@ -143,14 +144,22 @@ def run_pipeline(
|
|
| 143 |
pct = 65 + ((i + 1) / max(n, 1)) * 30
|
| 144 |
_emit(pct, "ocr", f"OCR frame {i + 1}/{n}")
|
| 145 |
|
| 146 |
-
if llm_enabled(inputs.anthropic_api_key):
|
| 147 |
n = len(kept)
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
def _llm_progress(done: int, total: int) -> None:
|
| 152 |
pct = 80 + (done / max(total, 1)) * 15
|
| 153 |
-
_emit(pct, "llm_extract", f"
|
| 154 |
|
| 155 |
extractions = extract_all(
|
| 156 |
[f.image_path for f in kept],
|
|
@@ -158,6 +167,7 @@ def run_pipeline(
|
|
| 158 |
ocr_texts,
|
| 159 |
on_progress=_llm_progress,
|
| 160 |
api_key=inputs.anthropic_api_key,
|
|
|
|
| 161 |
)
|
| 162 |
else:
|
| 163 |
extractions = None
|
|
@@ -166,10 +176,14 @@ def run_pipeline(
|
|
| 166 |
segments = build_segments(kept, narrations, ocr_texts, inline_images=inputs.inline_images)
|
| 167 |
if extractions is not None:
|
| 168 |
for seg, extracted in zip(segments, extractions):
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
if
|
|
|
|
|
|
|
| 172 |
seg.alt_draft = extracted.alt_text
|
|
|
|
|
|
|
| 173 |
|
| 174 |
page = page_metadata_from_segments(
|
| 175 |
title=inputs.title,
|
|
|
|
| 13 |
from typing import Callable
|
| 14 |
|
| 15 |
from .filter import filter_instructor_frames
|
| 16 |
+
from .llm_extract import LLMToggles, extract_all, is_enabled as llm_enabled
|
| 17 |
from .metadata import PageMetadata, SourceInfo, page_metadata_from_segments
|
| 18 |
from .ocr import ocr_frame
|
| 19 |
from .scenes import detect_and_extract
|
|
|
|
| 54 |
inline_images: bool = False
|
| 55 |
# Per-job credential for LLM extraction; never logged or persisted.
|
| 56 |
anthropic_api_key: str | None = field(default=None, repr=False)
|
| 57 |
+
llm_toggles: LLMToggles = field(default_factory=LLMToggles)
|
| 58 |
|
| 59 |
|
| 60 |
@dataclass
|
|
|
|
| 144 |
pct = 65 + ((i + 1) / max(n, 1)) * 30
|
| 145 |
_emit(pct, "ocr", f"OCR frame {i + 1}/{n}")
|
| 146 |
|
| 147 |
+
if llm_enabled(inputs.anthropic_api_key) and inputs.llm_toggles.any_enabled:
|
| 148 |
n = len(kept)
|
| 149 |
+
enabled_names = [
|
| 150 |
+
name for name, on in [
|
| 151 |
+
("titles", inputs.llm_toggles.section_title),
|
| 152 |
+
("alt-text", inputs.llm_toggles.alt_text),
|
| 153 |
+
("key terms", inputs.llm_toggles.key_terms),
|
| 154 |
+
("equations", inputs.llm_toggles.math_equations),
|
| 155 |
+
] if on
|
| 156 |
+
]
|
| 157 |
+
log.info("Running LLM extraction on %d frames (%s)", n, ", ".join(enabled_names))
|
| 158 |
+
_emit(80, "llm_extract", f"Extracting {', '.join(enabled_names)} ({n} frames)...")
|
| 159 |
|
| 160 |
def _llm_progress(done: int, total: int) -> None:
|
| 161 |
pct = 80 + (done / max(total, 1)) * 15
|
| 162 |
+
_emit(pct, "llm_extract", f"LLM extraction {done}/{total}")
|
| 163 |
|
| 164 |
extractions = extract_all(
|
| 165 |
[f.image_path for f in kept],
|
|
|
|
| 167 |
ocr_texts,
|
| 168 |
on_progress=_llm_progress,
|
| 169 |
api_key=inputs.anthropic_api_key,
|
| 170 |
+
toggles=inputs.llm_toggles,
|
| 171 |
)
|
| 172 |
else:
|
| 173 |
extractions = None
|
|
|
|
| 176 |
segments = build_segments(kept, narrations, ocr_texts, inline_images=inputs.inline_images)
|
| 177 |
if extractions is not None:
|
| 178 |
for seg, extracted in zip(segments, extractions):
|
| 179 |
+
if inputs.llm_toggles.key_terms:
|
| 180 |
+
seg.key_terms = list(extracted.key_terms)
|
| 181 |
+
if inputs.llm_toggles.math_equations:
|
| 182 |
+
seg.math_equations = list(extracted.math_equations)
|
| 183 |
+
if inputs.llm_toggles.alt_text and extracted.alt_text:
|
| 184 |
seg.alt_draft = extracted.alt_text
|
| 185 |
+
if inputs.llm_toggles.section_title and extracted.section_title:
|
| 186 |
+
seg.section_title = extracted.section_title
|
| 187 |
|
| 188 |
page = page_metadata_from_segments(
|
| 189 |
title=inputs.title,
|
|
@@ -3,344 +3,718 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
-
<title>
|
| 7 |
-
<link rel="
|
|
|
|
|
|
|
| 8 |
<style>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
-
.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
display: inline-block;
|
| 32 |
font-size: 0.75rem;
|
| 33 |
font-weight: 700;
|
| 34 |
text-transform: uppercase;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
letter-spacing: 0.08em;
|
| 36 |
-
color:
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
border-radius: 3px;
|
| 40 |
-
margin-right: 0.4rem;
|
| 41 |
-
vertical-align: middle;
|
| 42 |
}
|
| 43 |
-
.vgm-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
| 46 |
}
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
font-family:
|
| 56 |
-
font-size:
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
| 62 |
}
|
| 63 |
-
.vgm-
|
| 64 |
-
.vgm-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
cursor: pointer;
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
-
.vgm-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
display: none;
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
flex-direction: column;
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
-
.vgm-
|
| 85 |
-
.vgm-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
display: flex;
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
padding: 0.
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
| 95 |
}
|
| 96 |
-
.vgm-
|
| 97 |
-
.vgm-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
color: #fff;
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
font-size:
|
|
|
|
|
|
|
| 104 |
cursor: pointer;
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
-
.vgm-
|
| 107 |
-
.vgm-
|
| 108 |
-
.vgm-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
border: 0;
|
|
|
|
| 112 |
}
|
| 113 |
-
.vgm-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
.vgm-tune {
|
| 120 |
-
margin: 0.
|
| 121 |
-
padding-bottom: 0.
|
| 122 |
-
border-bottom: 1px solid
|
| 123 |
}
|
| 124 |
.vgm-tune:last-of-type { border-bottom: 0; }
|
| 125 |
.vgm-tune__head {
|
| 126 |
-
display: flex;
|
| 127 |
-
|
| 128 |
-
justify-content: space-between;
|
| 129 |
-
gap: 0.6rem;
|
| 130 |
-
margin-bottom: 0.25rem;
|
| 131 |
-
}
|
| 132 |
-
.vgm-tune__head label {
|
| 133 |
-
font-weight: 600;
|
| 134 |
-
font-size: 0.95rem;
|
| 135 |
}
|
|
|
|
| 136 |
.vgm-tune__value {
|
| 137 |
-
font-family:
|
| 138 |
-
font-size: 0.
|
| 139 |
-
color:
|
| 140 |
-
background:
|
| 141 |
padding: 0.1rem 0.5rem;
|
| 142 |
border-radius: 4px;
|
| 143 |
min-width: 4ch;
|
| 144 |
text-align: center;
|
| 145 |
}
|
| 146 |
-
.vgm-tune input[type="range"] {
|
| 147 |
-
width: 100%;
|
| 148 |
-
accent-color: #750014;
|
| 149 |
-
margin: 0.15rem 0;
|
| 150 |
-
}
|
| 151 |
.vgm-tune input[type="range"]:disabled { opacity: 0.45; }
|
| 152 |
.vgm-tune__anchors {
|
| 153 |
-
display: flex;
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
color: #777;
|
| 157 |
-
letter-spacing: 0.02em;
|
| 158 |
-
text-transform: uppercase;
|
| 159 |
margin-top: -0.1rem;
|
| 160 |
}
|
| 161 |
.vgm-tune__help {
|
| 162 |
-
display: block;
|
| 163 |
-
|
| 164 |
-
font-size: 0.82rem;
|
| 165 |
-
color: #555;
|
| 166 |
-
line-height: 1.4;
|
| 167 |
}
|
| 168 |
.vgm-tune__toggle {
|
| 169 |
-
display: inline-flex;
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
}
|
|
|
|
|
|
|
|
|
|
| 175 |
</style>
|
| 176 |
</head>
|
| 177 |
<body>
|
| 178 |
<a class="skip-link" href="#main">Skip to main content</a>
|
| 179 |
-
<header role="banner">
|
| 180 |
-
<h1>VideoGuideMaker</h1>
|
| 181 |
-
<p>Generate WCAG-ready HTML study guides from instructional videos.</p>
|
| 182 |
-
</header>
|
| 183 |
|
| 184 |
-
<
|
| 185 |
-
|
| 186 |
-
<
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
<div class="vgm-progress" data-state="idle" role="status" aria-live="polite" aria-atomic="true">
|
| 190 |
-
<h2>Generating study guide…</h2>
|
| 191 |
<progress max="100" value="0"></progress>
|
| 192 |
<p class="vgm-progress__msg">
|
| 193 |
<span class="vgm-progress__stage">starting</span>
|
| 194 |
<span class="vgm-progress__text">Uploading…</span>
|
| 195 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
<pre class="vgm-progress__details" aria-label="Error details"></pre>
|
| 197 |
<button type="button" class="vgm-progress__retry">Try again</button>
|
| 198 |
</div>
|
| 199 |
|
| 200 |
-
<
|
| 201 |
-
<h2 id="form-heading">Upload video and transcript</h2>
|
| 202 |
|
| 203 |
-
<
|
| 204 |
-
<
|
| 205 |
-
<input type="text" id="title" name="title" value="Lecture Study Guide" required>
|
| 206 |
-
</div>
|
| 207 |
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
<input type="file" id="video" name="video" accept="video/*" required>
|
| 211 |
-
</div>
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
<input type="password" id="anthropic_api_key" name="anthropic_api_key"
|
| 229 |
-
autocomplete="off" spellcheck="false"
|
| 230 |
-
placeholder="sk-ant-..."
|
| 231 |
-
aria-describedby="anthropic_api_key_help">
|
| 232 |
-
<small id="anthropic_api_key_help" class="vgm-apikey-help">
|
| 233 |
-
Used once for this run to extract key terms and on-screen equations as LaTeX.
|
| 234 |
-
Sent to Anthropic over HTTPS, held in memory only, never written to disk or logs.
|
| 235 |
-
Leave blank to skip — the rest of the pipeline still runs.
|
| 236 |
-
</small>
|
| 237 |
-
</fieldset>
|
| 238 |
-
|
| 239 |
-
<fieldset>
|
| 240 |
-
<legend>Tuning</legend>
|
| 241 |
-
|
| 242 |
-
<div class="vgm-tune">
|
| 243 |
-
<div class="vgm-tune__head">
|
| 244 |
-
<label for="threshold">Scene-change sensitivity</label>
|
| 245 |
-
<output for="threshold" class="vgm-tune__value">27</output>
|
| 246 |
</div>
|
| 247 |
-
<input type="range" id="threshold" name="threshold" value="27" min="5" max="60" step="1">
|
| 248 |
-
<div class="vgm-tune__anchors"><span>More scenes</span><span>Fewer scenes</span></div>
|
| 249 |
-
<small class="vgm-tune__help">
|
| 250 |
-
How visually different two frames must be before they count as a new scene.
|
| 251 |
-
Lower (5–15) catches every animation step; higher (35+) only major slide changes.
|
| 252 |
-
Default 27 works for most lecture decks.
|
| 253 |
-
</small>
|
| 254 |
-
</div>
|
| 255 |
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
<label
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
</div>
|
| 261 |
-
<input type="range" id="min_gap" name="min_gap" value="0" min="0" max="60" step="0.5">
|
| 262 |
-
<div class="vgm-tune__anchors"><span>Off</span><span>60 s</span></div>
|
| 263 |
-
<small class="vgm-tune__help">
|
| 264 |
-
Drop new scenes that arrive less than this many seconds after the previous kept one.
|
| 265 |
-
Useful when a slide builds up gradually — set to ~5 s to keep just the final state.
|
| 266 |
-
</small>
|
| 267 |
</div>
|
| 268 |
|
| 269 |
-
<div class="vgm-
|
| 270 |
-
<
|
| 271 |
-
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
</div>
|
| 274 |
-
<label class="vgm-tune__toggle">
|
| 275 |
-
<input type="checkbox" id="max_frames_enabled"> Cap total frames
|
| 276 |
-
</label>
|
| 277 |
-
<input type="range" id="max_frames" name="max_frames" min="1" max="200" step="1" value="50" disabled>
|
| 278 |
-
<div class="vgm-tune__anchors"><span>1</span><span>200</span></div>
|
| 279 |
-
<small class="vgm-tune__help">
|
| 280 |
-
Hard limit on the number of frames in the guide. Useful for very long lectures or
|
| 281 |
-
to bound LLM extraction cost. Frames are evenly distributed across the video.
|
| 282 |
-
</small>
|
| 283 |
</div>
|
| 284 |
|
| 285 |
-
<div class="vgm-
|
| 286 |
-
<
|
| 287 |
-
|
| 288 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
</div>
|
| 290 |
-
<input type="range" id="face_threshold" name="face_threshold" value="0.12" min="0.02" max="0.6" step="0.01">
|
| 291 |
-
<div class="vgm-tune__anchors"><span>Strict (drop more)</span><span>Lenient (keep more)</span></div>
|
| 292 |
-
<small class="vgm-tune__help">
|
| 293 |
-
Fraction of the frame a detected face must occupy before we treat it as
|
| 294 |
-
instructor-only and drop it. Lower values discard talking-head shots more
|
| 295 |
-
aggressively; raise it if your slides have a small inset webcam you want to keep.
|
| 296 |
-
</small>
|
| 297 |
</div>
|
| 298 |
|
| 299 |
-
<div class="vgm-
|
| 300 |
-
<
|
| 301 |
-
<
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
</div>
|
| 308 |
|
| 309 |
-
<div class="vgm-
|
| 310 |
-
<
|
| 311 |
-
|
| 312 |
-
<output for="lang" class="vgm-tune__value">en</output>
|
| 313 |
-
</div>
|
| 314 |
-
<input type="text" id="lang" name="lang" value="en" pattern="[a-zA-Z\-]+" maxlength="12"
|
| 315 |
-
style="width: 6rem;">
|
| 316 |
-
<small class="vgm-tune__help">
|
| 317 |
-
BCP-47 code (e.g. <code>en</code>, <code>en-US</code>, <code>fr</code>).
|
| 318 |
-
Sets the <code>lang</code> attribute on the generated HTML and selects Tesseract
|
| 319 |
-
language packs when available.
|
| 320 |
-
</small>
|
| 321 |
</div>
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
<
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
<div class="vgm-review" data-state="closed" role="dialog" aria-label="Study guide editor">
|
| 346 |
<div class="vgm-review__bar">
|
|
@@ -362,6 +736,7 @@
|
|
| 362 |
const textEl = panel.querySelector('.vgm-progress__text');
|
| 363 |
const detailsEl = panel.querySelector('.vgm-progress__details');
|
| 364 |
const retryBtn = panel.querySelector('.vgm-progress__retry');
|
|
|
|
| 365 |
const apiKeyEl = form.querySelector('#anthropic_api_key');
|
| 366 |
const titleEl = form.querySelector('#title');
|
| 367 |
const reviewEl = document.querySelector('.vgm-review');
|
|
@@ -371,6 +746,16 @@
|
|
| 371 |
const reviewOpenBtn = reviewEl.querySelector('.vgm-review__open');
|
| 372 |
let lastResultUrl = null;
|
| 373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
function openReview(resultUrl, title) {
|
| 375 |
lastResultUrl = resultUrl;
|
| 376 |
reviewTitleEl.textContent = title ? '— ' + title : '';
|
|
@@ -388,7 +773,89 @@
|
|
| 388 |
if (lastResultUrl) window.open(lastResultUrl, '_blank', 'noopener');
|
| 389 |
});
|
| 390 |
|
| 391 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
function fmtMinGap(v) { return parseFloat(v) <= 0 ? 'off' : (parseFloat(v) + ' s'); }
|
| 393 |
function fmtIdentity(v) { return v; }
|
| 394 |
const formatters = { min_gap: fmtMinGap };
|
|
@@ -400,7 +867,6 @@
|
|
| 400 |
slider.addEventListener('input', sync);
|
| 401 |
sync();
|
| 402 |
});
|
| 403 |
-
// Plain text input ('lang') gets the same readout treatment.
|
| 404 |
form.querySelectorAll('input[type="text"][id]').forEach(input => {
|
| 405 |
const out = form.querySelector('output[for="' + input.id + '"]');
|
| 406 |
if (!out) return;
|
|
@@ -409,8 +875,7 @@
|
|
| 409 |
sync();
|
| 410 |
});
|
| 411 |
|
| 412 |
-
// Max-frames
|
| 413 |
-
// is omitted from the form so the server treats it as "unlimited".
|
| 414 |
const maxFramesToggle = form.querySelector('#max_frames_enabled');
|
| 415 |
const maxFramesSlider = form.querySelector('#max_frames');
|
| 416 |
const maxFramesOut = form.querySelector('output[for="max_frames"]');
|
|
@@ -434,21 +899,21 @@
|
|
| 434 |
function setProgress(state, percent, stage, message) {
|
| 435 |
panel.setAttribute('data-state', state);
|
| 436 |
if (typeof percent === 'number') bar.value = percent;
|
| 437 |
-
if (stage)
|
|
|
|
|
|
|
|
|
|
| 438 |
if (message) textEl.textContent = message;
|
| 439 |
}
|
| 440 |
-
|
| 441 |
function showError(short, detail) {
|
| 442 |
setProgress('error', 100, 'error', short);
|
| 443 |
detailsEl.textContent = detail || '';
|
| 444 |
}
|
| 445 |
-
|
| 446 |
function resetForRetry() {
|
| 447 |
detailsEl.textContent = '';
|
| 448 |
panel.setAttribute('data-state', 'idle');
|
| 449 |
form.style.display = '';
|
| 450 |
}
|
| 451 |
-
|
| 452 |
retryBtn.addEventListener('click', resetForRetry);
|
| 453 |
|
| 454 |
function postJob(fd) {
|
|
@@ -477,8 +942,10 @@
|
|
| 477 |
const v = fd.get(k);
|
| 478 |
if (typeof v === 'string' && v.trim() === '') fd.delete(k);
|
| 479 |
});
|
| 480 |
-
//
|
| 481 |
-
|
|
|
|
|
|
|
| 482 |
if (apiKeyEl) apiKeyEl.value = '';
|
| 483 |
const submittedTitle = (titleEl && titleEl.value) || 'Study Guide';
|
| 484 |
const formatRadio = form.querySelector('input[name="format"]:checked');
|
|
@@ -500,7 +967,7 @@
|
|
| 500 |
try {
|
| 501 |
const parsed = JSON.parse(detail);
|
| 502 |
detail = parsed.detail || parsed.message || detail;
|
| 503 |
-
} catch (_) {
|
| 504 |
showError(`Server rejected the upload (HTTP ${xhr.status})`, detail);
|
| 505 |
return;
|
| 506 |
}
|
|
@@ -524,10 +991,9 @@
|
|
| 524 |
setProgress('running', data.percent, data.stage, data.message);
|
| 525 |
} else if (data.type === 'done') {
|
| 526 |
es.close();
|
| 527 |
-
setProgress('running', 100, '
|
| 528 |
if (format === 'review') {
|
| 529 |
openReview(result_url, submittedTitle);
|
| 530 |
-
// Reset the form pane so it's ready when the user clicks "Back to upload".
|
| 531 |
panel.setAttribute('data-state', 'idle');
|
| 532 |
form.style.display = '';
|
| 533 |
} else {
|
|
@@ -536,7 +1002,7 @@
|
|
| 536 |
document.body.appendChild(a);
|
| 537 |
a.click();
|
| 538 |
a.remove();
|
| 539 |
-
setProgress('running', 100, '
|
| 540 |
setTimeout(resetForRetry, 2500);
|
| 541 |
}
|
| 542 |
} else if (data.type === 'error') {
|
|
@@ -545,8 +1011,6 @@
|
|
| 545 |
}
|
| 546 |
};
|
| 547 |
es.onerror = () => {
|
| 548 |
-
// EventSource will retry automatically on transient drops; only treat
|
| 549 |
-
// as fatal when the underlying connection is closed permanently.
|
| 550 |
if (es.readyState === EventSource.CLOSED) {
|
| 551 |
showError('Lost connection to server.',
|
| 552 |
`Last progress message: ${lastStageMsg}\n` +
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Video Guide Maker</title>
|
| 7 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 10 |
<style>
|
| 11 |
+
:root {
|
| 12 |
+
--color-primary: #750014;
|
| 13 |
+
--color-primary-dark: #5a000f;
|
| 14 |
+
--color-primary-soft: #f0e3e5;
|
| 15 |
+
--color-text: #1a1a1a;
|
| 16 |
+
--color-text-muted: #555;
|
| 17 |
+
--color-text-subtle: #888;
|
| 18 |
+
--color-border: #d8d8dc;
|
| 19 |
+
--color-border-soft: #ececef;
|
| 20 |
+
--color-bg: #fafaf7;
|
| 21 |
+
--color-surface: #ffffff;
|
| 22 |
+
--color-surface-alt: #f5f1ec;
|
| 23 |
+
--color-error-bg: #fde2e2;
|
| 24 |
+
--color-error-fg: #7a0a0a;
|
| 25 |
+
--space-xs: 0.4rem;
|
| 26 |
+
--space-sm: 0.6rem;
|
| 27 |
+
--space-md: 1rem;
|
| 28 |
+
--space-lg: 1.5rem;
|
| 29 |
+
--space-xl: 2.4rem;
|
| 30 |
+
--shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.05);
|
| 31 |
+
--shadow-md: 0 2px 6px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.06);
|
| 32 |
+
--radius-sm: 6px;
|
| 33 |
+
--radius-md: 10px;
|
| 34 |
+
--font-heading: 'Fraunces', Georgia, 'Times New Roman', serif;
|
| 35 |
+
--font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 36 |
+
--font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
| 37 |
}
|
| 38 |
+
* { box-sizing: border-box; }
|
| 39 |
+
body {
|
| 40 |
+
margin: 0;
|
| 41 |
+
background: var(--color-bg);
|
| 42 |
+
color: var(--color-text);
|
| 43 |
+
font-family: var(--font-body);
|
| 44 |
+
line-height: 1.55;
|
| 45 |
+
font-size: 17px;
|
| 46 |
}
|
| 47 |
+
h1, h2, h3, h4 { font-family: var(--font-heading); letter-spacing: -0.01em; line-height: 1.2; }
|
| 48 |
+
a { color: var(--color-primary); }
|
| 49 |
+
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }
|
| 50 |
+
|
| 51 |
+
.skip-link {
|
| 52 |
+
position: absolute; left: -9999px; top: 0;
|
| 53 |
+
background: var(--color-primary); color: #fff; padding: 0.5rem 1rem; z-index: 1000;
|
| 54 |
}
|
| 55 |
+
.skip-link:focus { left: 1rem; top: 1rem; }
|
| 56 |
+
|
| 57 |
+
.vgm-page {
|
| 58 |
+
max-width: 72rem;
|
| 59 |
+
margin: 0 auto;
|
| 60 |
+
padding: 2.5rem 1.5rem;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/* HEADER */
|
| 64 |
+
.vgm-eyebrow {
|
| 65 |
display: inline-block;
|
| 66 |
font-size: 0.75rem;
|
| 67 |
font-weight: 700;
|
| 68 |
text-transform: uppercase;
|
| 69 |
+
letter-spacing: 0.12em;
|
| 70 |
+
color: var(--color-primary);
|
| 71 |
+
margin-bottom: 0.75rem;
|
| 72 |
+
}
|
| 73 |
+
h1.vgm-title {
|
| 74 |
+
font-size: clamp(2.1rem, 4vw, 3rem);
|
| 75 |
+
font-weight: 600;
|
| 76 |
+
margin: 0 0 0.5rem;
|
| 77 |
+
}
|
| 78 |
+
h1.vgm-title em { font-style: italic; color: var(--color-primary); font-weight: 500; }
|
| 79 |
+
.vgm-tagline {
|
| 80 |
+
font-size: 1.1rem;
|
| 81 |
+
color: var(--color-text-muted);
|
| 82 |
+
margin: 0 0 var(--space-xl);
|
| 83 |
+
max-width: 40rem;
|
| 84 |
+
line-height: 1.5;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* TWO-COLUMN HERO */
|
| 88 |
+
.vgm-hero {
|
| 89 |
+
display: grid;
|
| 90 |
+
grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr);
|
| 91 |
+
gap: 2rem;
|
| 92 |
+
align-items: start;
|
| 93 |
+
}
|
| 94 |
+
@media (max-width: 920px) {
|
| 95 |
+
.vgm-hero { grid-template-columns: 1fr; }
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/* CARD */
|
| 99 |
+
.vgm-card {
|
| 100 |
+
background: var(--color-surface);
|
| 101 |
+
border: 1px solid var(--color-border);
|
| 102 |
+
border-radius: var(--radius-md);
|
| 103 |
+
padding: var(--space-lg);
|
| 104 |
+
box-shadow: var(--shadow-sm);
|
| 105 |
+
}
|
| 106 |
+
.vgm-card + .vgm-card { margin-top: 1rem; }
|
| 107 |
+
|
| 108 |
+
.vgm-section { padding: var(--space-md) 0; }
|
| 109 |
+
.vgm-section + .vgm-section { border-top: 1px solid var(--color-border-soft); }
|
| 110 |
+
.vgm-section:first-child { padding-top: 0; }
|
| 111 |
+
.vgm-section:last-child { padding-bottom: 0; }
|
| 112 |
+
.vgm-section__title {
|
| 113 |
+
font-size: 0.78rem;
|
| 114 |
+
font-weight: 700;
|
| 115 |
+
text-transform: uppercase;
|
| 116 |
letter-spacing: 0.08em;
|
| 117 |
+
color: var(--color-text-muted);
|
| 118 |
+
margin: 0 0 var(--space-sm);
|
| 119 |
+
font-family: var(--font-body);
|
|
|
|
|
|
|
|
|
|
| 120 |
}
|
| 121 |
+
.vgm-section__intro {
|
| 122 |
+
margin: -0.2rem 0 0.75rem;
|
| 123 |
+
color: var(--color-text-muted);
|
| 124 |
+
font-size: 0.92rem;
|
| 125 |
}
|
| 126 |
+
|
| 127 |
+
/* INPUTS */
|
| 128 |
+
.vgm-field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: var(--space-md); }
|
| 129 |
+
.vgm-field:last-child { margin-bottom: 0; }
|
| 130 |
+
.vgm-field label { font-weight: 600; font-size: 0.92rem; }
|
| 131 |
+
.vgm-field small { font-size: 0.82rem; color: var(--color-text-muted); }
|
| 132 |
+
.vgm-card input[type="text"],
|
| 133 |
+
.vgm-card input[type="password"] {
|
| 134 |
+
font-family: inherit;
|
| 135 |
+
font-size: 1rem;
|
| 136 |
+
padding: 0.6rem 0.75rem;
|
| 137 |
+
border: 1px solid var(--color-border);
|
| 138 |
+
border-radius: var(--radius-sm);
|
| 139 |
+
background: var(--color-surface);
|
| 140 |
+
width: 100%;
|
| 141 |
+
transition: border-color 0.15s, box-shadow 0.15s;
|
| 142 |
}
|
| 143 |
+
.vgm-card input[type="text"]:focus,
|
| 144 |
+
.vgm-card input[type="password"]:focus {
|
| 145 |
+
outline: none;
|
| 146 |
+
border-color: var(--color-primary);
|
| 147 |
+
box-shadow: 0 0 0 3px var(--color-primary-soft);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/* DROP ZONES */
|
| 151 |
+
.vgm-drop {
|
| 152 |
+
position: relative;
|
| 153 |
+
display: block;
|
| 154 |
+
padding: 1.4rem 1rem;
|
| 155 |
+
border: 2px dashed var(--color-border);
|
| 156 |
+
border-radius: var(--radius-md);
|
| 157 |
+
text-align: center;
|
| 158 |
cursor: pointer;
|
| 159 |
+
transition: border-color 0.15s, background 0.15s;
|
| 160 |
+
background: var(--color-bg);
|
| 161 |
}
|
| 162 |
+
.vgm-drop:hover, .vgm-drop:focus-within {
|
| 163 |
+
border-color: var(--color-primary);
|
| 164 |
+
background: var(--color-surface-alt);
|
| 165 |
+
}
|
| 166 |
+
.vgm-drop.is-dragover {
|
| 167 |
+
border-color: var(--color-primary);
|
| 168 |
+
background: var(--color-primary-soft);
|
| 169 |
+
}
|
| 170 |
+
.vgm-drop input[type="file"] {
|
| 171 |
+
position: absolute; inset: 0;
|
| 172 |
+
width: 100%; height: 100%;
|
| 173 |
+
opacity: 0; cursor: pointer;
|
| 174 |
+
}
|
| 175 |
+
.vgm-drop__hint { font-size: 0.95rem; color: var(--color-text-muted); }
|
| 176 |
+
.vgm-drop__hint strong { color: var(--color-text); font-weight: 600; }
|
| 177 |
+
.vgm-drop__hint small { display: block; font-size: 0.8rem; color: var(--color-text-subtle); margin-top: 0.2rem; }
|
| 178 |
+
.vgm-drop__meta {
|
| 179 |
display: none;
|
| 180 |
+
font-family: var(--font-mono);
|
| 181 |
+
font-size: 0.85rem;
|
| 182 |
+
text-align: left;
|
| 183 |
+
}
|
| 184 |
+
.vgm-drop__meta strong { color: var(--color-primary); font-weight: 600; word-break: break-all; }
|
| 185 |
+
.vgm-drop__meta dl {
|
| 186 |
+
display: grid;
|
| 187 |
+
grid-template-columns: max-content 1fr;
|
| 188 |
+
gap: 0.1rem 0.5rem;
|
| 189 |
+
margin: 0.5rem 0 0;
|
| 190 |
+
font-size: 0.78rem;
|
| 191 |
+
color: var(--color-text-muted);
|
| 192 |
+
}
|
| 193 |
+
.vgm-drop__meta dt { font-weight: 600; }
|
| 194 |
+
.vgm-drop[data-loaded="true"] {
|
| 195 |
+
border-style: solid;
|
| 196 |
+
border-color: var(--color-primary);
|
| 197 |
+
background: var(--color-surface);
|
| 198 |
+
}
|
| 199 |
+
.vgm-drop[data-loaded="true"] .vgm-drop__hint { display: none; }
|
| 200 |
+
.vgm-drop[data-loaded="true"] .vgm-drop__meta { display: block; }
|
| 201 |
+
|
| 202 |
+
/* OUTPUT FORMAT */
|
| 203 |
+
.vgm-formats {
|
| 204 |
+
display: grid;
|
| 205 |
+
grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
|
| 206 |
+
gap: 0.5rem;
|
| 207 |
+
}
|
| 208 |
+
.vgm-fmt {
|
| 209 |
+
cursor: pointer;
|
| 210 |
+
padding: 0.7rem 0.85rem;
|
| 211 |
+
border: 1px solid var(--color-border);
|
| 212 |
+
border-radius: var(--radius-sm);
|
| 213 |
+
transition: border-color 0.15s, background 0.15s;
|
| 214 |
+
display: flex;
|
| 215 |
flex-direction: column;
|
| 216 |
+
gap: 0.2rem;
|
| 217 |
+
background: var(--color-surface);
|
| 218 |
}
|
| 219 |
+
.vgm-fmt:hover { border-color: var(--color-primary); }
|
| 220 |
+
.vgm-fmt:has(input:checked) {
|
| 221 |
+
border-color: var(--color-primary);
|
| 222 |
+
background: var(--color-primary-soft);
|
| 223 |
+
}
|
| 224 |
+
.vgm-fmt__head { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.93rem; }
|
| 225 |
+
.vgm-fmt small { font-size: 0.78rem; color: var(--color-text-muted); }
|
| 226 |
+
|
| 227 |
+
/* LLM TOGGLE GRID */
|
| 228 |
+
.vgm-llm-grid {
|
| 229 |
+
display: grid;
|
| 230 |
+
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
|
| 231 |
+
gap: 0.5rem;
|
| 232 |
+
margin-top: var(--space-sm);
|
| 233 |
+
}
|
| 234 |
+
.vgm-llm-toggle {
|
| 235 |
display: flex;
|
| 236 |
+
gap: 0.55rem;
|
| 237 |
+
align-items: flex-start;
|
| 238 |
+
padding: 0.6rem 0.7rem;
|
| 239 |
+
border: 1px solid var(--color-border);
|
| 240 |
+
border-radius: var(--radius-sm);
|
| 241 |
+
cursor: pointer;
|
| 242 |
+
background: var(--color-surface);
|
| 243 |
+
transition: border-color 0.15s, background 0.15s;
|
| 244 |
}
|
| 245 |
+
.vgm-llm-toggle:hover { border-color: var(--color-primary); }
|
| 246 |
+
.vgm-llm-toggle:has(input:checked) {
|
| 247 |
+
border-color: var(--color-primary);
|
| 248 |
+
background: var(--color-primary-soft);
|
| 249 |
+
}
|
| 250 |
+
.vgm-llm-toggle input { margin-top: 0.2rem; flex: 0 0 auto; accent-color: var(--color-primary); }
|
| 251 |
+
.vgm-llm-toggle__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
|
| 252 |
+
.vgm-llm-toggle strong { font-size: 0.9rem; font-weight: 600; }
|
| 253 |
+
.vgm-llm-toggle small { font-size: 0.75rem; color: var(--color-text-muted); line-height: 1.3; }
|
| 254 |
+
|
| 255 |
+
/* SUBMIT */
|
| 256 |
+
.vgm-cta {
|
| 257 |
+
display: inline-flex;
|
| 258 |
+
align-items: center;
|
| 259 |
+
gap: 0.5rem;
|
| 260 |
+
padding: 0.85rem 1.7rem;
|
| 261 |
+
background: var(--color-primary);
|
| 262 |
color: #fff;
|
| 263 |
+
font-family: inherit;
|
| 264 |
+
font-weight: 600;
|
| 265 |
+
font-size: 1.02rem;
|
| 266 |
+
border: 0;
|
| 267 |
+
border-radius: var(--radius-sm);
|
| 268 |
cursor: pointer;
|
| 269 |
+
box-shadow: var(--shadow-sm);
|
| 270 |
+
transition: background 0.15s, transform 0.05s;
|
| 271 |
}
|
| 272 |
+
.vgm-cta:hover { background: var(--color-primary-dark); }
|
| 273 |
+
.vgm-cta:active { transform: translateY(1px); }
|
| 274 |
+
.vgm-submit-row { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; margin-top: var(--space-md); }
|
| 275 |
+
.vgm-submit-row__hint { font-size: 0.82rem; color: var(--color-text-muted); }
|
| 276 |
+
|
| 277 |
+
/* SIDE PANEL */
|
| 278 |
+
.vgm-side h3 { font-size: 1.05rem; margin: 0 0 0.7rem; }
|
| 279 |
+
.vgm-feature-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.55rem; }
|
| 280 |
+
.vgm-feature-list li {
|
| 281 |
+
display: flex; gap: 0.6rem; align-items: flex-start;
|
| 282 |
+
font-size: 0.88rem; line-height: 1.45;
|
| 283 |
+
}
|
| 284 |
+
.vgm-feature-list li::before {
|
| 285 |
+
content: '';
|
| 286 |
+
flex: 0 0 0.45rem;
|
| 287 |
+
width: 0.45rem; height: 0.45rem;
|
| 288 |
+
border-radius: 50%;
|
| 289 |
+
background: var(--color-primary);
|
| 290 |
+
margin-top: 0.5rem;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
/* ADVANCED DETAILS */
|
| 294 |
+
details.vgm-advanced {
|
| 295 |
border: 0;
|
| 296 |
+
padding: 0;
|
| 297 |
}
|
| 298 |
+
details.vgm-advanced > summary {
|
| 299 |
+
list-style: none;
|
| 300 |
+
cursor: pointer;
|
| 301 |
+
display: inline-flex;
|
| 302 |
+
align-items: center;
|
| 303 |
+
gap: 0.4rem;
|
| 304 |
+
font-size: 0.84rem;
|
| 305 |
+
font-weight: 600;
|
| 306 |
+
color: var(--color-primary);
|
| 307 |
+
padding: 0.4rem 0;
|
| 308 |
}
|
| 309 |
+
details.vgm-advanced > summary::-webkit-details-marker { display: none; }
|
| 310 |
+
details.vgm-advanced > summary::before {
|
| 311 |
+
content: '+';
|
| 312 |
+
font-family: var(--font-mono);
|
| 313 |
+
font-size: 1rem;
|
| 314 |
+
width: 1rem;
|
| 315 |
+
text-align: center;
|
| 316 |
+
}
|
| 317 |
+
details.vgm-advanced[open] > summary::before { content: '−'; }
|
| 318 |
+
details.vgm-advanced > div { padding-top: var(--space-sm); }
|
| 319 |
+
|
| 320 |
+
/* TUNING SLIDERS (carried over) */
|
| 321 |
.vgm-tune {
|
| 322 |
+
margin: 0.6rem 0 1.1rem;
|
| 323 |
+
padding-bottom: 0.7rem;
|
| 324 |
+
border-bottom: 1px solid var(--color-border-soft);
|
| 325 |
}
|
| 326 |
.vgm-tune:last-of-type { border-bottom: 0; }
|
| 327 |
.vgm-tune__head {
|
| 328 |
+
display: flex; align-items: baseline; justify-content: space-between;
|
| 329 |
+
gap: 0.6rem; margin-bottom: 0.3rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
}
|
| 331 |
+
.vgm-tune__head label { font-weight: 600; font-size: 0.92rem; }
|
| 332 |
.vgm-tune__value {
|
| 333 |
+
font-family: var(--font-mono);
|
| 334 |
+
font-size: 0.85rem;
|
| 335 |
+
color: var(--color-text);
|
| 336 |
+
background: var(--color-surface-alt);
|
| 337 |
padding: 0.1rem 0.5rem;
|
| 338 |
border-radius: 4px;
|
| 339 |
min-width: 4ch;
|
| 340 |
text-align: center;
|
| 341 |
}
|
| 342 |
+
.vgm-tune input[type="range"] { width: 100%; accent-color: var(--color-primary); margin: 0.15rem 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
.vgm-tune input[type="range"]:disabled { opacity: 0.45; }
|
| 344 |
.vgm-tune__anchors {
|
| 345 |
+
display: flex; justify-content: space-between;
|
| 346 |
+
font-size: 0.72rem; color: var(--color-text-subtle);
|
| 347 |
+
letter-spacing: 0.02em; text-transform: uppercase;
|
|
|
|
|
|
|
|
|
|
| 348 |
margin-top: -0.1rem;
|
| 349 |
}
|
| 350 |
.vgm-tune__help {
|
| 351 |
+
display: block; margin-top: 0.4rem;
|
| 352 |
+
font-size: 0.82rem; color: var(--color-text-muted); line-height: 1.4;
|
|
|
|
|
|
|
|
|
|
| 353 |
}
|
| 354 |
.vgm-tune__toggle {
|
| 355 |
+
display: inline-flex; align-items: center; gap: 0.4rem;
|
| 356 |
+
font-size: 0.85rem; margin-bottom: 0.3rem;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
/* PROGRESS PANEL */
|
| 360 |
+
.vgm-progress {
|
| 361 |
+
display: none;
|
| 362 |
+
background: var(--color-surface);
|
| 363 |
+
border: 1px solid var(--color-border);
|
| 364 |
+
border-radius: var(--radius-md);
|
| 365 |
+
padding: var(--space-lg);
|
| 366 |
+
box-shadow: var(--shadow-sm);
|
| 367 |
+
margin-bottom: var(--space-lg);
|
| 368 |
+
}
|
| 369 |
+
.vgm-progress[data-state="running"], .vgm-progress[data-state="error"] { display: block; }
|
| 370 |
+
.vgm-progress h2 { font-family: var(--font-heading); font-size: 1.35rem; margin: 0 0 0.6rem; }
|
| 371 |
+
.vgm-progress progress {
|
| 372 |
+
width: 100%; height: 0.55rem;
|
| 373 |
+
accent-color: var(--color-primary);
|
| 374 |
+
border-radius: 4px;
|
| 375 |
+
}
|
| 376 |
+
.vgm-progress__msg { display: flex; gap: 0.5rem; align-items: baseline; margin-top: 0.6rem; font-size: 0.92rem; }
|
| 377 |
+
.vgm-progress__stage {
|
| 378 |
+
display: inline-block;
|
| 379 |
+
font-size: 0.7rem; font-weight: 700;
|
| 380 |
+
text-transform: uppercase; letter-spacing: 0.07em;
|
| 381 |
+
color: #fff; background: var(--color-primary);
|
| 382 |
+
padding: 0.18rem 0.55rem; border-radius: 3px;
|
| 383 |
+
}
|
| 384 |
+
.vgm-progress__text { color: var(--color-text); }
|
| 385 |
+
.vgm-progress__details {
|
| 386 |
+
display: none;
|
| 387 |
+
margin-top: 0.7rem;
|
| 388 |
+
padding: 0.6rem 0.8rem;
|
| 389 |
+
background: #fff; border: 1px solid #f5b5b5;
|
| 390 |
+
border-radius: 4px;
|
| 391 |
+
font-family: var(--font-mono);
|
| 392 |
+
font-size: 0.8rem; color: #5a0808;
|
| 393 |
+
white-space: pre-wrap; word-break: break-word;
|
| 394 |
+
max-height: 14rem; overflow: auto;
|
| 395 |
+
}
|
| 396 |
+
.vgm-progress[data-state="error"] .vgm-progress__details:not(:empty) { display: block; }
|
| 397 |
+
.vgm-progress__retry {
|
| 398 |
+
display: none;
|
| 399 |
+
margin-top: 0.7rem;
|
| 400 |
+
padding: 0.45rem 0.95rem;
|
| 401 |
+
background: var(--color-primary);
|
| 402 |
+
color: #fff; border: 0; border-radius: 4px;
|
| 403 |
+
font-family: inherit; font-size: 0.9rem; cursor: pointer;
|
| 404 |
+
}
|
| 405 |
+
.vgm-progress[data-state="error"] {
|
| 406 |
+
background: var(--color-error-bg);
|
| 407 |
+
border-color: #f5b5b5;
|
| 408 |
+
}
|
| 409 |
+
.vgm-progress[data-state="error"] .vgm-progress__retry { display: inline-block; }
|
| 410 |
+
.vgm-progress__stages {
|
| 411 |
+
display: flex; gap: 0.35rem; flex-wrap: wrap;
|
| 412 |
+
margin-top: 0.8rem; font-size: 0.72rem;
|
| 413 |
+
}
|
| 414 |
+
.vgm-progress__stages span {
|
| 415 |
+
padding: 0.2rem 0.55rem;
|
| 416 |
+
border: 1px solid var(--color-border);
|
| 417 |
+
border-radius: 999px;
|
| 418 |
+
color: var(--color-text-subtle);
|
| 419 |
+
background: var(--color-surface);
|
| 420 |
+
}
|
| 421 |
+
.vgm-progress__stages span.is-done {
|
| 422 |
+
background: var(--color-surface-alt);
|
| 423 |
+
color: var(--color-text-muted);
|
| 424 |
+
border-color: var(--color-border-soft);
|
| 425 |
+
}
|
| 426 |
+
.vgm-progress__stages span.is-active {
|
| 427 |
+
background: var(--color-primary);
|
| 428 |
+
color: #fff;
|
| 429 |
+
border-color: var(--color-primary);
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
/* REVIEW IFRAME OVERLAY */
|
| 433 |
+
.vgm-review {
|
| 434 |
+
display: none;
|
| 435 |
+
position: fixed; inset: 0;
|
| 436 |
+
background: #fff; z-index: 100;
|
| 437 |
+
flex-direction: column;
|
| 438 |
+
}
|
| 439 |
+
.vgm-review[data-state="open"] { display: flex; }
|
| 440 |
+
.vgm-review__bar {
|
| 441 |
+
flex: 0 0 auto;
|
| 442 |
+
display: flex; align-items: center; gap: 0.75rem;
|
| 443 |
+
padding: 0.5rem 1rem;
|
| 444 |
+
background: #1a1a1a; color: #fff;
|
| 445 |
+
border-bottom: 1px solid #333;
|
| 446 |
+
font-size: 0.9rem;
|
| 447 |
+
}
|
| 448 |
+
.vgm-review__bar strong { font-weight: 600; }
|
| 449 |
+
.vgm-review__bar button {
|
| 450 |
+
background: transparent; border: 1px solid #555; color: #fff;
|
| 451 |
+
padding: 0.3rem 0.7rem; border-radius: 4px;
|
| 452 |
+
font-family: inherit; font-size: 0.85rem; cursor: pointer;
|
| 453 |
}
|
| 454 |
+
.vgm-review__bar button:hover { background: #2a2a2a; }
|
| 455 |
+
.vgm-review__bar .spacer { flex: 1; }
|
| 456 |
+
.vgm-review__frame { flex: 1 1 auto; width: 100%; border: 0; }
|
| 457 |
</style>
|
| 458 |
</head>
|
| 459 |
<body>
|
| 460 |
<a class="skip-link" href="#main">Skip to main content</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
|
| 462 |
+
<div class="vgm-page" id="main" tabindex="-1">
|
| 463 |
+
|
| 464 |
+
<header>
|
| 465 |
+
<span class="vgm-eyebrow">Video Guide Maker</span>
|
| 466 |
+
<h1 class="vgm-title">Turn lectures into <em>study-ready</em> guides.</h1>
|
| 467 |
+
<p class="vgm-tagline">
|
| 468 |
+
Upload a video and its transcript. Get a WCAG-ready HTML guide with the cleanest
|
| 469 |
+
slide frames, aligned narration, and — optionally — Claude-generated section
|
| 470 |
+
titles, key terms, alt-text, and equations you can review and refine before
|
| 471 |
+
publishing.
|
| 472 |
+
</p>
|
| 473 |
+
</header>
|
| 474 |
|
| 475 |
<div class="vgm-progress" data-state="idle" role="status" aria-live="polite" aria-atomic="true">
|
| 476 |
+
<h2>Generating your study guide…</h2>
|
| 477 |
<progress max="100" value="0"></progress>
|
| 478 |
<p class="vgm-progress__msg">
|
| 479 |
<span class="vgm-progress__stage">starting</span>
|
| 480 |
<span class="vgm-progress__text">Uploading…</span>
|
| 481 |
</p>
|
| 482 |
+
<div class="vgm-progress__stages" aria-hidden="true">
|
| 483 |
+
<span data-stage="uploading">upload</span>
|
| 484 |
+
<span data-stage="scene_detect">scenes</span>
|
| 485 |
+
<span data-stage="filter">filter</span>
|
| 486 |
+
<span data-stage="transcript">transcript</span>
|
| 487 |
+
<span data-stage="ocr">ocr</span>
|
| 488 |
+
<span data-stage="llm_extract">llm</span>
|
| 489 |
+
<span data-stage="render">render</span>
|
| 490 |
+
</div>
|
| 491 |
<pre class="vgm-progress__details" aria-label="Error details"></pre>
|
| 492 |
<button type="button" class="vgm-progress__retry">Try again</button>
|
| 493 |
</div>
|
| 494 |
|
| 495 |
+
<div class="vgm-hero">
|
|
|
|
| 496 |
|
| 497 |
+
<form id="vgm-form" action="/process" method="post" enctype="multipart/form-data" class="vgm-card" aria-labelledby="form-heading">
|
| 498 |
+
<h2 id="form-heading" class="sr-only" style="position:absolute;left:-9999px;">Generate study guide</h2>
|
|
|
|
|
|
|
| 499 |
|
| 500 |
+
<div class="vgm-section">
|
| 501 |
+
<h3 class="vgm-section__title">1. Upload</h3>
|
|
|
|
|
|
|
| 502 |
|
| 503 |
+
<div class="vgm-field">
|
| 504 |
+
<label for="title">Study guide title</label>
|
| 505 |
+
<input type="text" id="title" name="title" value="Lecture Study Guide" required>
|
| 506 |
+
</div>
|
| 507 |
|
| 508 |
+
<div class="vgm-field">
|
| 509 |
+
<label for="video">Video file</label>
|
| 510 |
+
<label class="vgm-drop" data-loaded="false">
|
| 511 |
+
<input type="file" id="video" name="video" accept="video/*" required>
|
| 512 |
+
<div class="vgm-drop__hint">
|
| 513 |
+
<strong>Drop a video here</strong> or click to browse<br>
|
| 514 |
+
<small>MP4, MOV, MKV, WebM, M4V</small>
|
| 515 |
+
</div>
|
| 516 |
+
<div class="vgm-drop__meta" data-meta-for="video"></div>
|
| 517 |
+
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
|
| 520 |
+
<div class="vgm-field">
|
| 521 |
+
<label for="transcript">Transcript</label>
|
| 522 |
+
<label class="vgm-drop" data-loaded="false">
|
| 523 |
+
<input type="file" id="transcript" name="transcript" accept=".vtt,.srt,text/vtt,application/x-subrip" required>
|
| 524 |
+
<div class="vgm-drop__hint">
|
| 525 |
+
<strong>Drop a VTT or SRT file</strong> or click to browse<br>
|
| 526 |
+
<small>Cue timestamps drive segment alignment</small>
|
| 527 |
+
</div>
|
| 528 |
+
<div class="vgm-drop__meta" data-meta-for="transcript"></div>
|
| 529 |
+
</label>
|
| 530 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
</div>
|
| 532 |
|
| 533 |
+
<div class="vgm-section">
|
| 534 |
+
<h3 class="vgm-section__title">2. AI assist (optional)</h3>
|
| 535 |
+
<p class="vgm-section__intro">
|
| 536 |
+
Paste an Anthropic API key to let Claude generate the fields below. Without a key the
|
| 537 |
+
pipeline still runs — you'll just get the OCR-derived scaffold with placeholders.
|
| 538 |
+
Toggle off any feature you don't want to pay for.
|
| 539 |
+
</p>
|
| 540 |
+
|
| 541 |
+
<div class="vgm-field">
|
| 542 |
+
<label for="anthropic_api_key">Anthropic API key</label>
|
| 543 |
+
<input type="password" id="anthropic_api_key" name="anthropic_api_key"
|
| 544 |
+
autocomplete="off" spellcheck="false"
|
| 545 |
+
placeholder="sk-ant-…">
|
| 546 |
+
<small>Used once for this run. Sent over HTTPS, held in memory only, never written to disk or logs.</small>
|
| 547 |
+
</div>
|
| 548 |
+
|
| 549 |
+
<div class="vgm-llm-grid">
|
| 550 |
+
<label class="vgm-llm-toggle">
|
| 551 |
+
<input type="checkbox" name="llm_section_title" value="true" checked>
|
| 552 |
+
<span class="vgm-llm-toggle__body">
|
| 553 |
+
<strong>Section titles</strong>
|
| 554 |
+
<small>"Combining AI models" instead of "Segment 3 — 4:25"</small>
|
| 555 |
+
</span>
|
| 556 |
+
</label>
|
| 557 |
+
<label class="vgm-llm-toggle">
|
| 558 |
+
<input type="checkbox" name="llm_alt_text" value="true" checked>
|
| 559 |
+
<span class="vgm-llm-toggle__body">
|
| 560 |
+
<strong>Alt-text drafts</strong>
|
| 561 |
+
<small>WCAG-purpose descriptions, not OCR transcripts</small>
|
| 562 |
+
</span>
|
| 563 |
+
</label>
|
| 564 |
+
<label class="vgm-llm-toggle">
|
| 565 |
+
<input type="checkbox" name="llm_key_terms" value="true" checked>
|
| 566 |
+
<span class="vgm-llm-toggle__body">
|
| 567 |
+
<strong>Key terms</strong>
|
| 568 |
+
<small>Term + concise definition per segment</small>
|
| 569 |
+
</span>
|
| 570 |
+
</label>
|
| 571 |
+
<label class="vgm-llm-toggle">
|
| 572 |
+
<input type="checkbox" name="llm_math_equations" value="true" checked>
|
| 573 |
+
<span class="vgm-llm-toggle__body">
|
| 574 |
+
<strong>Math equations</strong>
|
| 575 |
+
<small>LaTeX from on-screen formulas, with screen-reader labels</small>
|
| 576 |
+
</span>
|
| 577 |
+
</label>
|
| 578 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
</div>
|
| 580 |
|
| 581 |
+
<div class="vgm-section">
|
| 582 |
+
<h3 class="vgm-section__title">3. Output</h3>
|
| 583 |
+
<div class="vgm-formats">
|
| 584 |
+
<label class="vgm-fmt">
|
| 585 |
+
<span class="vgm-fmt__head"><input type="radio" name="format" value="review" checked>Review & edit</span>
|
| 586 |
+
<small>Open the in-browser editor to refine before publishing.</small>
|
| 587 |
+
</label>
|
| 588 |
+
<label class="vgm-fmt">
|
| 589 |
+
<span class="vgm-fmt__head"><input type="radio" name="format" value="single">Single HTML</span>
|
| 590 |
+
<small>Self-contained file with all images inlined.</small>
|
| 591 |
+
</label>
|
| 592 |
+
<label class="vgm-fmt">
|
| 593 |
+
<span class="vgm-fmt__head"><input type="radio" name="format" value="zip">Zip bundle</span>
|
| 594 |
+
<small>HTML plus a static folder, ready to host.</small>
|
| 595 |
+
</label>
|
| 596 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
</div>
|
| 598 |
|
| 599 |
+
<div class="vgm-section">
|
| 600 |
+
<details class="vgm-advanced">
|
| 601 |
+
<summary>Advanced settings</summary>
|
| 602 |
+
<div>
|
| 603 |
+
|
| 604 |
+
<div class="vgm-tune">
|
| 605 |
+
<div class="vgm-tune__head">
|
| 606 |
+
<label for="threshold">Scene-change sensitivity</label>
|
| 607 |
+
<output for="threshold" class="vgm-tune__value">27</output>
|
| 608 |
+
</div>
|
| 609 |
+
<input type="range" id="threshold" name="threshold" value="27" min="5" max="60" step="1">
|
| 610 |
+
<div class="vgm-tune__anchors"><span>More scenes</span><span>Fewer scenes</span></div>
|
| 611 |
+
<small class="vgm-tune__help">
|
| 612 |
+
How visually different two frames must be before they count as a new scene.
|
| 613 |
+
Lower (5–15) catches every animation step; higher (35+) only major slide changes.
|
| 614 |
+
</small>
|
| 615 |
+
</div>
|
| 616 |
+
|
| 617 |
+
<div class="vgm-tune">
|
| 618 |
+
<div class="vgm-tune__head">
|
| 619 |
+
<label for="min_gap">Minimum gap between scenes</label>
|
| 620 |
+
<output for="min_gap" class="vgm-tune__value">off</output>
|
| 621 |
+
</div>
|
| 622 |
+
<input type="range" id="min_gap" name="min_gap" value="0" min="0" max="60" step="0.5">
|
| 623 |
+
<div class="vgm-tune__anchors"><span>Off</span><span>60 s</span></div>
|
| 624 |
+
<small class="vgm-tune__help">
|
| 625 |
+
Drop new scenes that arrive less than this many seconds after the previous kept one.
|
| 626 |
+
Useful for slides that build up gradually — try ~5 s to keep just the final state.
|
| 627 |
+
</small>
|
| 628 |
+
</div>
|
| 629 |
+
|
| 630 |
+
<div class="vgm-tune">
|
| 631 |
+
<div class="vgm-tune__head">
|
| 632 |
+
<label for="max_frames">Max frames</label>
|
| 633 |
+
<output for="max_frames" class="vgm-tune__value">unlimited</output>
|
| 634 |
+
</div>
|
| 635 |
+
<label class="vgm-tune__toggle">
|
| 636 |
+
<input type="checkbox" id="max_frames_enabled"> Cap total frames
|
| 637 |
+
</label>
|
| 638 |
+
<input type="range" id="max_frames" min="1" max="200" step="1" value="50" disabled>
|
| 639 |
+
<div class="vgm-tune__anchors"><span>1</span><span>200</span></div>
|
| 640 |
+
<small class="vgm-tune__help">
|
| 641 |
+
Hard limit on the number of frames in the guide. Useful for very long lectures
|
| 642 |
+
or to bound LLM extraction cost. Frames are evenly distributed across the video.
|
| 643 |
+
</small>
|
| 644 |
+
</div>
|
| 645 |
+
|
| 646 |
+
<div class="vgm-tune">
|
| 647 |
+
<div class="vgm-tune__head">
|
| 648 |
+
<label for="face_threshold">Instructor-frame face threshold</label>
|
| 649 |
+
<output for="face_threshold" class="vgm-tune__value">0.12</output>
|
| 650 |
+
</div>
|
| 651 |
+
<input type="range" id="face_threshold" name="face_threshold" value="0.12" min="0.02" max="0.6" step="0.01">
|
| 652 |
+
<div class="vgm-tune__anchors"><span>Strict (drop more)</span><span>Lenient (keep more)</span></div>
|
| 653 |
+
<small class="vgm-tune__help">
|
| 654 |
+
Fraction of the frame a detected face must occupy before we drop it as
|
| 655 |
+
instructor-only. Lower = more aggressive; raise it if your slides have an
|
| 656 |
+
inset webcam you want to keep.
|
| 657 |
+
</small>
|
| 658 |
+
</div>
|
| 659 |
+
|
| 660 |
+
<div class="vgm-tune">
|
| 661 |
+
<label class="vgm-tune__toggle">
|
| 662 |
+
<input type="checkbox" name="skip_ocr" value="true"> Skip OCR
|
| 663 |
+
</label>
|
| 664 |
+
<small class="vgm-tune__help">
|
| 665 |
+
Faster; on-screen text and the heuristic LaTeX wrapping in the guide will be empty.
|
| 666 |
+
Doesn't affect LLM extraction (which reads the frame image directly).
|
| 667 |
+
</small>
|
| 668 |
+
</div>
|
| 669 |
+
|
| 670 |
+
<div class="vgm-tune">
|
| 671 |
+
<div class="vgm-tune__head">
|
| 672 |
+
<label for="lang">Document language</label>
|
| 673 |
+
<output for="lang" class="vgm-tune__value">en</output>
|
| 674 |
+
</div>
|
| 675 |
+
<input type="text" id="lang" name="lang" value="en" pattern="[a-zA-Z\-]+" maxlength="12" style="width: 6rem;">
|
| 676 |
+
<small class="vgm-tune__help">
|
| 677 |
+
BCP-47 code (<code>en</code>, <code>en-US</code>, <code>fr</code>…).
|
| 678 |
+
Sets the <code>lang</code> attribute on the generated HTML and selects
|
| 679 |
+
Tesseract language packs when available.
|
| 680 |
+
</small>
|
| 681 |
+
</div>
|
| 682 |
+
|
| 683 |
+
</div>
|
| 684 |
+
</details>
|
| 685 |
</div>
|
| 686 |
|
| 687 |
+
<div class="vgm-submit-row">
|
| 688 |
+
<span class="vgm-submit-row__hint">Processing usually takes ~30 s per minute of video.</span>
|
| 689 |
+
<button type="submit" class="vgm-cta">Generate study guide →</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 690 |
</div>
|
| 691 |
+
|
| 692 |
+
</form>
|
| 693 |
+
|
| 694 |
+
<aside class="vgm-side">
|
| 695 |
+
<div class="vgm-card">
|
| 696 |
+
<h3>What you'll get</h3>
|
| 697 |
+
<ul class="vgm-feature-list">
|
| 698 |
+
<li>One scene-aligned segment per slide with the cleanest available frame.</li>
|
| 699 |
+
<li>Three candidate frames per segment — pick the best in the editor.</li>
|
| 700 |
+
<li>Narration paragraphed and aligned to each visual.</li>
|
| 701 |
+
<li>WCAG 2.2 scaffold: proper heading hierarchy, lang, skip links, alt-text drafts.</li>
|
| 702 |
+
<li>Inline editor for human review — fix titles, alt text, terms, equations.</li>
|
| 703 |
+
</ul>
|
| 704 |
+
</div>
|
| 705 |
+
<div class="vgm-card">
|
| 706 |
+
<h3>Tips</h3>
|
| 707 |
+
<ul class="vgm-feature-list">
|
| 708 |
+
<li><strong>Save money:</strong> uncheck AI features above to skip Claude entirely.</li>
|
| 709 |
+
<li><strong>Progressive-reveal slides:</strong> set Min-gap ≈ 5 s in advanced settings.</li>
|
| 710 |
+
<li><strong>Inset webcam stays:</strong> raise the face-threshold; instructor-only frames still drop.</li>
|
| 711 |
+
<li><strong>Long lectures:</strong> cap Max frames to bound runtime and API cost.</li>
|
| 712 |
+
</ul>
|
| 713 |
+
</div>
|
| 714 |
+
</aside>
|
| 715 |
+
|
| 716 |
+
</div>
|
| 717 |
+
</div>
|
| 718 |
|
| 719 |
<div class="vgm-review" data-state="closed" role="dialog" aria-label="Study guide editor">
|
| 720 |
<div class="vgm-review__bar">
|
|
|
|
| 736 |
const textEl = panel.querySelector('.vgm-progress__text');
|
| 737 |
const detailsEl = panel.querySelector('.vgm-progress__details');
|
| 738 |
const retryBtn = panel.querySelector('.vgm-progress__retry');
|
| 739 |
+
const stagePillsEl = panel.querySelector('.vgm-progress__stages');
|
| 740 |
const apiKeyEl = form.querySelector('#anthropic_api_key');
|
| 741 |
const titleEl = form.querySelector('#title');
|
| 742 |
const reviewEl = document.querySelector('.vgm-review');
|
|
|
|
| 746 |
const reviewOpenBtn = reviewEl.querySelector('.vgm-review__open');
|
| 747 |
let lastResultUrl = null;
|
| 748 |
|
| 749 |
+
const STAGE_ORDER = ['uploading', 'scene_detect', 'filter', 'transcript', 'ocr', 'llm_extract', 'render'];
|
| 750 |
+
function setStagePill(stage) {
|
| 751 |
+
const idx = STAGE_ORDER.indexOf(stage);
|
| 752 |
+
stagePillsEl.querySelectorAll('span').forEach(el => {
|
| 753 |
+
const i = STAGE_ORDER.indexOf(el.getAttribute('data-stage'));
|
| 754 |
+
el.classList.toggle('is-active', i === idx);
|
| 755 |
+
el.classList.toggle('is-done', i >= 0 && idx > i);
|
| 756 |
+
});
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
function openReview(resultUrl, title) {
|
| 760 |
lastResultUrl = resultUrl;
|
| 761 |
reviewTitleEl.textContent = title ? '— ' + title : '';
|
|
|
|
| 773 |
if (lastResultUrl) window.open(lastResultUrl, '_blank', 'noopener');
|
| 774 |
});
|
| 775 |
|
| 776 |
+
// Drop zones — show file metadata + drag styling.
|
| 777 |
+
function fmtBytes(n) {
|
| 778 |
+
if (n < 1024) return n + ' B';
|
| 779 |
+
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + ' KB';
|
| 780 |
+
if (n < 1024 * 1024 * 1024) return (n / (1024 * 1024)).toFixed(1) + ' MB';
|
| 781 |
+
return (n / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
|
| 782 |
+
}
|
| 783 |
+
function fmtDuration(s) {
|
| 784 |
+
if (!s || !isFinite(s)) return '—';
|
| 785 |
+
const h = Math.floor(s / 3600);
|
| 786 |
+
const m = Math.floor((s % 3600) / 60);
|
| 787 |
+
const sec = Math.round(s % 60);
|
| 788 |
+
return h > 0 ? `${h}:${String(m).padStart(2,'0')}:${String(sec).padStart(2,'0')}`
|
| 789 |
+
: `${m}:${String(sec).padStart(2,'0')}`;
|
| 790 |
+
}
|
| 791 |
+
async function readVideoMeta(file) {
|
| 792 |
+
return new Promise(resolve => {
|
| 793 |
+
const v = document.createElement('video');
|
| 794 |
+
v.preload = 'metadata';
|
| 795 |
+
v.onloadedmetadata = () => {
|
| 796 |
+
const d = v.duration;
|
| 797 |
+
URL.revokeObjectURL(v.src);
|
| 798 |
+
resolve({ duration: d, width: v.videoWidth, height: v.videoHeight });
|
| 799 |
+
};
|
| 800 |
+
v.onerror = () => { URL.revokeObjectURL(v.src); resolve({}); };
|
| 801 |
+
v.src = URL.createObjectURL(file);
|
| 802 |
+
});
|
| 803 |
+
}
|
| 804 |
+
async function readTranscriptPreview(file) {
|
| 805 |
+
try {
|
| 806 |
+
const text = await file.slice(0, 8 * 1024).text();
|
| 807 |
+
const cues = (text.match(/-->/g) || []).length;
|
| 808 |
+
const firstCue = (text.match(/(\d{1,2}:\d{2}:\d{2}[.,]\d{3})\s*-->\s*(\d{1,2}:\d{2}:\d{2}[.,]\d{3})/) || [])[0];
|
| 809 |
+
return { cues, firstCue: firstCue || '' };
|
| 810 |
+
} catch (_) { return {}; }
|
| 811 |
+
}
|
| 812 |
+
function setMeta(dropEl, label, rows) {
|
| 813 |
+
const meta = dropEl.querySelector('.vgm-drop__meta');
|
| 814 |
+
const rowsHTML = rows.filter(([k, v]) => v).map(([k, v]) =>
|
| 815 |
+
`<dt>${k}</dt><dd>${v}</dd>`
|
| 816 |
+
).join('');
|
| 817 |
+
meta.innerHTML = `<strong>${label}</strong>${rowsHTML ? '<dl>' + rowsHTML + '</dl>' : ''}`;
|
| 818 |
+
dropEl.setAttribute('data-loaded', 'true');
|
| 819 |
+
}
|
| 820 |
+
function bindDropZone(input, kind) {
|
| 821 |
+
const drop = input.closest('.vgm-drop');
|
| 822 |
+
['dragenter', 'dragover'].forEach(evt =>
|
| 823 |
+
drop.addEventListener(evt, e => { e.preventDefault(); drop.classList.add('is-dragover'); })
|
| 824 |
+
);
|
| 825 |
+
['dragleave', 'drop'].forEach(evt =>
|
| 826 |
+
drop.addEventListener(evt, e => { drop.classList.remove('is-dragover'); })
|
| 827 |
+
);
|
| 828 |
+
input.addEventListener('change', async () => {
|
| 829 |
+
const f = input.files && input.files[0];
|
| 830 |
+
if (!f) { drop.setAttribute('data-loaded', 'false'); return; }
|
| 831 |
+
if (kind === 'video') {
|
| 832 |
+
setMeta(drop, f.name, [['Size', fmtBytes(f.size)], ['Type', f.type || '—']]);
|
| 833 |
+
const meta = await readVideoMeta(f);
|
| 834 |
+
if (meta.duration) {
|
| 835 |
+
const dim = (meta.width && meta.height) ? `${meta.width}×${meta.height}` : '';
|
| 836 |
+
setMeta(drop, f.name, [
|
| 837 |
+
['Size', fmtBytes(f.size)],
|
| 838 |
+
['Duration', fmtDuration(meta.duration)],
|
| 839 |
+
['Resolution', dim],
|
| 840 |
+
]);
|
| 841 |
+
}
|
| 842 |
+
} else {
|
| 843 |
+
setMeta(drop, f.name, [['Size', fmtBytes(f.size)]]);
|
| 844 |
+
const t = await readTranscriptPreview(f);
|
| 845 |
+
if (t.cues != null) {
|
| 846 |
+
setMeta(drop, f.name, [
|
| 847 |
+
['Size', fmtBytes(f.size)],
|
| 848 |
+
['Cues (approx.)', String(t.cues)],
|
| 849 |
+
['First cue', t.firstCue || '—'],
|
| 850 |
+
]);
|
| 851 |
+
}
|
| 852 |
+
}
|
| 853 |
+
});
|
| 854 |
+
}
|
| 855 |
+
bindDropZone(form.querySelector('#video'), 'video');
|
| 856 |
+
bindDropZone(form.querySelector('#transcript'), 'transcript');
|
| 857 |
+
|
| 858 |
+
// Sliders: keep <output> in sync.
|
| 859 |
function fmtMinGap(v) { return parseFloat(v) <= 0 ? 'off' : (parseFloat(v) + ' s'); }
|
| 860 |
function fmtIdentity(v) { return v; }
|
| 861 |
const formatters = { min_gap: fmtMinGap };
|
|
|
|
| 867 |
slider.addEventListener('input', sync);
|
| 868 |
sync();
|
| 869 |
});
|
|
|
|
| 870 |
form.querySelectorAll('input[type="text"][id]').forEach(input => {
|
| 871 |
const out = form.querySelector('output[for="' + input.id + '"]');
|
| 872 |
if (!out) return;
|
|
|
|
| 875 |
sync();
|
| 876 |
});
|
| 877 |
|
| 878 |
+
// Max-frames cap toggle.
|
|
|
|
| 879 |
const maxFramesToggle = form.querySelector('#max_frames_enabled');
|
| 880 |
const maxFramesSlider = form.querySelector('#max_frames');
|
| 881 |
const maxFramesOut = form.querySelector('output[for="max_frames"]');
|
|
|
|
| 899 |
function setProgress(state, percent, stage, message) {
|
| 900 |
panel.setAttribute('data-state', state);
|
| 901 |
if (typeof percent === 'number') bar.value = percent;
|
| 902 |
+
if (stage) {
|
| 903 |
+
stageEl.textContent = stage.replace('_', ' ');
|
| 904 |
+
setStagePill(stage);
|
| 905 |
+
}
|
| 906 |
if (message) textEl.textContent = message;
|
| 907 |
}
|
|
|
|
| 908 |
function showError(short, detail) {
|
| 909 |
setProgress('error', 100, 'error', short);
|
| 910 |
detailsEl.textContent = detail || '';
|
| 911 |
}
|
|
|
|
| 912 |
function resetForRetry() {
|
| 913 |
detailsEl.textContent = '';
|
| 914 |
panel.setAttribute('data-state', 'idle');
|
| 915 |
form.style.display = '';
|
| 916 |
}
|
|
|
|
| 917 |
retryBtn.addEventListener('click', resetForRetry);
|
| 918 |
|
| 919 |
function postJob(fd) {
|
|
|
|
| 942 |
const v = fd.get(k);
|
| 943 |
if (typeof v === 'string' && v.trim() === '') fd.delete(k);
|
| 944 |
});
|
| 945 |
+
// Unchecked LLM toggles must explicitly send "false" so the server doesn't apply its default-on.
|
| 946 |
+
['llm_alt_text', 'llm_key_terms', 'llm_math_equations', 'llm_section_title'].forEach(k => {
|
| 947 |
+
if (!fd.has(k)) fd.set(k, 'false');
|
| 948 |
+
});
|
| 949 |
if (apiKeyEl) apiKeyEl.value = '';
|
| 950 |
const submittedTitle = (titleEl && titleEl.value) || 'Study Guide';
|
| 951 |
const formatRadio = form.querySelector('input[name="format"]:checked');
|
|
|
|
| 967 |
try {
|
| 968 |
const parsed = JSON.parse(detail);
|
| 969 |
detail = parsed.detail || parsed.message || detail;
|
| 970 |
+
} catch (_) {}
|
| 971 |
showError(`Server rejected the upload (HTTP ${xhr.status})`, detail);
|
| 972 |
return;
|
| 973 |
}
|
|
|
|
| 991 |
setProgress('running', data.percent, data.stage, data.message);
|
| 992 |
} else if (data.type === 'done') {
|
| 993 |
es.close();
|
| 994 |
+
setProgress('running', 100, 'render', 'Loading editor…');
|
| 995 |
if (format === 'review') {
|
| 996 |
openReview(result_url, submittedTitle);
|
|
|
|
| 997 |
panel.setAttribute('data-state', 'idle');
|
| 998 |
form.style.display = '';
|
| 999 |
} else {
|
|
|
|
| 1002 |
document.body.appendChild(a);
|
| 1003 |
a.click();
|
| 1004 |
a.remove();
|
| 1005 |
+
setProgress('running', 100, 'render', 'Downloaded. Generate another?');
|
| 1006 |
setTimeout(resetForRetry, 2500);
|
| 1007 |
}
|
| 1008 |
} else if (data.type === 'error') {
|
|
|
|
| 1011 |
}
|
| 1012 |
};
|
| 1013 |
es.onerror = () => {
|
|
|
|
|
|
|
| 1014 |
if (es.readyState === EventSource.CLOSED) {
|
| 1015 |
showError('Lost connection to server.',
|
| 1016 |
`Last progress message: ${lastStageMsg}\n` +
|