diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..2442ff01d327ea4d7fdd3318a54249a29091d02d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,38 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +assets/bgm/deno-bgm-001.mp3 filter=lfs diff=lfs merge=lfs -text +assets/bgm/offline_ambient_pad.wav filter=lfs diff=lfs merge=lfs -text +assets/fonts/PretendardVariable.woff2 filter=lfs diff=lfs merge=lfs -text +assets/sfx/sfx_counter_tick.wav filter=lfs diff=lfs merge=lfs -text +assets/sfx/sfx_highlighter_sweep.wav filter=lfs diff=lfs merge=lfs -text +assets/sfx/sfx_insight_chime.wav filter=lfs diff=lfs merge=lfs -text +assets/sfx/sfx_terminal_type.wav filter=lfs diff=lfs merge=lfs -text +assets/sfx/sfx_whoosh.wav filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-macosx_11_0_arm64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-win_amd64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/beautifulsoup4-4.15.0-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/certifi-2026.10.23-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/lxml-6.1.3-cp312-cp312-macosx_10_13_universal2.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/lxml-6.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/lxml-6.1.3-cp312-cp312-win_amd64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/multidict-7.2.1-cp312-cp312-macosx_11_0_arm64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/multidict-7.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/numpy-2.5.5-cp312-cp312-macosx_14_0_arm64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/numpy-2.5.5-cp312-cp312-win_amd64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/packaging-26.3-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/pillow-13.0.0-cp312-cp312-macosx_11_0_arm64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/pillow-13.0.0-cp312-cp312-win_amd64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/propcache-0.5.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/python_docx-1.2.0-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/python_pptx-1.0.2-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/setuptools-84.2.1-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/xlsxwriter-3.3.1-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/yarl-1.25.1-cp312-cp312-macosx_11_0_arm64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/yarl-1.25.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl filter=lfs diff=lfs merge=lfs -text +offline_vendor/wheels/yarl-1.25.1-cp312-cp312-win_amd64.whl filter=lfs diff=lfs merge=lfs -text +samples/sample_sync_deck.mp4 filter=lfs diff=lfs merge=lfs -text diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c084f271090cc84a3e905d1894b4ecc8fc81a8d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:22-bookworm + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 python3-pip python3-venv ffmpeg \ + libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \ + libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \ + libgbm1 libasound2 libpango-1.0-0 libcairo2 fonts-noto-cjk \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app/deck_video_pipeline +COPY . /app/deck_video_pipeline + +RUN python3 -m venv /opt/venv \ + && /opt/venv/bin/pip install --no-cache-dir --upgrade pip \ + && /opt/venv/bin/pip install --no-cache-dir -r requirements.txt \ + && /opt/venv/bin/pip install --no-cache-dir -e . \ + && npx --yes hyperframes --version + +ENV PATH="/opt/venv/bin:${PATH}" +ENTRYPOINT ["deck2video"] +CMD ["--demo"] diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..dea77696b2335d85bb5a83237aa33da51b3337b9 --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +--- +license: mit +language: + - ko + - en +tags: + - agent-skill + - presentation-to-video + - pptx-to-video + - docx-to-video + - html-motion + - hyperframes + - claude-code + - antigravity + - offline-ready +--- + +# 🎬 Deck2Video Agent Skill (`PPTX Β· DOCX Β· MD Β· HTML βž” HTML λͺ¨μ…˜ + UI 효과음 βž” 1080p MP4`) + +νŒŒμ›Œν¬μΈνŠΈ(`.pptx`), μ›Œλ“œ(`.docx`), λ§ˆν¬λ‹€μš΄(`.md`/`.txt`), μ›Ή μŠ¬λΌμ΄λ“œΒ·λ¬Έμ„œ(`.html`)μ—μ„œ λ°œν‘œ ꡬ쑰λ₯Ό μžλ™ μΆ”μΆœν•˜μ—¬ **닀크 λ„€μ˜¨ κΈ€λž˜μŠ€ UI + 3D νŒŒν‹°ν΄ μ›¨μ΄λΈŒ λ°°κ²½ + 상단 챕터 μ§„ν–‰λ°” + 5μ’… λͺ¨μ…˜ λ ˆμ΄μ•„μ›ƒ + λ‚΄λ ˆμ΄μ…˜ + 6μ’… UI 효과음 + μžλ™ 덕킹 λ°°κ²½μŒμ•…**이 κ²°ν•©λœ `1920Γ—1080` MP4 μ˜μƒμ„ μƒμ„±ν•˜λŠ” **μ˜¨Β·μ˜€ν”„λΌμΈ 겸용 AI μ—μ΄μ „νŠΈ μŠ€ν‚¬**μž…λ‹ˆλ‹€. + +--- + +## πŸ€– AI μ—μ΄μ „νŠΈμš© 원클릭 μ„€μΉ˜ ν”„λ‘¬ν”„νŠΈ (λ³΅μ‚¬ν•΄μ„œ λΆ™μ—¬λ„£κΈ°) + +μ‚¬μš©ν•˜μ‹œλŠ” AI μ½”λ”© μ—μ΄μ „νŠΈ(**Google Antigravity, Claude Code, Cursor, Codex, Windsurf** λ“±) μ±„νŒ…μ°½μ— μ•„λž˜ ν”„λ‘¬ν”„νŠΈλ₯Ό κ·ΈλŒ€λ‘œ λΆ™μ—¬λ„£μœΌλ©΄ μ—μ΄μ „νŠΈκ°€ 슀슀둜 μŠ€ν‚¬μ„ λ‹€μš΄λ‘œλ“œΒ·μ„€μΉ˜Β·κ²€μ¦ν•©λ‹ˆλ‹€. + +```text +https://huggingface.co/VanyaJ/deck2video-skill μ €μž₯μ†Œλ₯Ό ν΄λ‘ ν•΄μ„œ λ‚΄ 둜컬 AI μ—μ΄μ „νŠΈ μŠ€ν‚¬ 디렉토리(AntigravityλŠ” ~/.gemini/config/skills/deck-video-pipeline, Claude CodeλŠ” ~/.claude/skills/deck-video-pipeline, λ˜λŠ” ν˜„μž¬ ν”„λ‘œμ νŠΈμ˜ .agents/skills/deck-video-pipeline)에 μ„€μΉ˜ν•΄ 쀘. +μ„€μΉ˜ ν›„ SKILL.mdλ₯Ό 읽고 λ‚΄ OS(Mac/Windows/Linux)에 맞좰 파이썬 μ˜μ‘΄μ„±(온라인이면 install_mac_linux.sh / install_windows.ps1, 폐쇄망 μ˜€ν”„λΌμΈμ΄λ©΄ install_offline_mac_linux.sh / install_offline_windows.ps1)을 μ„ΈνŒ…ν•œ λ’€, μƒ˜ν”Œ λ¬Έμ„œλ‘œ λ™μž‘ ν…ŒμŠ€νŠΈκΉŒμ§€ 마치고 보고해 쀘. +``` + +--- + +## πŸ“¦ ν¬ν•¨λœ κ΅¬μ„±ν’ˆ (온라인 + 100% 폐쇄망 μ˜€ν”„λΌμΈ νŒ¨ν‚€μ§€ μ™„λΉ„) + +* **`SKILL.md`**: AI μ—μ΄μ „νŠΈ μžλ™ μΈμ‹μš© μŠ€ν‚¬ λͺ…μ„Έμ„œ +* **`produce_deck_video.py`** (`deck2video` CLI): 톡합 λ³€ν™˜ μ‹€ν–‰κΈ° (`--offline` λ¬΄λ„€νŠΈμ›Œν¬ λͺ¨λ“œ 지원) +* **`ingest_parser.py`**: `.pptx` / `.docx` / `.md` / `.txt` / `.html` / `.json` 닀쀑 λ¬Έμ„œ νŒŒμ„œ +* **`html_builder.py`**: 3D λ„νŠΈ μ›¨μ΄λΈŒ μΊ”λ²„μŠ€ + 상단 챕터 HUD + 5μ’… λͺ¨μ…˜ 씬(`arc_cards`, `mockup_steps`, `book_quote`, `terminal_flow`, `metric_summary`) + ν•œΒ·μ˜ 이쀑 μžλ§‰ 컴파일러 +* **`sfx_engine.py` & `bgm_engine.py`**: μ™ΈλΆ€ 유료 μŒμ› 없이 자체 ν•©μ„±ν•˜λŠ” 48kHz μŠ€ν…Œλ ˆμ˜€ UI 효과음 6μ’… + μ˜¨Β·μ˜€ν”„λΌμΈ ν•˜μ΄λΈŒλ¦¬λ“œ BGM +* **`offline_renderer.py`**: Node.js/npmμ΄λ‚˜ 인터넷이 μ „ν˜€ μ—†λŠ” 폐쇄망 PCμ—μ„œλ„ 둜컬 Chrome/Edge λΈŒλΌμš°μ €(CDP) + FFmpeg만으둜 1080p MP4λ₯Ό λ Œλ”λ§ν•˜λŠ” λ¬΄μ˜μ‘΄μ„± μ˜€ν”„λΌμΈ λ Œλ”λŸ¬ +* **`offline_vendor/wheels/`**: Windows(`win_amd64`), macOS(`arm64`), Linux(`manylinux_x86_64`)용 μ˜€ν”„λΌμΈ Python `.whl` νŒ¨ν‚€μ§€ 일체 λ‚΄μž₯ +* **`assets/`**: `PretendardVariable.woff2` ν•œκΈ€ κ°€λ³€ 폰트, `gsap.min.js`, 6μ’… UI 효과음 WAV, λ°°κ²½μŒμ•… MP3/WAV 사전 λ²ˆλ“€λ§ +* **`samples/`**: ν…ŒμŠ€νŠΈμš© `.pptx`, `.docx`, `.md`, `.html` μƒ˜ν”Œ λ¬Έμ„œ 및 μ™„μ„± μƒ˜ν”Œ μ˜μƒ(`sample_sync_deck.mp4`) + +--- + +## πŸš€ μˆ˜λ™ μ„€μΉ˜ 및 μ‚¬μš©λ²• + +### 1) 온라인 PC μ„€μΉ˜ (macOS / Linux / Windows) +```bash +git clone https://huggingface.co/VanyaJ/deck2video-skill deck-video-pipeline +cd deck-video-pipeline + +# macOS / Linux +./install_mac_linux.sh && source .venv/bin/activate + +# Windows (PowerShell) +# powershell -ExecutionPolicy Bypass -File .\install_windows.ps1 +# .\.venv\Scripts\Activate.ps1 +``` + +### 2) 폐쇄망 / μ˜€ν”„λΌμΈ PC μ„€μΉ˜ (인터넷 μ—°κ²° λΆˆν•„μš”) +μ €μž₯μ†Œ 폴더(λ˜λŠ” `deck2video_offline_full.zip`)λ₯Ό USB/μ‚¬λ‚΄λ§μœΌλ‘œ λ³΅μ‚¬ν•œ λ’€ μ‹€ν–‰ν•©λ‹ˆλ‹€(PC에 Python 3.12, FFmpeg, Chrome λ˜λŠ” Edge λΈŒλΌμš°μ €λ§Œ 있으면 λ™μž‘). +```bash +# macOS / Linux μ˜€ν”„λΌμΈ μ„€μΉ˜ +./install_offline_mac_linux.sh && source .venv/bin/activate + +# Windows μ˜€ν”„λΌμΈ μ„€μΉ˜ (PowerShell) +# powershell -ExecutionPolicy Bypass -File .\install_offline_windows.ps1 + +# 100% μ˜€ν”„λΌμΈ λͺ¨λ“œλ‘œ μ˜μƒ λ Œλ”λ§ (OS λ‚΄μž₯ ν•œκ΅­μ–΄ TTS + 둜컬 λΈŒλΌμš°μ € CDP λ Œλ”λ§) +python3 produce_deck_video.py --input samples/sample_ai_sync_lecture.pptx --offline --output output/offline_lecture.mp4 +``` + +### 3) 포맷별 λ³€ν™˜ μ˜ˆμ‹œ +```bash +# νŒŒμ›Œν¬μΈνŠΈ (.pptx) +deck2video --input lecture.pptx --output output/lecture.mp4 + +# μ›Œλ“œ (.docx) +deck2video --input proposal.docx --output output/proposal.mp4 + +# λ§ˆν¬λ‹€μš΄ (.md) +deck2video --input notes.md --voice ko-KR-SunHiNeural --output output/notes.mp4 + +# μ›Ή μŠ¬λΌμ΄λ“œ / HTML (.html) +deck2video --input slides.html --output output/slides.mp4 +``` diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000000000000000000000000000000000000..9cdc2b283fddd2b7dcc488282803eb5b67a2ae7b --- /dev/null +++ b/SKILL.md @@ -0,0 +1,73 @@ +--- +name: deck-video-pipeline +description: > + Convert PowerPoint (.pptx), Word (.docx), Markdown (.md/.txt), or HTML (.html) + presentations and educational materials into sleek code-rendered 1920x1080 MP4 + motion videos complete with dark glassmorphism UI, 3D horizon particle waves, + top chapter progress bars, Korean/multilingual TTS voiceover, 6 procedural UI + sound effects (SFX), and auto-ducked ambient BGM. Supports both Online mode + (HyperFrames + Edge-TTS) and 100% Air-Gapped Offline mode (--offline). +--- + +# Deck-to-Video Motion Presentation Skill (`deck-video-pipeline`) + +Use this skill whenever the user asks to: +- Turn a **PowerPoint (`.pptx`)**, **Word document (`.docx`)**, **Markdown/text note (`.md`/`.txt`)**, or **HTML presentation/article (`.html`)** into a presentation video, lecture video, explainer video, or YouTube tech presentation (like *μ«‘λŒ€ν‘œμ˜ 딸깍일기* / code-rendered dark glass UI decks). +- Generate a presentation video **with UI sound effects (SFX)**, chapter progress HUD, big stat counters, 3D card arcs, textbook quote highlights, or terminal flow animations. +- Run presentation video conversion in **offline / air-gapped environments** (`--offline`). + +--- + +## 1. Skill Directory & Entrypoint + +Locate `produce_deck_video.py` inside this skill folder (`/produce_deck_video.py`). + +### Quick Verification +```bash +python3 "/produce_deck_video.py" --help +``` + +If Python dependencies are not yet installed on the machine: +- **Online install**: `bash "/install_mac_linux.sh"` (macOS/Linux) or `powershell -ExecutionPolicy Bypass -File "\install_windows.ps1"` (Windows). +- **Offline (air-gapped) install**: `bash "/install_offline_mac_linux.sh"` or `powershell -ExecutionPolicy Bypass -File "\install_offline_windows.ps1"`. + +--- + +## 2. Standard Execution Commands + +### A. Convert PowerPoint (`.pptx`), Word (`.docx`), Markdown (`.md`), or HTML (`.html`) to MP4 +```bash +python3 "/produce_deck_video.py" \ + --input "/absolute/path/to/material.pptx" \ + --output "/absolute/path/to/output_video.mp4" +``` + +### B. 100% Offline / Air-Gapped Mode (Zero Internet, Zero NPM Required) +Uses OS-native TTS (macOS `say`, Windows `System.Speech`, Linux `espeak-ng`), bundled `PretendardVariable.woff2` + `gsap.min.js`, procedural 48kHz stereo SFX + offline ambient pad BGM, and local Chrome/Edge headless CDP frame pipe: +```bash +python3 "/produce_deck_video.py" \ + --input "/absolute/path/to/material.docx" \ + --offline \ + --output "/absolute/path/to/output_video.mp4" +``` + +### C. Customize Voice, Pacing, or Audio Layers +- `--voice ko-KR-InJoonNeural` (default calm male) or `--voice ko-KR-SunHiNeural` (bright female) or any `edge-tts` voice (e.g. `en-US-AndrewNeural`, `ja-JP-KeitaNeural`) +- `--rate "+8%"` (adjust speaking speed) +- `--no-sfx` (mute UI sound effects) / `--no-bgm` (mute background music) +- `--html-only` (generate `index.html` and run layout/WCAG contrast checks without encoding MP4) + +--- + +## 3. Authoring & Formatting Tips for Best Visual Output + +When the user asks you to create a presentation from a topic or rough notes first, write a `.md` or `.json` (or `.pptx`) using these conventions before running `produce_deck_video.py`: + +1. **5 Built-in Visual Scene Archetypes** (auto-assigned, or override via `[ARCHETYPE: ]` line): + - `arc_cards`: 3D cylindrical concave card carousel + big glowing stat counter (`[STAT_PREFIX: ...]`, `[STAT_NUM: 9]`, `[STAT_SUFFIX: μ’…]`). Best for intro / overview of N items. + - `mockup_steps`: Left glass app/slide monitor + Right 3 stacked cards that light up sequentially per spoken beat with `card_pop` SFX. Best for 3-step comparisons or problem diagnosis. + - `book_quote`: 3D perspective open manual spread + animated sky-blue highlighter sweep (`[QUOTE: ...]`). Best for core principles, rules, or definitions. + - `terminal_flow`: Dark macOS-style terminal typing (`[COMMAND: ...]`) + glowing `INPUT ──●──▢ OUTPUT` node pulse. Best for workflows, CLI commands, or system pipelines. + - `metric_summary`: 3 neon glass pillars (`01`, `02`, `03`) + bottom takeaway pill (`[SUBTITLE: ...]`). Best for conclusions and action items. +2. **Card Label Splitting**: Format bullets as `핡심 ν‚€μ›Œλ“œ | λΆ€μ—° μ„€λͺ… ν•œ 쀄` so cards display a bold title and crisp subtitle. +3. **Bilingual Dual Subtitles**: In PPTX speaker notes, Word quotes, or Markdown `>` lines, write `ν•œκ΅­μ–΄ λ‚΄λ ˆμ΄μ…˜ λ¬Έμž₯μž…λ‹ˆλ‹€. || Optional English subtitle line.` to render dual KR/EN subtitles automatically. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..05ef3c592dce5620144556752df9aa8df1d97b1e --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +"""Deck-to-Video (PPTX / Markdown / JSON -> HTML Motion + SFX -> MP4) Pipeline.""" diff --git a/assets/bgm/deno-bgm-001.mp3 b/assets/bgm/deno-bgm-001.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..b236dd7cb0138549ccdf0b8447c8fd047bb6be69 --- /dev/null +++ b/assets/bgm/deno-bgm-001.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1fe33de255fa9ac731624d8c6ead4d7f95b66ce28c0f1a6761458cba37f3bca5 +size 4441685 diff --git a/assets/bgm/offline_ambient_pad.wav b/assets/bgm/offline_ambient_pad.wav new file mode 100644 index 0000000000000000000000000000000000000000..d9b0242bfd56b8a736b9f6fba85ef2a81098d13a --- /dev/null +++ b/assets/bgm/offline_ambient_pad.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a4b7248e9bd15b95b86c71290e9e3d5635d22152752ac46c88471aa3089a64a +size 5760044 diff --git a/assets/fonts/PretendardVariable.woff2 b/assets/fonts/PretendardVariable.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..3eb09337c03866484453b6ffdf8d08da7ea76998 --- /dev/null +++ b/assets/fonts/PretendardVariable.woff2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9599f12fd42fc0bce1cd50b47a0c022e108d7aa64dd0d1bb0ed44f3282d900b4 +size 2057688 diff --git a/assets/js/gsap.min.js b/assets/js/gsap.min.js new file mode 100644 index 0000000000000000000000000000000000000000..fde57af06cc445f47ca2a6fc1232ec04666346d4 --- /dev/null +++ b/assets/js/gsap.min.js @@ -0,0 +1,11 @@ +/*! + * GSAP 3.14.2 + * https://gsap.com + * + * @license Copyright 2025, GreenSock. All rights reserved. + * Subject to the terms at https://gsap.com/standard-license. + * @author: Jack Doyle, jack@greensock.com + */ + +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(e){"use strict";function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t){return"string"==typeof t}function s(t){return"function"==typeof t}function t(t){return"number"==typeof t}function u(t){return void 0===t}function v(t){return"object"==typeof t}function w(t){return!1!==t}function x(){return"undefined"!=typeof window}function y(t){return s(t)||r(t)}function R(t){return(i=bt(t,ht))&&Fe}function S(t,e){return console.warn("Invalid property",t,"set to",e,"Missing plugin? gsap.registerPlugin()")}function T(t,e){return!e&&console.warn(t)}function U(t,e){return t&&(ht[t]=e)&&i&&(i[t]=e)||ht}function V(){return 0}function ga(t){var e,r,i=t[0];if(v(i)||s(i)||(t=[t]),!(e=(i._gsap||{}).harness)){for(r=yt.length;r--&&!yt[r].targetTest(i););e=yt[r]}for(r=t.length;r--;)t[r]&&(t[r]._gsap||(t[r]._gsap=new Xt(t[r],e)))||t.splice(r,1);return t}function ha(t){return t._gsap||ga(Pt(t))[0]._gsap}function ia(t,e,r){return(r=t[e])&&s(r)?t[e]():u(r)&&t.getAttribute&&t.getAttribute(e)||r}function ja(t,e){return(t=t.split(",")).forEach(e)||t}function ka(t){return Math.round(1e5*t)/1e5||0}function la(t){return Math.round(1e7*t)/1e7||0}function ma(t,e){var r=e.charAt(0),i=parseFloat(e.substr(2));return t=parseFloat(t),"+"===r?t+i:"-"===r?t-i:"*"===r?t*i:t/i}function na(t,e){for(var r=e.length,i=0;t.indexOf(e[i])<0&&++ia;)s=s._prev;return s?(e._next=s._next,s._next=e):(e._next=t[r],t[r]=e),e._next?e._next._prev=e:t[i]=e,e._prev=s,e.parent=e._dp=t,e}function Ba(t,e,r,i){void 0===r&&(r="_first"),void 0===i&&(i="_last");var n=e._prev,a=e._next;n?n._next=a:t[r]===e&&(t[r]=a),a?a._prev=n:t[i]===e&&(t[i]=n),e._next=e._prev=e.parent=null}function Ca(t,e){t.parent&&(!e||t.parent.autoRemoveChildren)&&t.parent.remove&&t.parent.remove(t),t._act=0}function Da(t,e){if(t&&(!e||e._end>t._dur||e._start<0))for(var r=t;r;)r._dirty=1,r=r.parent;return t}function Fa(t,e,r,i){return t._startAt&&(I?t._startAt.revert(ft):t.vars.immediateRender&&!t.vars.autoRevert||t._startAt.render(e,!0,i))}function Ha(t){return t._repeat?wt(t._tTime,t=t.duration()+t._rDelay)*t:0}function Ja(t,e){return(t-e._start)*e._ts+(0<=e._ts?0:e._dirty?e.totalDuration():e._tDur)}function Ka(t){return t._end=la(t._start+(t._tDur/Math.abs(t._ts||t._rts||q)||0))}function La(t,e){var r=t._dp;return r&&r.smoothChildTiming&&t._ts&&(t._start=la(r._time-(0q)&&e.render(r,!0)),Da(t,e)._dp&&t._initted&&t._time>=t._dur&&t._ts){if(t._dur(n=Math.abs(n))&&(a=i,o=n);return a}function wb(t){return Ca(t),t.scrollTrigger&&t.scrollTrigger.kill(!!I),t.progress()<1&&Dt(t,"onInterrupt"),t}function zb(t){if(t)if(t=!t.name&&t.default||t,x()||t.headless){var e=t.name,r=s(t),i=e&&!r&&t.init?function(){this._props=[]}:t,n={init:V,render:ve,add:Jt,kill:Te,modifier:ye,rawVars:0},a={targetTest:0,get:0,getSetter:le,aliases:{},register:0};if(Lt(),t!==i){if(mt[e])return;ta(i,ta(xa(t,n),a)),bt(i.prototype,bt(n,xa(t,a))),mt[i.prop=e]=i,t.targetTest&&(yt.push(i),ct[e]=1),e=("css"===e?"CSS":e.charAt(0).toUpperCase()+e.substr(1))+"Plugin"}U(e,i),t.register&&t.register(Fe,i,we)}else St.push(t)}function Cb(t,e,r){return(6*(t+=t<0?1:1>16,e>>8&zt,e&zt]:0:Et.black;if(!p){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),Et[e])p=Et[e];else if("#"===e.charAt(0)){if(e.length<6&&(e="#"+(n=e.charAt(1))+n+(a=e.charAt(2))+a+(s=e.charAt(3))+s+(5===e.length?e.charAt(4)+e.charAt(4):"")),9===e.length)return[(p=parseInt(e.substr(1,6),16))>>16,p>>8&zt,p&zt,parseInt(e.substr(7),16)/255];p=[(e=parseInt(e.substr(1),16))>>16,e>>8&zt,e&zt]}else if("hsl"===e.substr(0,3))if(p=c=e.match(rt),r){if(~e.indexOf("="))return p=e.match(it),i&&p.length<4&&(p[3]=1),p}else o=+p[0]%360/360,u=p[1]/100,n=2*(h=p[2]/100)-(a=h<=.5?h*(u+1):h+u-h*u),3=X?u.endTime(!1):t._dur;return r(e)&&(isNaN(e)||e in o)?(a=e.charAt(0),s="%"===e.substr(-1),n=e.indexOf("="),"<"===a||">"===a?(0<=n&&(e=e.replace(/=/,"")),("<"===a?u._start:u.endTime(0<=u._repeat))+(parseFloat(e.substr(1))||0)*(s?(n<0?u:i).totalDuration()/100:1)):n<0?(e in o||(o[e]=h),o[e]):(a=parseFloat(e.charAt(n-1)+e.substr(n+1)),s&&i&&(a=a/100*($(i)?i[0]:i).totalDuration()),1=r&&te)return i;i=i._next}else for(i=t._last;i&&i._start>=r;){if("isPause"===i.data&&i._start=n._start)&&n._ts&&h!==n){if(n.parent!==this)return this.render(t,e,r);if(n.render(0=this.totalDuration()||!v&&_)&&(f!==this._start&&Math.abs(l)===Math.abs(this._ts)||this._lock||(!t&&g||!(v===m&&0=i&&(a instanceof te?e&&n.push(a):(r&&n.push(a),t&&n.push.apply(n,a.getChildren(!0,e,r)))),a=a._next;return n},e.getById=function getById(t){for(var e=this.getChildren(1,1,1),r=e.length;r--;)if(e[r].vars.id===t)return e[r]},e.remove=function remove(t){return r(t)?this.removeLabel(t):s(t)?this.killTweensOf(t):(t.parent===this&&Ba(this,t),t===this._recent&&(this._recent=this._last),Da(this))},e.totalTime=function totalTime(t,e){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=la(It.time-(0r:!r||s.isActive())&&n.push(s):(i=s.getTweensOf(a,r)).length&&n.push.apply(n,i),s=s._next;return n},e.tweenTo=function tweenTo(t,e){e=e||{};var r,i=this,n=Ot(i,t),a=e.startAt,s=e.onStart,o=e.onStartParams,u=e.immediateRender,h=te.to(i,ta({ease:e.ease||"none",lazy:!1,immediateRender:!1,time:n,overwrite:"auto",duration:e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale())||q,onStart:function onStart(){if(i.pause(),!r){var t=e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale());h._dur!==t&&Ua(h,t,0,1).render(h._time,!0,!0),r=1}s&&s.apply(h,o||[])}},e));return u?h.render(0):h},e.tweenFromTo=function tweenFromTo(t,e,r){return this.tweenTo(e,ta({startAt:{time:Ot(this,t)}},r))},e.recent=function recent(){return this._recent},e.nextLabel=function nextLabel(t){return void 0===t&&(t=this._time),ub(this,Ot(this,t))},e.previousLabel=function previousLabel(t){return void 0===t&&(t=this._time),ub(this,Ot(this,t),1)},e.currentLabel=function currentLabel(t){return arguments.length?this.seek(t,!0):this.previousLabel(this._time+q)},e.shiftChildren=function shiftChildren(t,e,r){void 0===r&&(r=0);var i,n=this._first,a=this.labels;for(t=la(t);n;)n._start>=r&&(n._start+=t,n._end+=t),n=n._next;if(e)for(i in a)a[i]>=r&&(a[i]+=t);return Da(this)},e.invalidate=function invalidate(t){var e=this._first;for(this._lock=0;e;)e.invalidate(t),e=e._next;return i.prototype.invalidate.call(this,t)},e.clear=function clear(t){void 0===t&&(t=!0);for(var e,r=this._first;r;)e=r._next,this.remove(r),r=e;return this._dp&&(this._time=this._tTime=this._pTime=0),t&&(this.labels={}),Da(this)},e.totalDuration=function totalDuration(t){var e,r,i,n=0,a=this,s=a._last,o=X;if(arguments.length)return a.timeScale((a._repeat<0?a.duration():a.totalDuration())/(a.reversed()?-t:t));if(a._dirty){for(i=a.parent;s;)e=s._prev,s._dirty&&s.totalDuration(),o<(r=s._start)&&a._sort&&s._ts&&!a._lock?(a._lock=1,Na(a,s,r-s._delay,1)._lock=0):o=r,r<0&&s._ts&&(n-=r,(!i&&!a._dp||i&&i.smoothChildTiming)&&(a._start+=la(r/a._ts),a._time-=r,a._tTime-=r),a.shiftChildren(-r,!1,-Infinity),o=0),s._end>n&&s._ts&&(n=s._end),s=e;Ua(a,a===L&&a._time>n?a._time:n,1,1),a._dirty=0}return a._tDur},Timeline.updateRoot=function updateRoot(t){if(L._ts&&(qa(L,Ja(t,L)),f=It.frame),It.frame>=vt){vt+=N.autoSleep||120;var e=L._first;if((!e||!e._ts)&&N.autoSleep&&It._listeners.length<2){for(;e&&!e._ts;)e=e._next;e||It.sleep()}}},Timeline}(qt);ta(Zt.prototype,{_lock:0,_hasPause:0,_forcing:0});function dc(t,e,i,n,a,o){var u,h,l,f;if(mt[t]&&!1!==(u=new mt[t]).init(a,u.rawVars?e[t]:function _processVars(t,e,i,n,a){if(s(t)&&(t=Gt(t,a,e,i,n)),!v(t)||t.style&&t.nodeType||$(t)||K(t))return r(t)?Gt(t,a,e,i,n):t;var o,u={};for(o in t)u[o]=Gt(t[o],a,e,i,n);return u}(e[t],n,a,o,i),i,n,o)&&(i._pt=h=new we(i._pt,a,t,0,1,u.render,u,0,u.priority),i!==d))for(l=i._ptLookup[i._targets.indexOf(a)],f=u._props.length;f--;)l[u._props[f]]=h;return u}function jc(t,r,e,i){var n,a,s=r.ease||i||"power1.inOut";if($(r))a=e[t]||(e[t]=[]),r.forEach(function(t,e){return a.push({t:e/(r.length-1)*100,v:t,e:s})});else for(n in r)a=e[n]||(e[n]=[]),"ease"===n||a.push({t:parseFloat(t),v:r[n],e:s})}var Wt,Ht,Jt=function _addPropTween(t,e,i,n,a,o,u,h,l,f){s(n)&&(n=n(a||0,t,o));var d,c=t[e],p="get"!==i?i:s(c)?l?t[e.indexOf("set")||!s(t["get"+e.substr(3)])?e:"get"+e.substr(3)](l):t[e]():c,_=s(c)?l?ue:re:ee;if(r(n)&&(~n.indexOf("random(")&&(n=rb(n)),"="===n.charAt(1)&&(!(d=ma(p,n)+(_a(p)||0))&&0!==d||(n=d))),!f||p!==n||Ht)return isNaN(p*n)||""===n?(c||e in t||S(e,n),function _addComplexStringPropTween(t,e,r,i,n,a,s){var o,u,h,l,f,d,c,p,_=new we(this._pt,t,e,0,1,ge,null,n),m=0,g=0;for(_.b=r,_.e=i,r+="",(c=~(i+="").indexOf("random("))&&(i=rb(i)),a&&(a(p=[r,i],t,e),r=p[0],i=p[1]),u=r.match(at)||[];o=at.exec(i);)l=o[0],f=i.substring(m,o.index),h?h=(h+1)%5:"rgba("===f.substr(-5)&&(h=1),l!==u[g++]&&(d=parseFloat(u[g-1])||0,_._pt={_next:_._pt,p:f||1===g?f:",",s:d,c:"="===l.charAt(1)?ma(d,l)-d:parseFloat(l)-d,m:h&&h<4?Math.round:0},m=at.lastIndex);return _.c=m")}),s.duration();else{for(l in u={},k)"ease"===l||"easeEach"===l||jc(l,k[l],u,k.easeEach);for(l in u)for(D=u[l].sort(function(t,e){return t.t-e.t}),o=E=0;o=t._tDur||e<0)&&t.ratio===u&&(u&&Ca(t,1),r||I||(Dt(t,u?"onComplete":"onReverseComplete",!0),t._prom&&t._prom()))}else t._zTime||(t._zTime=e)}(this,t,e,r);return this},e.targets=function targets(){return this._targets},e.invalidate=function invalidate(t){return t&&this.vars.runBackwards||(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(t),R.prototype.invalidate.call(this,t)},e.resetTo=function resetTo(t,e,r,i,n){c||It.wake(),this._ts||this.play();var a,s=Math.min(this._dur,(this._dp._time-this._start)*this._ts);return this._initted||Qt(this,s),a=this._ease(s/this._dur),function _updatePropTweens(t,e,r,i,n,a,s,o){var u,h,l,f,d=(t._pt&&t._ptCache||(t._ptCache={}))[e];if(!d)for(d=t._ptCache[e]=[],l=t._ptLookup,f=t._targets.length;f--;){if((u=l[f][e])&&u.d&&u.d._pt)for(u=u.d._pt;u&&u.p!==e&&u.fp!==e;)u=u._next;if(!u)return Ht=1,t.vars[e]="+=0",Qt(t,s),Ht=0,o?T(e+" not eligible for reset"):1;d.push(u)}for(f=d.length;f--;)(u=(h=d[f])._pt||h).s=!i&&0!==i||n?u.s+(i||0)+a*u.c:i,u.c=r-u.s,h.e&&(h.e=ka(r)+_a(h.e)),h.b&&(h.b=u.s+_a(h.b))}(this,t,e,r,i,a,s,n)?this.resetTo(t,e,r,i,1):(La(this,0),this.parent||Aa(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},e.kill=function kill(t,e){if(void 0===e&&(e="all"),!(t||e&&"all"!==e))return this._lazy=this._pt=0,this.parent?wb(this):this.scrollTrigger&&this.scrollTrigger.kill(!!I),this;if(this.timeline){var i=this.timeline.totalDuration();return this.timeline.killTweensOf(t,e,Wt&&!0!==Wt.vars.overwrite)._first||wb(this),this.parent&&i!==this.timeline.totalDuration()&&Ua(this,this._dur*this.timeline._tDur/i,0,1),this}var n,a,s,o,u,h,l,f=this._targets,d=t?Pt(t):f,c=this._ptLookup,p=this._pt;if((!e||"all"===e)&&function _arraysMatch(t,e){for(var r=t.length,i=r===e.length;i&&r--&&t[r]===e[r];);return r<0}(f,d))return"all"===e&&(this._pt=0),wb(this);for(n=this._op=this._op||[],"all"!==e&&(r(e)&&(u={},ja(e,function(t){return u[t]=1}),e=u),e=function _addAliasesToVars(t,e){var r,i,n,a,s=t[0]?ha(t[0]).harness:0,o=s&&s.aliases;if(!o)return e;for(i in r=bt({},e),o)if(i in r)for(n=(a=o[i].split(",")).length;n--;)r[a[n]]=r[i];return r}(f,e)),l=f.length;l--;)if(~d.indexOf(f[l]))for(u in a=c[l],"all"===e?(n[l]=e,o=a,s={}):(s=n[l]=n[l]||{},o=e),o)(h=a&&a[u])&&("kill"in h.d&&!0!==h.d.kill(u)||Ba(this,h,"_pt"),delete a[u]),"all"!==s&&(s[u]=1);return this._initted&&!this._pt&&p&&wb(this),this},Tween.to=function to(t,e,r){return new Tween(t,e,r)},Tween.from=function from(t,e){return Ya(1,arguments)},Tween.delayedCall=function delayedCall(t,e,r,i){return new Tween(e,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:t,onComplete:e,onReverseComplete:e,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:i})},Tween.fromTo=function fromTo(t,e,r){return Ya(2,arguments)},Tween.set=function set(t,e){return e.duration=0,e.repeatDelay||(e.repeat=0),new Tween(t,e)},Tween.killTweensOf=function killTweensOf(t,e,r){return L.killTweensOf(t,e,r)},Tween}(qt);ta(te.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),ja("staggerTo,staggerFrom,staggerFromTo",function(r){te[r]=function(){var t=new Zt,e=Ct.call(arguments,0);return e.splice("staggerFromTo"===r?5:4,0,0),t[r].apply(t,e)}});function rc(t,e,r){return t.setAttribute(e,r)}function zc(t,e,r,i){i.mSet(t,e,i.m.call(i.tween,r,i.mt),i)}var ee=function _setterPlain(t,e,r){return t[e]=r},re=function _setterFunc(t,e,r){return t[e](r)},ue=function _setterFuncWithParam(t,e,r,i){return t[e](i.fp,r)},le=function _getSetter(t,e){return s(t[e])?re:u(t[e])&&t.setAttribute?rc:ee},ce=function _renderPlain(t,e){return e.set(e.t,e.p,Math.round(1e6*(e.s+e.c*t))/1e6,e)},_e=function _renderBoolean(t,e){return e.set(e.t,e.p,!!(e.s+e.c*t),e)},ge=function _renderComplexString(t,e){var r=e._pt,i="";if(!t&&e.b)i=e.b;else if(1===t&&e.e)i=e.e;else{for(;r;)i=r.p+(r.m?r.m(r.s+r.c*t):Math.round(1e4*(r.s+r.c*t))/1e4)+i,r=r._next;i+=e.c}e.set(e.t,e.p,i,e)},ve=function _renderPropTweens(t,e){for(var r=e._pt;r;)r.r(t,r.d),r=r._next},ye=function _addPluginModifier(t,e,r,i){for(var n,a=this._pt;a;)n=a._next,a.p===i&&a.modifier(t,e,r),a=n},Te=function _killPropTweensOf(t){for(var e,r,i=this._pt;i;)r=i._next,i.p===t&&!i.op||i.op===t?Ba(this,i,"_pt"):i.dep||(e=1),i=r;return!e},be=function _sortPropTweensByPriority(t){for(var e,r,i,n,a=t._pt;a;){for(e=a._next,r=i;r&&r.pr>a.pr;)r=r._next;(a._prev=r?r._prev:n)?a._prev._next=a:i=a,(a._next=r)?r._prev=a:n=a,a=e}t._pt=i},we=(PropTween.prototype.modifier=function modifier(t,e,r){this.mSet=this.mSet||this.set,this.set=zc,this.m=t,this.mt=r,this.tween=e},PropTween);function PropTween(t,e,r,i,n,a,s,o,u){this.t=e,this.s=i,this.c=n,this.p=r,this.r=a||ce,this.d=s||this,this.set=o||ee,this.pr=u||0,(this._next=t)&&(t._prev=this)}ja(Tt+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(t){return ct[t]=1}),ht.TweenMax=ht.TweenLite=te,ht.TimelineLite=ht.TimelineMax=Zt,L=new Zt({sortChildren:!1,defaults:j,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),N.stringFilter=Ib;function Hc(t){return(Oe[t]||Me).map(function(t){return t()})}function Ic(){var t=Date.now(),o=[];2 Path: + """Generates a warm Fmaj9 stereo ambient synth pad WAV when offline.""" + out_wav.parent.mkdir(parents=True, exist_ok=True) + dur = max(6.0, min(duration_sec, 90.0)) + n = int(sr * dur) + t = np.linspace(0.0, dur, n, endpoint=False) + + # Fmaj9 warm chord frequencies (F3, A3, C4, E4, G4) + freqs = [174.61, 220.00, 261.63, 329.63, 392.00] + amps = [0.32, 0.24, 0.22, 0.16, 0.12] + left = np.zeros(n) + right = np.zeros(n) + + for idx, (f, a) in enumerate(zip(freqs, amps)): + lfo = 0.82 + 0.18 * np.sin(2.0 * np.pi * (0.09 + idx * 0.03) * t + idx) + left += np.sin(2.0 * np.pi * f * t) * a * lfo + right += np.sin(2.0 * np.pi * (f * 1.0012) * t + 0.4 * idx) * a * lfo + + fade = np.minimum(t / 1.5, 1.0) * np.minimum((dur - t) / 1.8, 1.0) + left *= fade + right *= fade + + peak = max(float(np.max(np.abs(left))), float(np.max(np.abs(right))), 1e-6) + stereo = np.stack([left / peak * 0.65, right / peak * 0.65], axis=-1) + pcm = np.clip(stereo * 32767.0, -32768, 32767).astype(np.int16) + + with wave.open(str(out_wav), "wb") as wf: + wf.setnchannels(2) + wf.setsampwidth(2) + wf.setframerate(sr) + wf.writeframes(pcm.tobytes()) + return out_wav + + +def get_or_create_bgm_source(cache_dir: Path, mood: str = "focused", duration_sec: float = 60.0) -> tuple[Path, str]: + """Returns `(audio_path, title)` for ambient BGM, downloading once or synthesizing offline.""" + cache_dir.mkdir(parents=True, exist_ok=True) + track_id, title, url = DENO_PRESET_TRACKS.get(mood.lower(), DENO_PRESET_TRACKS["focused"]) + mp3_path = cache_dir / f"{track_id}.mp3" + + if mp3_path.exists() and mp3_path.stat().st_size > 4096: + return mp3_path, title + + try: + req = urllib.request.Request(url, headers={"User-Agent": "Deck2Video/1.0"}) + with urllib.request.urlopen(req, timeout=15) as resp: + data = resp.read() + if len(data) > 4096: + mp3_path.write_bytes(data) + return mp3_path, title + except Exception as exc: + print(f"[BGM Info] Offline or CDN unreachable ({exc}); using procedural ambient pad.") + + wav_fallback = cache_dir / "offline_ambient_pad.wav" + synth_offline_ambient_pad(wav_fallback, duration_sec=duration_sec) + return wav_fallback, "Procedural Fmaj9 Ambient Pad" diff --git a/deck2video_offline_full.zip b/deck2video_offline_full.zip new file mode 100644 index 0000000000000000000000000000000000000000..56591b82f5384a6d1a691f8cdcb7d6b0b2f49b0a --- /dev/null +++ b/deck2video_offline_full.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62bd0d702b10d8008bdb33fb4ec32732fa233099383ede8d7505d9a00fecfaff +size 91651717 diff --git a/html_builder.py b/html_builder.py new file mode 100644 index 0000000000000000000000000000000000000000..36c1abbe3d641527885b21578775de2cf65a42de --- /dev/null +++ b/html_builder.py @@ -0,0 +1,1572 @@ +""" +HyperFrames HTML Composition Compiler (`html_builder.py`) +Compiles an enriched `DeckSpec` (with exact TTS beat timings & SFX cues) into +a deterministic, WCAG-compliant 1920x1080 HyperFrames `index.html` composition +inspired by modern Korean AI presentation videos (Dark Glass UI, 3D Particle +Horizon Wave, Top Chapter Progress Bar, 5 Scene Archetypes, Dual KR/EN Captions, +and Multi-Track Voiceover + UI SFX + BGM Audio). +""" + +from __future__ import annotations +import html +import json +import shutil +import urllib.request +from pathlib import Path +from typing import Any + + +PIPELINE_ROOT = Path(__file__).resolve().parent +PRETENDARD_URL = "https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/packages/pretendard/dist/web/variable/woff2/PretendardVariable.woff2" +GSAP_URL = "https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js" + + +def _ensure_static_vendor_assets() -> tuple[Path, Path]: + font_src = PIPELINE_ROOT / "assets" / "fonts" / "PretendardVariable.woff2" + gsap_src = PIPELINE_ROOT / "assets" / "js" / "gsap.min.js" + font_src.parent.mkdir(parents=True, exist_ok=True) + gsap_src.parent.mkdir(parents=True, exist_ok=True) + if not font_src.exists() or font_src.stat().st_size < 100_000: + urllib.request.urlretrieve(PRETENDARD_URL, str(font_src)) + if not gsap_src.exists() or gsap_src.stat().st_size < 10_000: + urllib.request.urlretrieve(GSAP_URL, str(gsap_src)) + return font_src, gsap_src + + +def _esc(val: Any) -> str: + return html.escape(str(val or ""), quote=True) + + +def _split_card_item(raw: str, idx: int) -> tuple[str, str]: + if "|" in raw: + left, right = [x.strip() for x in raw.split("|", 1)] + return left, right + if "Β·" in raw: + left, right = [x.strip() for x in raw.split("Β·", 1)] + return left, right + words = raw.strip().split() + if len(words) >= 3: + return " ".join(words[:2]), " ".join(words[2:]) + return f"λͺ¨λ“ˆ {idx + 1:02d}", raw.strip() + + +def _render_arc_cards_scene(slide: dict[str, Any], s_idx: int) -> str: + sid = f"s{s_idx + 1}" + items = slide.get("bullets") or ["기획 λͺ¨λ“ˆ | ꡬ쑰화", "λͺ¨μ…˜ λͺ¨λ“ˆ | λ Œλ”λ§", "μ‚¬μš΄λ“œ λͺ¨λ“ˆ | 효과음"] + items = items[:9] + n_items = len(items) + mid = (n_items - 1) / 2.0 + + cards_html = [] + for i, item in enumerate(items): + role_short, role_desc = _split_card_item(item, i) + offset = i - mid + rot_y = round(offset * -7.2, 2) + trans_z = round(-abs(offset) * 22.0, 1) + ascii_prefix = "".join(ch for ch in role_short if ch.isascii() and ch.isalnum()) + badge_word = ascii_prefix[:3].upper() if len(ascii_prefix) >= 2 else role_short[:2] + cards_html.append(f""" +
+
+
{_esc(badge_word)}
+
{_esc(role_short)}
+
{_esc(role_desc[:14])}
+
가동 쀑
+
+
""") + + return f""" +
+
+ + {_esc(slide.get("badge", "AI SYNC ENGINE"))} +
+
+ {_esc(slide.get("stat_prefix", "AI λͺ¨λ“ˆ"))} + {int(slide.get("stat_number", n_items))} + {_esc(slide.get("stat_suffix", "μ’…"))} +
+
+ {"".join(cards_html)} +
+
""" + + +def _render_mockup_steps_scene(slide: dict[str, Any], s_idx: int) -> str: + sid = f"s{s_idx + 1}" + raw_items = slide.get("bullets") or [ + "μ •μ§€ μŠ¬λΌμ΄λ“œμ˜ ν•œκ³„ | 초반 μ΄νƒˆ λ°œμƒ", + "μˆ˜λ™ νƒ€μž„λΌμΈ νŽΈμ§‘ | μžλ§‰Β·νš¨κ³ΌμŒ 병λͺ©", + "μ½”λ“œ 기반 μžλ™ 동기화 | μ¦‰μ‹œ MP4 μ™„μ„±", + ] + while len(raw_items) < 3: + raw_items.append(f"핡심 포인트 {len(raw_items) + 1} | μžλ™ 동기화 처리") + step_items = raw_items[:3] + + icons = ["01", "02", "03"] + right_cards = [] + left_rows = [] + for i, raw in enumerate(step_items): + head, desc = _split_card_item(raw, i) + right_cards.append(f""" +
+
{icons[i]}
+
+
{_esc(head)}
+
{_esc(desc)}
+
+
""") + left_rows.append(f""" +
+
S{i + 1}
+
+
{_esc(head[:16])}
+
+
+
{i + 1}
+
""") + + return f""" +
+
+
+ + {_esc(slide.get("badge", "Slide Sync Monitor"))} +
+
+ {"".join(left_rows)} +
+
+
+ {"".join(right_cards)} +
+
""" + + +def _render_book_quote_scene(slide: dict[str, Any], s_idx: int) -> str: + sid = f"s{s_idx + 1}" + quote = slide.get("highlight_quote") or slide.get("title", "") + bullets = slide.get("bullets") or [] + left_p1 = bullets[0] if len(bullets) > 0 else "λ°˜λ³΅λ˜λŠ” λ°œν‘œ 자료 μ œμž‘ 과정을 뢄석해 μΌκ΄€λœ μ‹œκ° μ‹œμŠ€ν…œμœΌλ‘œ μ •μ˜ν•©λ‹ˆλ‹€." + left_p2 = bullets[1] if len(bullets) > 1 else "폰트 크기, μ—¬λ°±, 챕터 ν‘œμ‹œμ€„, 효과음 타이밍이 ν•˜λ‚˜μ˜ κ·œμΉ™ 파일둜 ν†΅ν•©λ©λ‹ˆλ‹€." + + return f""" +
+
+ + {_esc(slide.get("badge", "CHAPTER Β· CORE PRINCIPLE"))} +
+
+
+
+
WORKFLOW MANUAL
+
{_esc(slide.get("title", ""))}
+

{_esc(left_p1)}

+

{_esc(left_p2)}

+
104
+
+
+
+
KEY RULE Β· SYNC
+
+
+

{_esc(quote)}

+
+

ν•œ 번 κ²€μ¦λœ λͺ¨μ…˜κ³Ό μ‚¬μš΄λ“œ μ„€κ³„λŠ” μ½”λ“œλ‘œ κ³ μ •λ˜μ–΄ λ‹€μŒ κ΅μ•ˆμ—μ„œλ„ 였차 없이 μž¬ν˜„λ©λ‹ˆλ‹€.

+
105
+
+
+
+
""" + + +def _render_terminal_flow_scene(slide: dict[str, Any], s_idx: int) -> str: + sid = f"s{s_idx + 1}" + cmd_str = slide.get("command", "python3 produce_deck_video.py --input lecture.pptx --sfx on") + f_left = slide.get("flow_left", "νŒŒμ›Œν¬μΈνŠΈ Β· κ΅μ•ˆ") + f_left_sub = slide.get("flow_left_sub", "μŠ¬λΌμ΄λ“œ Β· λ°œν‘œλ…ΈνŠΈ νŒŒμ‹±") + f_right = slide.get("flow_right", "1080p λͺ¨μ…˜ MP4") + f_right_sub = slide.get("flow_right_sub", "HTML λ Œλ”λ§ + 효과음 싱크") + + return f""" +
+
+
CLI μžλ™ν™” μ—”μ§„
+
SFX Β· μžλ§‰ μ‹€μ‹œκ°„ ν•©μ„±
+
+
+
+
+ + + +
+
Deck-to-Video Compiler
+
+
+
+ > +
+ {_esc(cmd_str)} +
+ +
+
+ βœ“ μŠ¬λΌμ΄λ“œ νŒŒμ‹± μ™„λ£Œ β†’ μŒμ„± νƒ€μž„μŠ€νƒ¬ν”„ μ •λ ¬ β†’ 6μ’… UI 효과음 λ―Ήμ‹± β†’ 1080p λ Œλ”λ§ +
+
+
+
+
+
INPUT
+
{_esc(f_left)}
+
{_esc(f_left_sub)}
+
+
+
+
+
+
+
OUTPUT
+
{_esc(f_right)}
+
{_esc(f_right_sub)}
+
+
+
""" + + +def _render_metric_summary_scene(slide: dict[str, Any], s_idx: int) -> str: + sid = f"s{s_idx + 1}" + raw_items = slide.get("bullets") or [ + "κ΅μ•ˆ μžλ™ νŒŒμ‹± | PPTX Β· λ§ˆν¬λ‹€μš΄ μ¦‰μ‹œ λ³€ν™˜", + "λͺ¨μ…˜ Β· 효과음 | 3D μ›¨μ΄λΈŒ Β· λ„€μ˜¨ UI μ‚¬μš΄λ“œ", + "무손싀 MP4 | 1920x1080 κ³ ν™”μ§ˆ 직좜λ ₯", + ] + while len(raw_items) < 3: + raw_items.append(f"핡심 단계 {len(raw_items) + 1} | μ›μŠ€ν†± νŒŒμ΄ν”„λΌμΈ") + + pillars_html = [] + for i, raw in enumerate(raw_items[:3]): + head, desc = _split_card_item(raw, i) + pillars_html.append(f""" +
+
{i + 1:02d}
+
+
{_esc(head)}
+
{_esc(desc)}
+
""") + + sub_summary = slide.get("subtitle") or slide.get("title", "핡심 μš”μ•½ Β· 3단계 μžλ™ν™”") + return f""" +
+
+ {"".join(pillars_html)} +
+ +
""" + + +def compile_hyperframes_project(spec: dict[str, Any], project_dir: Path) -> Path: + """ + Writes `index.html` and copies required fonts/JS assets into `project_dir`. + Returns path to `index.html`. + """ + fonts_dst = project_dir / "assets" / "fonts" + js_dst = project_dir / "assets" / "js" + fonts_dst.mkdir(parents=True, exist_ok=True) + js_dst.mkdir(parents=True, exist_ok=True) + + font_src, gsap_src = _ensure_static_vendor_assets() + if font_src.exists(): + shutil.copy2(font_src, fonts_dst / "PretendardVariable.woff2") + if gsap_src.exists(): + shutil.copy2(gsap_src, js_dst / "gsap.min.js") + + total_dur = spec["total_duration"] + chapters = spec.get("chapters", []) + + # 1. Top Chapter HUD Bar + chapter_tabs_html = [] + for c_idx, ch in enumerate(chapters): + chapter_tabs_html.append(f""" +
+
+ {_esc(ch['num'])} + {_esc(ch['label'])} +
+
+
+
+
""") + + # 2. Scene Clips (Track 0) + scenes_html = [] + for s_idx, slide in enumerate(spec["slides"]): + arch = slide["archetype"] + if arch == "arc_cards": + inner_markup = _render_arc_cards_scene(slide, s_idx) + elif arch == "mockup_steps": + inner_markup = _render_mockup_steps_scene(slide, s_idx) + elif arch == "book_quote": + inner_markup = _render_book_quote_scene(slide, s_idx) + elif arch == "terminal_flow": + inner_markup = _render_terminal_flow_scene(slide, s_idx) + else: + inner_markup = _render_metric_summary_scene(slide, s_idx) + + scenes_html.append(f""" +
{inner_markup} +
""") + + # 3. Subtitle Clips (Track 1) & Voiceover Audio Clips (Track 2) + captions_html = [] + vo_audio_html = [] + for s_idx, slide in enumerate(spec["slides"]): + for b_idx, beat in enumerate(slide["beats"]): + cid = f"cap-s{s_idx + 1}-b{b_idx + 1}" + sub_en_markup = ( + f'
{_esc(beat["sub_en"])}
' + if beat.get("sub_en") + else "" + ) + # Extend subtitle window slightly across inter-beat breath for smooth reading + next_start = ( + slide["beats"][b_idx + 1]["start"] + if b_idx + 1 < len(slide["beats"]) + else slide["end"] + ) + cap_dur = round(max(0.25, next_start - beat["start"] - 0.02), 3) + captions_html.append(f""" +
+
+
{_esc(beat['sub_ko'])}
+ {sub_en_markup} +
+
""") + + vo_audio_html.append(f""" + """) + + # 4. SFX Audio Clips (Track 3) & BGM Bed (Track 4) + sfx_audio_html = [] + for ev in spec.get("sfx_events", []): + sfx_audio_html.append(f""" + """) + + bgm_html = "" + if spec.get("bgm"): + bgm = spec["bgm"] + bgm_html = f""" + """ + + # Embed compact JSON timeline spec for deterministic GSAP choreography + choreo_payload = { + "totalDuration": total_dur, + "chaptersCount": len(chapters), + "slides": [ + { + "index": i, + "chapterIndex": s["chapter_index"], + "archetype": s["archetype"], + "start": s["start"], + "duration": s["duration"], + "end": s["end"], + "statNumber": int(s.get("stat_number", 9)), + "bulletsCount": len(s.get("bullets", [])), + "beats": [ + {"start": b["start"], "duration": b["duration"], "end": b["end"]} + for b in s["beats"] + ], + } + for i, s in enumerate(spec["slides"]) + ], + } + choreo_json = json.dumps(choreo_payload, ensure_ascii=False) + + html_doc = f""" + + + + + {_esc(spec.get("title", "AI SYNC Presentation"))} + + + + +
+
+ + +
+ {"".join(chapter_tabs_html)} +
+ + {"".join(scenes_html)} + {"".join(captions_html)} + {"".join(vo_audio_html)} + {"".join(sfx_audio_html)} + {bgm_html} +
+ + + + +""" + + index_path = project_dir / "index.html" + index_path.write_text(html_doc, encoding="utf-8") + return index_path diff --git a/ingest_parser.py b/ingest_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..40c1efb349b154965a7496fe81301398bbbd5365 --- /dev/null +++ b/ingest_parser.py @@ -0,0 +1,731 @@ +""" +Universal Document-to-Deck Ingestion Parser (`ingest_parser.py`) +Supports: + - PowerPoint (.pptx) β€” Slides, bullets, tables, speaker notes + - Word (.docx) β€” Headings, paragraphs, bullet lists, quotes, tables + - Markdown (.md/.txt) β€” #, ##, -, >, tables + - HTML (.html/.htm) β€” Reveal.js
, .slide, or

/

/
    /

    /

    + - JSON (.json) β€” Direct DeckSpec schema + +Maps every extracted slide into one of 5 visual motion archetypes: + 1. `arc_cards` β€” 3D cylindrical card carousel + glowing big counter + 2. `mockup_steps` β€” Left app/slide list mockup + Right 3-card sequential focus glow + 3. `book_quote` β€” 3D perspective open manual/book spread + cyan highlighter sweep + 4. `terminal_flow` β€” Dark glass CLI/code window typing + glowing node flow diagram + 5. `metric_summary` β€” 3 neon glass pillars + final takeaway callout badge +""" + +from __future__ import annotations +import json +import re +from pathlib import Path +from typing import Any + + +ARCHETYPES = ["arc_cards", "mockup_steps", "book_quote", "terminal_flow", "metric_summary"] + + +def _split_sentences(text: str) -> list[str]: + text = re.sub(r"\s+", " ", text.strip()) + if not text: + return [] + parts = re.split(r"(?<=[.!?λ‹€μš”μ£ ])\s+", text) + cleaned = [p.strip() for p in parts if p.strip()] + return cleaned if cleaned else [text] + + +def _clean_chapter_label(raw_ch: str) -> str: + cleaned = re.sub(r"^\d+\s*[.Β·\-:]?\s*", "", raw_ch.strip()).strip() + return (cleaned or raw_ch.strip())[:16] + + +def _infer_archetype(idx: int, title: str, bullets: list[str], notes: str) -> str: + combined = f"{title} {' '.join(bullets)} {notes}".lower() + if idx == 0 and (re.search(r"\d+", title) or len(bullets) >= 5): + return "arc_cards" + if any(k in combined for k in ["λͺ…λ Ήμ–΄", "μ½”λ“œ", "νŒŒμ΄ν”„λΌμΈ", "cli", "터미널", "μžλ™ν™”", "μ‹€ν–‰", "command", "python", "claude", "μ›Œν¬ν”Œλ‘œμš°"]): + return "terminal_flow" + if any(k in combined for k in ["원칙", "μ±…", "맀뉴얼", "μ •μ˜", "인용", "핡심 λ¬Έμž₯", "chapter", "법칙", "μ² ν•™"]): + return "book_quote" + if any(k in combined for k in ["μš”μ•½", "정리", "κ²°λ‘ ", "3κ°€μ§€", "핡심 3", "마무리", "체크리슀트"]): + return "metric_summary" + if len(bullets) >= 5: + return "arc_cards" + return ARCHETYPES[idx % len(ARCHETYPES)] + + +def _parse_notes_into_beats(title: str, bullets: list[str], notes_lines: list[str]) -> list[dict[str, str]]: + beats: list[dict[str, str]] = [] + for ln in notes_lines: + ln = ln.strip() + if not ln: + continue + if "||" in ln: + ko_part, en_part = [x.strip() for x in ln.split("||", 1)] + beats.append({"narration": ko_part, "sub_ko": ko_part, "sub_en": en_part}) + else: + for sent in _split_sentences(ln): + beats.append({"narration": sent, "sub_ko": sent, "sub_en": ""}) + + if not beats: + intro_sent = title if title.endswith(("λ‹€.", "μš”.", "μ£ .", "?")) else f"{title}에 λŒ€ν•΄ ν•΅μ‹¬λ§Œ μ§šμ–΄λ³΄κ² μŠ΅λ‹ˆλ‹€." + beats.append({"narration": intro_sent, "sub_ko": title, "sub_en": ""}) + for b in bullets[:3]: + display_b = b.replace("|", " Β· ").strip() + spoken_b = b.replace("|", ", ").replace("β†’", "μ—μ„œ ").strip() + if not spoken_b.endswith(("λ‹€.", "μš”.", "μ£ .", "!", "?")): + spoken_b = f"{spoken_b}μž…λ‹ˆλ‹€." + beats.append({"narration": spoken_b, "sub_ko": display_b, "sub_en": ""}) + return beats + + +def _compile_raw_slides_to_spec(deck_title: str, raw_slides: list[dict[str, Any]]) -> dict[str, Any]: + if not raw_slides: + raw_slides = [{ + "title": deck_title, + "bullets": ["핡심 λ‚΄μš© μš”μ•½ | μžλ™ 생성 μŠ¬λΌμ΄λ“œ"], + "notes_lines": [f"{deck_title} ν”„λ ˆμ  ν…Œμ΄μ…˜μ„ μ‹œμž‘ν•©λ‹ˆλ‹€."], + "meta": {}, + }] + + chapters: list[dict[str, str]] = [] + seen_chapters: dict[str, int] = {} + for item in raw_slides: + raw_ch = item.get("meta", {}).get("CHAPTER") or item.get("chapter") or item["title"] + ch_label = _clean_chapter_label(raw_ch) + if ch_label not in seen_chapters and len(chapters) < 6: + seen_chapters[ch_label] = len(chapters) + chapters.append({ + "num": f"{len(chapters) + 1:02d}", + "label": ch_label, + }) + + slides_spec: list[dict[str, Any]] = [] + for s_idx, item in enumerate(raw_slides): + meta = item.get("meta", {}) + raw_ch = meta.get("CHAPTER") or item.get("chapter") or item["title"] + ch_label = _clean_chapter_label(raw_ch) + ch_idx = seen_chapters.get(ch_label, min(s_idx, max(len(chapters) - 1, 0))) + + bullets = item.get("bullets") or [item["title"]] + notes_lines = item.get("notes_lines", []) + archetype = meta.get("ARCHETYPE") or _infer_archetype(s_idx, item["title"], bullets, " ".join(notes_lines)) + beats = _parse_notes_into_beats(item["title"], bullets, notes_lines) + + num_match = re.search(r"^(.*?)\s*(\d+)\s*([^\d]*)$", item["title"]) + stat_prefix = meta.get("STAT_PREFIX", item["title"][:16]) + stat_number = ( + int(meta["STAT_NUM"]) + if "STAT_NUM" in meta and str(meta["STAT_NUM"]).isdigit() + else (int(num_match.group(2)) if num_match else len(bullets)) + ) + stat_suffix = meta.get("STAT_SUFFIX", num_match.group(3).strip()[:6] if num_match else "핡심") + if num_match and "STAT_PREFIX" not in meta and num_match.group(1).strip(): + stat_prefix = num_match.group(1).strip() + + slides_spec.append({ + "id": f"slide_{s_idx + 1:02d}", + "chapter_index": ch_idx, + "archetype": archetype, + "badge": meta.get("BADGE", f"SECTION {s_idx + 1:02d}"), + "title": item["title"], + "subtitle": meta.get("SUBTITLE", ""), + "stat_prefix": stat_prefix, + "stat_number": stat_number, + "stat_suffix": stat_suffix, + "bullets": bullets, + "highlight_quote": meta.get("QUOTE") or item.get("quote") or (bullets[0] if bullets else item["title"]), + "command": meta.get("COMMAND", "deck2video --input document.pptx --sfx on"), + "flow_left": meta.get("FLOW_LEFT", "원본 κ΅μ•ˆ λ¬Έμ„œ"), + "flow_left_sub": meta.get("FLOW_LEFT_SUB", "PPTX Β· DOCX Β· MD Β· HTML"), + "flow_right": meta.get("FLOW_RIGHT", "1080p λͺ¨μ…˜ MP4"), + "flow_right_sub": meta.get("FLOW_RIGHT_SUB", "HTML λ Œλ”λ§ + 효과음 싱크"), + "beats": beats, + }) + + return { + "title": deck_title, + "voice": "ko-KR-InJoonNeural", + "voice_rate": "+6%", + "bgm_mood": "focused", + "chapters": chapters, + "slides": slides_spec, + } + + +# --------------------------------------------------------------------------- +# 1. PowerPoint (.pptx) Parser +# --------------------------------------------------------------------------- +def parse_pptx_to_spec(pptx_path: Path) -> dict[str, Any]: + from pptx import Presentation + + prs = Presentation(str(pptx_path)) + raw_slides: list[dict[str, Any]] = [] + + for s_idx, slide in enumerate(prs.slides): + title = "" + if slide.shapes.title and slide.shapes.title.text.strip(): + title = slide.shapes.title.text.strip().replace("\n", " ") + + bullets: list[str] = [] + meta_tags: dict[str, str] = {} + + for shape in slide.shapes: + if shape == slide.shapes.title: + continue + if getattr(shape, "has_text_frame", False): + for para in shape.text_frame.paragraphs: + line = para.text.strip() + if not line: + continue + m_tag = re.match(r"^\[([A-Z_]+):\s*(.+)\]$", line) + if m_tag: + meta_tags[m_tag.group(1).upper()] = m_tag.group(2).strip() + else: + bullets.append(line) + elif getattr(shape, "has_table", False): + for row in shape.table.rows: + cells = [c.text.strip().replace("\n", " ") for c in row.cells if c.text.strip()] + if cells: + bullets.append(" | ".join(cells[:2]) if len(cells) >= 2 else cells[0]) + + if not title and bullets: + title = bullets.pop(0) + if not title: + title = f"μŠ¬λΌμ΄λ“œ {s_idx + 1}" + + notes_lines: list[str] = [] + if slide.has_notes_slide and slide.notes_slide.notes_text_frame: + raw_notes = slide.notes_slide.notes_text_frame.text.strip() + notes_lines = [ln.strip() for ln in raw_notes.splitlines() if ln.strip()] + + raw_slides.append({ + "title": title, + "bullets": bullets, + "notes_lines": notes_lines, + "meta": meta_tags, + }) + + deck_title = raw_slides[0]["title"] if raw_slides else pptx_path.stem + return _compile_raw_slides_to_spec(deck_title, raw_slides) + + +# --------------------------------------------------------------------------- +# 2. Microsoft Word (.docx) Parser +# --------------------------------------------------------------------------- +def parse_docx_to_spec(docx_path: Path) -> dict[str, Any]: + from docx import Document + from docx.oxml.table import CT_Tbl + from docx.oxml.text.paragraph import CT_P + from docx.table import Table + from docx.text.paragraph import Paragraph + + doc = Document(str(docx_path)) + deck_title = docx_path.stem + current_chapter = "" + raw_slides: list[dict[str, Any]] = [] + cur_slide: dict[str, Any] | None = None + + def flush_slide() -> None: + nonlocal cur_slide + if cur_slide and (cur_slide["title"] or cur_slide["bullets"] or cur_slide["notes_lines"]): + if not cur_slide["title"]: + cur_slide["title"] = cur_slide["bullets"].pop(0) if cur_slide["bullets"] else f"μ„Ήμ…˜ {len(raw_slides) + 1}" + raw_slides.append(cur_slide) + cur_slide = None + + for child in doc.element.body.iterchildren(): + if isinstance(child, CT_P): + para = Paragraph(child, doc) + text = para.text.strip() + if not text: + continue + style_name = (para.style.name if para.style else "").lower() + + if "title" in style_name and not raw_slides and cur_slide is None: + deck_title = text + continue + + if style_name.startswith("heading 1"): + flush_slide() + current_chapter = text + cur_slide = { + "title": text, + "chapter": current_chapter, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + continue + + if style_name.startswith(("heading 2", "heading 3")) or re.match(r"^(?:\d+\.|Step\s*\d+|μŠ¬λΌμ΄λ“œ\s*\d+)\s+\S+", text, re.I): + # If cur_slide was just created from Heading 1 and still empty, adopt this Heading 2 as its title + if cur_slide and not cur_slide["bullets"] and not cur_slide["notes_lines"] and cur_slide["title"] == current_chapter: + cur_slide["title"] = text + else: + flush_slide() + cur_slide = { + "title": text, + "chapter": current_chapter or text, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + continue + + if cur_slide is None: + cur_slide = { + "title": text if len(text) <= 36 else deck_title, + "chapter": current_chapter or deck_title, + "bullets": [] if len(text) <= 36 else [text], + "notes_lines": [], + "quote": "", + "meta": {}, + } + continue + + m_tag = re.match(r"^\[([A-Z_]+):\s*(.+)\]$", text) + if m_tag: + cur_slide["meta"][m_tag.group(1).upper()] = m_tag.group(2).strip() + elif "quote" in style_name or text.startswith((">", "πŸ’¬", "[λ°œν‘œλ…ΈνŠΈ]", "[λ‚΄λ ˆμ΄μ…˜]", "λ…ΈνŠΈ:")): + cleaned_note = re.sub(r"^(?:>|πŸ’¬|\[λ°œν‘œλ…ΈνŠΈ\]|\[λ‚΄λ ˆμ΄μ…˜\]|λ…ΈνŠΈ:)\s*", "", text).strip() + if "quote" in style_name and not cur_slide["quote"]: + cur_slide["quote"] = cleaned_note + cur_slide["notes_lines"].append(cleaned_note) + elif "list" in style_name or text.startswith(("- ", "β€’ ", "* ", "β–ͺ ")): + cur_slide["bullets"].append(re.sub(r"^[-β€’*β–ͺ]\s*", "", text).strip()) + else: + # Long prose sentence becomes spoken narration; concise phrase becomes bullet + if len(text) > 52 and text.endswith(("λ‹€.", "μš”.", "μ£ .", "!", "?")): + cur_slide["notes_lines"].append(text) + else: + cur_slide["bullets"].append(text) + + # Auto-chunk if a flat Word doc has too many bullets in one section + if len(cur_slide["bullets"]) >= 7 and not current_chapter: + flush_slide() + + elif isinstance(child, CT_Tbl): + tbl = Table(child, doc) + if cur_slide is None: + cur_slide = { + "title": deck_title, + "chapter": current_chapter or deck_title, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + for r_i, row in enumerate(tbl.rows): + cells = [c.text.strip().replace("\n", " ") for c in row.cells if c.text.strip()] + if not cells: + continue + if r_i == 0 and any(h in cells[0].lower() for h in ["ꡬ뢄", "ν•­λͺ©", "단계", "λͺ¨λ“ˆ", "category", "step"]): + continue + cur_slide["bullets"].append(" | ".join(cells[:2]) if len(cells) >= 2 else cells[0]) + + flush_slide() + if raw_slides and deck_title == docx_path.stem: + deck_title = raw_slides[0]["title"] + return _compile_raw_slides_to_spec(deck_title, raw_slides) + + +# --------------------------------------------------------------------------- +# 3. Markdown / Plain Text (.md / .txt) Parser +# --------------------------------------------------------------------------- +def parse_markdown_to_spec(md_path: Path) -> dict[str, Any]: + text = md_path.read_text(encoding="utf-8") + lines = text.splitlines() + deck_title = md_path.stem + current_chapter = "" + raw_slides: list[dict[str, Any]] = [] + cur_slide: dict[str, Any] | None = None + + def flush_slide() -> None: + nonlocal cur_slide + if cur_slide and (cur_slide["title"] or cur_slide["bullets"] or cur_slide["notes_lines"]): + raw_slides.append(cur_slide) + cur_slide = None + + for raw_ln in lines: + ln = raw_ln.strip() + if not ln or ln.startswith("---") or re.match(r"^\|[\s\-:|]+\|$", ln): + continue + + if ln.startswith("# ") and not ln.startswith("## "): + h1 = ln[2:].strip() + if not raw_slides and cur_slide is None and deck_title == md_path.stem: + deck_title = h1 + current_chapter = h1 + else: + flush_slide() + current_chapter = h1 + continue + + if ln.startswith(("## ", "### ")): + flush_slide() + title = ln.lstrip("#").strip() + cur_slide = { + "title": title, + "chapter": current_chapter or title, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + continue + + if cur_slide is None: + cur_slide = { + "title": deck_title, + "chapter": current_chapter or deck_title, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + + m_tag = re.match(r"^\[([A-Z_]+):\s*(.+)\]$", ln) + if m_tag: + cur_slide["meta"][m_tag.group(1).upper()] = m_tag.group(2).strip() + elif ln.startswith(">"): + cur_slide["notes_lines"].append(ln.lstrip("> ").strip()) + elif ln.startswith(("- ", "* ", "β€’ ")): + cur_slide["bullets"].append(ln[2:].strip()) + elif ln.startswith("|") and ln.endswith("|"): + cells = [c.strip() for c in ln.strip("|").split("|") if c.strip()] + if cells and cells[0].lower() not in ("ꡬ뢄", "ν•­λͺ©", "μ˜΅μ…˜", "방식"): + cur_slide["bullets"].append(" | ".join(cells[:2]) if len(cells) >= 2 else cells[0]) + else: + if len(ln) > 50 and ln.endswith(("λ‹€.", "μš”.", "μ£ .", "!", "?")): + cur_slide["notes_lines"].append(ln) + else: + cur_slide["bullets"].append(ln) + + flush_slide() + return _compile_raw_slides_to_spec(deck_title, raw_slides) + + +# --------------------------------------------------------------------------- +# 4. HTML Presentation / Web Article (.html / .htm) Parser +# --------------------------------------------------------------------------- +def parse_html_to_spec(html_path: Path) -> dict[str, Any]: + from bs4 import BeautifulSoup + + soup = BeautifulSoup(html_path.read_text(encoding="utf-8"), "html.parser") + for tag in soup(["script", "style", "noscript", "svg", "nav", "footer"]): + tag.decompose() + + deck_title = (soup.title.string.strip() if soup.title and soup.title.string else "") or html_path.stem + h1_first = soup.find("h1") + if h1_first and h1_first.get_text(strip=True): + deck_title = h1_first.get_text(" ", strip=True) + + raw_slides: list[dict[str, Any]] = [] + + # Case A: Slide-based HTML (
    , .slide, [data-slide]) + slide_nodes = soup.select("section, div.slide, article.slide, [data-slide]") + # Filter out outer wrapper sections that contain nested
    slides (like Reveal.js vertical stacks) + leaf_slides = [ + node for node in slide_nodes + if not node.find(["section"]) and node.get_text(strip=True) + ] + + if leaf_slides: + for idx, node in enumerate(leaf_slides): + heading = node.find(["h1", "h2", "h3", "h4"]) + title = heading.get_text(" ", strip=True) if heading else f"μŠ¬λΌμ΄λ“œ {idx + 1}" + chapter = node.get("data-chapter") or title + + notes_lines: list[str] = [] + if node.get("data-notes"): + notes_lines.append(str(node["data-notes"]).strip()) + for aside in node.select("aside.notes, .speaker-notes, [data-narration]"): + nt = aside.get_text("\n", strip=True) + if nt: + notes_lines.extend([x.strip() for x in nt.splitlines() if x.strip()]) + aside.decompose() + + quote_txt = "" + for bq in node.find_all("blockquote"): + qt = bq.get_text(" ", strip=True) + if qt and not quote_txt: + quote_txt = qt + bq.decompose() + + bullets: list[str] = [] + for li in node.find_all("li"): + t = li.get_text(" ", strip=True) + if t: + bullets.append(t) + for tr in node.find_all("tr"): + cells = [td.get_text(" ", strip=True) for td in tr.find_all(["td", "th"]) if td.get_text(strip=True)] + if len(cells) >= 2 and tr.find("td"): + bullets.append(" | ".join(cells[:2])) + if not bullets: + for p in node.find_all("p"): + pt = p.get_text(" ", strip=True) + if pt and pt != title: + if len(pt) > 55: + notes_lines.append(pt) + else: + bullets.append(pt) + + meta = {} + if node.get("data-archetype"): + meta["ARCHETYPE"] = str(node["data-archetype"]).strip() + if node.get("data-badge"): + meta["BADGE"] = str(node["data-badge"]).strip() + if node.get("data-command"): + meta["COMMAND"] = str(node["data-command"]).strip() + + raw_slides.append({ + "title": title, + "chapter": chapter, + "bullets": bullets or [title], + "notes_lines": notes_lines, + "quote": quote_txt, + "meta": meta, + }) + return _compile_raw_slides_to_spec(deck_title, raw_slides) + + # Case B: General Web Document / Article HTML (

    /

    sections) + current_chapter = deck_title + cur_slide: dict[str, Any] | None = None + + def flush_html_slide() -> None: + nonlocal cur_slide + if cur_slide and (cur_slide["bullets"] or cur_slide["notes_lines"] or cur_slide["title"]): + raw_slides.append(cur_slide) + cur_slide = None + + body = soup.body or soup + for el in body.find_all(["h1", "h2", "h3", "li", "p", "blockquote", "pre", "code"], recursive=True): + txt = el.get_text(" ", strip=True) + if not txt: + continue + if el.name == "h1": + current_chapter = txt + elif el.name in ("h2", "h3"): + flush_html_slide() + cur_slide = { + "title": txt, + "chapter": current_chapter, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + else: + if cur_slide is None: + cur_slide = { + "title": deck_title, + "chapter": current_chapter, + "bullets": [], + "notes_lines": [], + "quote": "", + "meta": {}, + } + if el.name == "blockquote": + cur_slide["quote"] = cur_slide["quote"] or txt + cur_slide["notes_lines"].append(txt) + elif el.name in ("pre", "code") and len(txt) < 120: + cur_slide["meta"]["COMMAND"] = txt.splitlines()[0] + cur_slide["meta"].setdefault("ARCHETYPE", "terminal_flow") + elif el.name == "li": + if txt not in cur_slide["bullets"]: + cur_slide["bullets"].append(txt) + elif el.name == "p" and not el.find_parent(["li", "blockquote"]): + if len(txt) > 50: + cur_slide["notes_lines"].append(txt) + elif txt not in cur_slide["bullets"]: + cur_slide["bullets"].append(txt) + + flush_html_slide() + return _compile_raw_slides_to_spec(deck_title, raw_slides) + + +# --------------------------------------------------------------------------- +# Unified Dispatcher +# --------------------------------------------------------------------------- +def load_input_to_spec(input_path: Path) -> dict[str, Any]: + suffix = input_path.suffix.lower() + if suffix == ".json": + return json.loads(input_path.read_text(encoding="utf-8")) + if suffix == ".pptx": + return parse_pptx_to_spec(input_path) + if suffix == ".docx": + return parse_docx_to_spec(input_path) + if suffix in (".md", ".markdown", ".txt"): + return parse_markdown_to_spec(input_path) + if suffix in (".html", ".htm"): + return parse_html_to_spec(input_path) + raise ValueError( + f"Unsupported input format '{suffix}'. Supported: .pptx, .docx, .md, .txt, .html, .htm, .json" + ) + + +# --------------------------------------------------------------------------- +# Sample Template Generators (PPTX, DOCX, HTML) +# --------------------------------------------------------------------------- +def create_sample_pptx(output_pptx: Path) -> Path: + from pptx import Presentation + + output_pptx.parent.mkdir(parents=True, exist_ok=True) + prs = Presentation() + layout = prs.slide_layouts[1] + + sample_slides = [ + { + "title": "AI ꡐ윑 μ—μ΄μ „νŠΈ 9μ’…", + "body": [ + "[CHAPTER: 01 μ—μ΄μ „νŠΈ ꡰ체]", + "[ARCHETYPE: arc_cards]", + "[BADGE: PPTX Γ— HyperFrames Engine]", + "[STAT_PREFIX: AI μ œμž‘ λͺ¨λ“ˆ]", + "[STAT_NUM: 9]", + "[STAT_SUFFIX: μ’…]", + "κ΅μ•ˆλΆ„μ„ | μŠ¬λΌμ΄λ“œ ꡬ쑰 μΆ”μΆœ", + "λŒ€λ³Έμ„€κ³„ | λ°œν‘œ λ…ΈνŠΈ 호흑 λΆ„ν• ", + "λͺ¨μ…˜μ—”μ§„ | HTML 3D μΊ”λ²„μŠ€ 생성", + "μ„±μš°ν•©μ„± | μžμ—°μŠ€λŸ¬μš΄ λ‚΄λ ˆμ΄μ…˜", + "νš¨κ³ΌμŒλ΄‡ | μ „ν™˜Β·νŒμ—… μ‚¬μš΄λ“œ 싱크", + "μžλ§‰μ—”μ§„ | ν•œΒ·μ˜ 이쀑 μžλ§‰ μ •λ ¬", + "차트λͺ¨λ“ˆ | 숫자 μΉ΄μš΄νŠΈμ—… μ—°μΆœ", + "BGM덕킹 | λ°°κ²½μŒμ•… λ³Όλ₯¨ μžλ™μ‘°μ ˆ", + "λ Œλ”λŸ¬ | 1080p 무손싀 MP4 μΆ”μΆœ", + ], + "notes": ( + "νŒŒμ›Œν¬μΈνŠΈ κ΅μ•ˆλ§Œ λ„£μœΌλ©΄ 아홉 개의 AI λͺ¨λ“ˆμ΄ λ™μ‹œμ— μ›€μ§μž…λ‹ˆλ‹€. || Put in a PowerPoint deck, and 9 AI modules spring into action.\n" + "μ •μ§€λœ μŠ¬λΌμ΄λ“œλ₯Ό μ½”λ“œ 기반 λͺ¨μ…˜ μ˜μƒμœΌλ‘œ μžλ™ λ³€ν™˜ν•΄ μ£Όμ£ . || Turning static slides into code-rendered motion videos automatically." + ), + }, + { + "title": "μ™œ κΈ°μ‘΄ κ°•μ˜ μ˜μƒ μ œμž‘μ€ 였래 κ±Έλ Έμ„κΉŒ", + "body": [ + "[CHAPTER: 02 병λͺ© 진단]", + "[ARCHETYPE: mockup_steps]", + "[BADGE: Lecture Deck Analysis]", + "μ •μ§€λœ PPT λ…Ήν™”μ˜ ν•œκ³„ | ν™”λ©΄ λ³€ν™”κ°€ μ—†μ–΄ 초반 μ‹œμ²­ 지속λ₯  급락", + "μˆ˜λ™ μ˜μƒ νŽΈμ§‘μ˜ 병λͺ© | μžλ§‰κ³Ό 효과음 싱크λ₯Ό μ†μœΌλ‘œ λ§žμΆ”λŠλΌ μ‹œκ°„ μ†Œλͺ¨", + "μ½”λ“œ 기반 SYNC μžλ™ν™” | λŒ€λ³Έ νƒ€μž„μŠ€νƒ¬ν”„μ— 맞좰 μΉ΄λ“œμ™€ μ‚¬μš΄λ“œκ°€ μ¦‰μ‹œ λ°˜μ‘", + ], + "notes": ( + "기쑴에 PPTλ₯Ό λ„μ›Œλ†“κ³  ν™”λ©΄λ§Œ λ…Ήν™”ν•˜λ©΄ μ‹œμ²­μžκ°€ 금방 μ§€λ£¨ν•΄μ§‘λ‹ˆλ‹€. || Recording static PPT slides quickly loses viewer attention.\n" + "κ·Έλ ‡λ‹€κ³  ν”„λ¦¬λ―Έμ–΄λ‘œ μΉ΄λ“œμ™€ νš¨κ³ΌμŒμ„ 일일이 λ§žμΆ”λ©΄ νŽΈμ§‘ μ‹œκ°„μ΄ μ—΄ 배둜 λŠ˜μ–΄λ‚˜μ£ . || Yet syncing cards and SFX manually in Premiere takes 10x longer.\n" + "해결책은 μŒμ„±κ³Ό ν™”λ©΄, νš¨κ³ΌμŒμ„ μ½”λ“œλ‘œ ν•œ λ²ˆμ— λ™κΈ°ν™”ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. || The answer is syncing voice, visuals, and SFX together in code." + ), + }, + { + "title": "λ°˜λ³΅λ˜λŠ” νŽΈμ§‘ κ·œμΉ™μ€ 맀뉴얼과 μ½”λ“œλ‘œ 남긴닀", + "body": [ + "[CHAPTER: 03 SYNC 원칙]", + "[ARCHETYPE: book_quote]", + "[BADGE: CHAPTER 03 Β· DESIGN SYSTEM]", + "[QUOTE: 같은 λ””μžμΈκ³Ό νŽΈμ§‘μ„ 두 번 λ°˜λ³΅ν–ˆλ‹€λ©΄, 이제 κ·Έ μž‘μ—…μ€ νƒ€μž„λΌμΈμ΄ μ•„λ‹ˆλΌ μ½”λ“œ ν…œν”Œλ¦Ώμ— μžˆμ–΄μ•Ό ν•œλ‹€.]", + "상단 챕터 진행바와 ν•˜λ‹¨ 이쀑 μžλ§‰ λ ˆμ΄μ•„μ›ƒμ„ κ³ μ • κ·œμΉ™μœΌλ‘œ μžμ‚°ν™”", + "κ΅μ•ˆ ν…μŠ€νŠΈλ§Œ λ°”λ€Œμ–΄λ„ μΌκ΄€λœ λΈŒλžœλ“œ ν†€μ•€λ§€λ„ˆμ™€ 가독성 100% μœ μ§€", + ], + "notes": ( + "맀번 같은 μŠ€νƒ€μΌμ˜ κ°•μ‘° νš¨κ³Όμ™€ μžλ§‰μ„ μ†μœΌλ‘œ 찍고 μžˆλ‹€λ©΄ λ°”κΏ”μ•Ό ν•©λ‹ˆλ‹€. || If you repeat the same highlights and captions by hand, change the workflow.\n" + "λ””μžμΈ κ·œμΉ™κ³Ό 효과음 타이밍을 μ½”λ“œ ν…œν”Œλ¦ΏμœΌλ‘œ 남겨두면 κ΅μ•ˆλ§Œ λ°”κΏ” 계속 μ“Έ 수 μžˆμŠ΅λ‹ˆλ‹€. || Once baked into a code template, any new deck inherits the exact same polish." + ), + }, + { + "title": "λͺ…λ Ήμ–΄ ν•œ μ€„λ‘œ λλ‚˜λŠ” PPTX μ˜μƒ λ³€ν™˜ νŒŒμ΄ν”„λΌμΈ", + "body": [ + "[CHAPTER: 04 μžλ™ λ³€ν™˜]", + "[ARCHETYPE: terminal_flow]", + "[BADGE: Automated CLI Pipeline]", + "[COMMAND: python3 produce_deck_video.py --input lecture.pptx --sfx on]", + "[FLOW_LEFT: ꡐ윑자료 Β· PPTX]", + "[FLOW_LEFT_SUB: μŠ¬λΌμ΄λ“œ Β· λ°œν‘œλ…ΈνŠΈ νŒŒμ‹±]", + "[FLOW_RIGHT: 1080p λͺ¨μ…˜ MP4]", + "[FLOW_RIGHT_SUB: HTML λ Œλ”λ§ + UI 효과음]", + "μŠ¬λΌμ΄λ“œ 제λͺ©Β·λ³Έλ¬ΈΒ·λ°œν‘œμž λ…ΈνŠΈλ₯Ό 읽어 씬 λ ˆμ΄μ•„μ›ƒ μžλ™ λ°°μ •", + "μ „ν™˜ μŠ€μš°μ‹œ, μΉ΄λ“œ 포컀슀 팝, 타이핑 μ‚¬μš΄λ“œλ₯Ό 0.01초 λ‹¨μœ„λ‘œ 배치", + ], + "notes": ( + "μ‹€μ œ μ‚¬μš©λ²•μ€ μ•„μ£Ό κ°„λ‹¨ν•©λ‹ˆλ‹€. κ΅μœ‘μžλ£Œλ‚˜ νŒŒμ›Œν¬μΈνŠΈ 파일 ν•˜λ‚˜λ§Œ μ§€μ •ν•΄ μ£Όμ„Έμš”. || Usage is simple: just point the pipeline at your PPTX or lesson file.\n" + "엔진이 μŠ¬λΌμ΄λ“œ ꡬ쑰λ₯Ό 뢄석해 HTML λͺ¨μ…˜κ³Ό νš¨κ³ΌμŒκΉŒμ§€ μž…νžŒ MP4 μ˜μƒμ„ λ°”λ‘œ λ½‘μ•„λƒ…λ‹ˆλ‹€. || It parses your slides and renders an MP4 complete with HTML motion and UI SFX." + ), + }, + { + "title": "μ•žμœΌλ‘œ ꡐ윑 μ˜μƒ μ œμž‘μ΄ λ°”λ€ŒλŠ” 3단계", + "body": [ + "[CHAPTER: 05 핡심 μš”μ•½]", + "[ARCHETYPE: metric_summary]", + "[BADGE: Ready For Production]", + "[SUBTITLE: 자료 μž…λ ₯λΆ€ν„° 효과음 λ§ˆμŠ€ν„°λ§κΉŒμ§€ μ›μŠ€ν†± μžλ™ν™”]", + "κ΅μ•ˆ μž…λ ₯ | PPTX Β· μ›Œλ“œ Β· λ§ˆν¬λ‹€μš΄ Β· HTML 지원", + "λͺ¨μ…˜Β·νš¨κ³ΌμŒ | 3D μ›¨μ΄λΈŒΒ·λ„€μ˜¨ μΉ΄λ“œΒ·μ‚¬μš΄λ“œ μžλ™ 싱크", + "κ³ ν™”μ§ˆ λ Œλ”λ§ | λŠκΉ€ μ—†λŠ” 1080p MP4 μ˜μƒ μ¦‰μ‹œ μ™„μ„±", + ], + "notes": ( + "이제 νŒŒμ›Œν¬μΈνŠΈλ‚˜ μ›Œλ“œ κ΅μ•ˆλ§Œ μ€€λΉ„ν•˜μ‹œλ©΄ λͺ¨μ…˜ κ·Έλž˜ν”½κ³Ό νš¨κ³ΌμŒμ€ νŒŒμ΄ν”„λΌμΈμ΄ λ§‘μŠ΅λ‹ˆλ‹€. || Prepare your PPTX or Word docsβ€”the pipeline handles motion and SFX.\n" + "μ–Έμ œλ“  μƒˆλ‘œμš΄ ꡐ윑자료λ₯Ό λ„£μ–΄ 같은 포맷의 κ³ ν’ˆμ§ˆ ν”„λ ˆμ  ν…Œμ΄μ…˜ μ˜μƒμ„ λ§Œλ“€μ–΄ λ³΄μ„Έμš”! || Feed in any future training deck to produce sleek presentation videos anytime!" + ), + }, + ] + + for s in sample_slides: + slide = prs.slides.add_slide(layout) + slide.shapes.title.text = s["title"] + tf = slide.placeholders[1].text_frame + tf.clear() + for idx, line in enumerate(s["body"]): + p = tf.paragraphs[0] if idx == 0 else tf.add_paragraph() + p.text = line + slide.notes_slide.notes_text_frame.text = s["notes"] + + prs.save(str(output_pptx)) + return output_pptx + + +def create_sample_docx(output_docx: Path) -> Path: + from docx import Document + + output_docx.parent.mkdir(parents=True, exist_ok=True) + doc = Document() + doc.add_heading("AI λ¬Έμ„œ μžλ™ μ˜μƒν™” κ°€μ΄λ“œ", 0) + + doc.add_heading("01 닀쀑 포맷 μž…λ ₯", level=1) + doc.add_heading("λ„€ κ°€μ§€ 싀무 λ¬Έμ„œλ₯Ό κ·ΈλŒ€λ‘œ μ˜μƒμœΌλ‘œ", level=2) + doc.add_paragraph("νŒŒμ›Œν¬μΈνŠΈ | λ°œν‘œ μŠ¬λΌμ΄λ“œμ™€ λ°œν‘œμž λ…ΈνŠΈ μžλ™ μΆ”μΆœ", style="List Bullet") + doc.add_paragraph("μ›Œλ“œ λ¬Έμ„œ | 제λͺ© μŠ€νƒ€μΌκ³Ό ν‘œΒ·λ³Έλ¬Έ 단락 ꡬ쑰화", style="List Bullet") + doc.add_paragraph("λ§ˆν¬λ‹€μš΄ Β· HTML | 기술 λ¬Έμ„œμ™€ μ›Ή μŠ¬λΌμ΄λ“œ μ¦‰μ‹œ νŒŒμ‹±", style="List Bullet") + doc.add_paragraph("> μ‹€λ¬΄μ—μ„œ 이미 μ“°λ˜ μ›Œλ“œ κΈ°νšμ„œλ‚˜ ꡐ윑 κ΅μ•ˆμ„ μƒˆλ‘œ νŽΈμ§‘ν•  ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€. || No need to re-edit existing Word specs or training docs.") + + doc.add_heading("02 핡심 원칙", level=1) + doc.add_heading("λ¬Έμ„œ ꡬ쑰가 κ³§ λͺ¨μ…˜ μŠ€ν† λ¦¬λ³΄λ“œκ°€ λœλ‹€", level=2) + doc.add_paragraph("같은 λ ˆμ΄μ•„μ›ƒ μž‘μ—…μ„ 두 번 λ°˜λ³΅ν•˜μ§€ 말고 μ½”λ“œ νŒŒμ΄ν”„λΌμΈμ— λ§‘κΈ΄λ‹€.", style="Quote") + doc.add_paragraph("제λͺ©μ€ 챕터 λ°”λ‘œ, λͺ©λ‘μ€ λ„€μ˜¨ 포컀슀 μΉ΄λ“œλ‘œ μžλ™ λ§€ν•‘λ©λ‹ˆλ‹€.") + + doc.save(str(output_docx)) + return output_docx + + +def create_sample_html_slides(output_html: Path) -> Path: + output_html.parent.mkdir(parents=True, exist_ok=True) + content = """ + +μ›Ή μŠ¬λΌμ΄λ“œ μ˜μƒ λ³€ν™˜ μƒ˜ν”Œ + +
    +

    HTML ν”„λ ˆμ  ν…Œμ΄μ…˜λ„ κ·ΈλŒ€λ‘œ MP4둜

    +
      +
    • μ„Ήμ…˜ μžλ™ 인식 | Reveal.js 및 일반 μ›Ή μŠ¬λΌμ΄λ“œ νƒœκ·Έ νŒŒμ‹±
    • +
    • λ°œν‘œ λ…ΈνŠΈ 연동 | aside.notes νƒœκ·Έλ₯Ό 읽어 μ„±μš° λ‚΄λ ˆμ΄μ…˜ ν•©μ„±
    • +
    • 효과음 κ²°ν•© | ν™”λ©΄ μ „ν™˜κ³Ό μΉ΄λ“œ ν¬μ»€μŠ€μ— 맞좰 UI μ‚¬μš΄λ“œ λ―Ήμ‹±
    • +
    + +
    + + +""" + output_html.write_text(content, encoding="utf-8") + return output_html diff --git a/install_mac_linux.sh b/install_mac_linux.sh new file mode 100644 index 0000000000000000000000000000000000000000..35466f8f5b2bbcb181f9182d3e970012d471dc22 --- /dev/null +++ b/install_mac_linux.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "=== Deck2Video Portable Setup (macOS / Linux) ===" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +if ! command -v node >/dev/null 2>&1; then + echo "[!] Node.js (v22+) is required. Install via: brew install node (macOS) or https://nodejs.org" + exit 1 +fi + +if ! command -v ffmpeg >/dev/null 2>&1; then + echo "[!] FFmpeg is required. Install via: brew install ffmpeg (macOS) or sudo apt install ffmpeg (Linux)" + exit 1 +fi + +echo "[1/3] Creating Python virtual environment (.venv) and installing dependencies..." +python3 -m venv .venv +source .venv/bin/activate +pip install --upgrade pip +pip install -r requirements.txt +pip install -e . + +echo "[2/3] Warming up HyperFrames CLI & Headless Chromium..." +npx --yes hyperframes --version +npx --yes hyperframes browser ensure || true + +echo "[3/3] Generating sample PPTX, DOCX, Markdown, and HTML templates..." +python produce_deck_video.py --generate-samples + +echo "" +echo "βœ… Setup Complete! Run with:" +echo " source .venv/bin/activate" +echo " deck2video --demo" +echo " deck2video --input my_slides.pptx --output output/my_video.mp4" diff --git a/install_offline_mac_linux.sh b/install_offline_mac_linux.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f989e705ef111e15cc6ddd489c8660ab6b03bf0 --- /dev/null +++ b/install_offline_mac_linux.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "=== Deck2Video 100% Offline Installer (macOS / Linux) ===" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +WHEEL_DIR="$SCRIPT_DIR/offline_vendor/wheels" +if [ ! -d "$WHEEL_DIR" ]; then + echo "[!] offline_vendor/wheels not found. Please download the full offline package from Hugging Face." + exit 1 +fi + +python3 -m venv .venv +source .venv/bin/activate +pip install --no-index --find-links="$WHEEL_DIR" -r requirements.txt +pip install --no-index --find-links="$WHEEL_DIR" --no-build-isolation -e . || true + +echo "" +echo "βœ… Offline Python environment ready!" +echo " Ensure FFmpeg and Google Chrome / Chromium / Edge are installed locally, then run:" +echo " source .venv/bin/activate" +echo " python3 produce_deck_video.py --input samples/sample_ai_sync_lecture.pptx --offline --output output/offline_demo.mp4" diff --git a/install_offline_windows.ps1 b/install_offline_windows.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..4017f55d6e8eddf7bf04c50e13ec9a56d7472335 --- /dev/null +++ b/install_offline_windows.ps1 @@ -0,0 +1,19 @@ +$ErrorActionPreference = "Stop" +Write-Host "=== Deck2Video 100% Offline Installer (Windows 10/11) ===" -ForegroundColor Cyan + +Set-Location $PSScriptRoot +$WheelDir = Join-Path $PSScriptRoot "offline_vendor\wheels" + +if (-not (Test-Path $WheelDir)) { + Write-Host "[!] offline_vendor\wheels not found. Download the full offline bundle from Hugging Face." -ForegroundColor Red + exit 1 +} + +python -m venv .venv +& ".\.venv\Scripts\pip.exe" install --no-index --find-links="$WheelDir" -r requirements.txt +& ".\.venv\Scripts\pip.exe" install --no-index --find-links="$WheelDir" --no-build-isolation -e . + +Write-Host "" +Write-Host "Offline setup complete! Run with:" -ForegroundColor Green +Write-Host " .\.venv\Scripts\Activate.ps1" +Write-Host " python produce_deck_video.py --input samples\sample_ai_sync_lecture.pptx --offline --output output\offline_demo.mp4" diff --git a/install_windows.ps1 b/install_windows.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..d13e2b317c995b18d4522908f43d81cf84de7207 --- /dev/null +++ b/install_windows.ps1 @@ -0,0 +1,33 @@ +$ErrorActionPreference = "Stop" +Write-Host "=== Deck2Video Portable Setup (Windows 10/11 PowerShell) ===" -ForegroundColor Cyan + +Set-Location $PSScriptRoot + +if (-not (Get-Command node -ErrorAction SilentlyContinue)) { + Write-Host "[!] Node.js (v22+) not found. Install via: winget install OpenJS.NodeJS.LTS" -ForegroundColor Yellow + exit 1 +} + +if (-not (Get-Command ffmpeg -ErrorAction SilentlyContinue)) { + Write-Host "[!] FFmpeg not found. Install via: winget install Gyan.FFmpeg" -ForegroundColor Yellow + exit 1 +} + +Write-Host "[1/3] Creating Python virtual environment (.venv) and installing packages..." +python -m venv .venv +& ".\.venv\Scripts\python.exe" -m pip install --upgrade pip +& ".\.venv\Scripts\pip.exe" install -r requirements.txt +& ".\.venv\Scripts\pip.exe" install -e . + +Write-Host "[2/3] Warming up HyperFrames CLI & Headless Chromium..." +npx.cmd --yes hyperframes --version +npx.cmd --yes hyperframes browser ensure + +Write-Host "[3/3] Generating sample PPTX, DOCX, Markdown, and HTML templates..." +& ".\.venv\Scripts\python.exe" produce_deck_video.py --generate-samples + +Write-Host "" +Write-Host "Setup Complete! Run with:" -ForegroundColor Green +Write-Host " .\.venv\Scripts\Activate.ps1" +Write-Host " deck2video --demo" +Write-Host " deck2video --input C:\path\to\lecture.pptx --output .\output\lecture.mp4" diff --git a/offline_renderer.py b/offline_renderer.py new file mode 100644 index 0000000000000000000000000000000000000000..e8a21bc0ad2a8074cc9bd61ed1a85c6976127361 --- /dev/null +++ b/offline_renderer.py @@ -0,0 +1,387 @@ +""" +Zero-NPM Air-Gapped Offline HTML-to-MP4 Renderer (`offline_renderer.py`) +Drives any locally installed Chromium / Google Chrome / Microsoft Edge via raw +Chrome DevTools Protocol (CDP) over localhost WebSocket (Python stdlib only β€” +zero Playwright / zero Node.js required!) + sample-accurate NumPy/FFmpeg audio +mixing for Voiceover + UI SFX + BGM. +""" + +from __future__ import annotations +import base64 +import http.server +import json +import os +import platform +import shutil +import socket +import struct +import subprocess +import tempfile +import threading +import time +import urllib.request +import wave +from pathlib import Path +from typing import Any +import numpy as np + + +def _is_working_browser(path_str: str) -> bool: + if not path_str or not Path(path_str).exists(): + return False + try: + res = subprocess.run([path_str, "--version"], capture_output=True, timeout=4) + return res.returncode == 0 + except Exception: + return False + + +def _find_local_browser() -> str: + env_b = os.environ.get("CHROME_BIN") + if env_b and _is_working_browser(env_b): + return env_b + + # Check HyperFrames cached headless shell first if present + hf_cache = Path.home() / ".cache" / "hyperframes" / "chrome" + if hf_cache.exists(): + for exe_name in ("chrome-headless-shell", "chrome", "chrome.exe"): + for m in hf_cache.rglob(exe_name): + if _is_working_browser(str(m)): + return str(m) + + candidates = [] + sys_name = platform.system().lower() + if sys_name == "darwin": + candidates = [ + "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", + "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", + "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", + "/Applications/Chromium.app/Contents/MacOS/Chromium", + ] + elif sys_name == "windows": + pf = os.environ.get("PROGRAMFILES", r"C:\Program Files") + pfx86 = os.environ.get("PROGRAMFILES(X86)", r"C:\Program Files (x86)") + local_app = os.environ.get("LOCALAPPDATA", "") + candidates = [ + rf"{pf}\Google\Chrome\Application\chrome.exe", + rf"{pfx86}\Google\Chrome\Application\chrome.exe", + rf"{local_app}\Google\Chrome\Application\chrome.exe", + rf"{pf}\Microsoft\Edge\Application\msedge.exe", + rf"{pfx86}\Microsoft\Edge\Application\msedge.exe", + ] + else: + candidates = ["/usr/bin/google-chrome", "/usr/bin/chromium", "/usr/bin/chromium-browser"] + + for cmd in ("google-chrome", "chromium", "chromium-browser", "msedge", "brave-browser"): + found = shutil.which(cmd) + if found: + candidates.append(found) + + for c in candidates: + if _is_working_browser(c): + return c + + raise RuntimeError("No working local Chrome, Edge, or Chromium browser found for offline rendering.") + + +class _MiniCDPClient: + """Minimal stdlib WebSocket client for localhost Chrome DevTools Protocol.""" + + def __init__(self, ws_url: str): + # ws://127.0.0.1:PORT/devtools/page/ID + rest = ws_url.replace("ws://", "") + host_port, path = rest.split("/", 1) + host, port_s = host_port.split(":") + self.sock = socket.create_connection((host, int(port_s)), timeout=30) + key = base64.b64encode(os.urandom(16)).decode("ascii") + handshake = ( + f"GET /{path} HTTP/1.1\r\n" + f"Host: {host_port}\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + f"Sec-WebSocket-Key: {key}\r\n" + "Sec-WebSocket-Version: 13\r\n\r\n" + ) + self.sock.sendall(handshake.encode("ascii")) + buf = b"" + while b"\r\n\r\n" not in buf: + buf += self.sock.recv(4096) + self._msg_id = 0 + + def _send_frame(self, text: str) -> None: + payload = text.encode("utf-8") + mask_key = os.urandom(4) + header = bytearray([0x81]) # FIN + text frame + length = len(payload) + if length < 126: + header.append(0x80 | length) + elif length < 65536: + header.append(0x80 | 126) + header.extend(struct.pack("!H", length)) + else: + header.append(0x80 | 127) + header.extend(struct.pack("!Q", length)) + header.extend(mask_key) + masked = bytes(b ^ mask_key[i % 4] for i, b in enumerate(payload)) + self.sock.sendall(bytes(header) + masked) + + def _recv_exact(self, n: int) -> bytes: + chunks = [] + rem = n + while rem > 0: + chunk = self.sock.recv(rem) + if not chunk: + raise EOFError("CDP socket closed") + chunks.append(chunk) + rem -= len(chunk) + return b"".join(chunks) + + def _recv_frame(self) -> str: + while True: + b1, b2 = self._recv_exact(2) + opcode = b1 & 0x0F + masked = bool(b2 & 0x80) + length = b2 & 0x7F + if length == 126: + length = struct.unpack("!H", self._recv_exact(2))[0] + elif length == 127: + length = struct.unpack("!Q", self._recv_exact(8))[0] + mask_key = self._recv_exact(4) if masked else b"" + data = self._recv_exact(length) + if masked: + data = bytes(b ^ mask_key[i % 4] for i, b in enumerate(data)) + if opcode == 0x8: + raise EOFError("CDP WebSocket closed") + if opcode == 0x9: # Ping -> Pong + pong = bytearray([0x8A, 0x80]) + os.urandom(4) + self.sock.sendall(bytes(pong)) + continue + if opcode == 0x1: + return data.decode("utf-8") + + def call(self, method: str, params: dict[str, Any] | None = None) -> dict[str, Any]: + self._msg_id += 1 + mid = self._msg_id + self._send_frame(json.dumps({"id": mid, "method": method, "params": params or {}})) + while True: + msg = json.loads(self._recv_frame()) + if msg.get("id") == mid: + if "error" in msg: + raise RuntimeError(f"CDP error on {method}: {msg['error']}") + return msg.get("result", {}) + + def close(self) -> None: + try: + self.sock.close() + except Exception: + pass + + +def _decode_to_pcm48k(ffmpeg_bin: str, src_path: Path) -> np.ndarray: + cmd = [ + ffmpeg_bin, "-v", "error", + "-i", str(src_path), + "-f", "s16le", + "-acodec", "pcm_s16le", + "-ar", "48000", + "-ac", "2", + "-", + ] + res = subprocess.run(cmd, capture_output=True, check=True) + arr = np.frombuffer(res.stdout, dtype=np.int16).astype(np.float32) / 32768.0 + return arr.reshape(-1, 2) + + +def mix_offline_master_audio(ffmpeg_bin: str, spec: dict[str, Any], project_dir: Path, out_wav: Path) -> Path: + """Sample-accurate 48kHz stereo master mix of all Voiceover + SFX + BGM tracks.""" + sr = 48000 + total_samples = int(round(spec["total_duration"] * sr)) + sr // 4 + master = np.zeros((total_samples, 2), dtype=np.float32) + + def place_clip(rel_src: str, start_sec: float, gain: float) -> None: + p = project_dir / rel_src + if not p.exists(): + return + pcm = _decode_to_pcm48k(ffmpeg_bin, p) * gain + s0 = max(0, int(round(start_sec * sr))) + s1 = min(total_samples, s0 + len(pcm)) + if s1 > s0: + master[s0:s1] += pcm[: s1 - s0] + + if spec.get("bgm"): + place_clip(spec["bgm"]["src"], float(spec["bgm"]["start"]), float(spec["bgm"]["volume"])) + + for slide in spec.get("slides", []): + for beat in slide.get("beats", []): + place_clip(beat["src"], float(beat["start"]), 1.0) + + for ev in spec.get("sfx_events", []): + place_clip(ev["src"], float(ev["start"]), float(ev.get("volume", 0.3))) + + # Soft limiter ceiling at -1.0 dBFS + peak = float(np.max(np.abs(master))) + if peak > 0.89: + master *= 0.89 / peak + + trim_len = int(round(spec["total_duration"] * sr)) + pcm16 = np.clip(master[:trim_len] * 32767.0, -32768, 32767).astype(np.int16) + out_wav.parent.mkdir(parents=True, exist_ok=True) + with wave.open(str(out_wav), "wb") as wf: + wf.setnchannels(2) + wf.setsampwidth(2) + wf.setframerate(sr) + wf.writeframes(pcm16.tobytes()) + return out_wav + + +def render_offline_via_local_browser( + project_dir: Path, + spec: dict[str, Any], + output_mp4: Path, + fps: int = 30, +) -> Path: + """Renders `project_dir/index.html` + audio stems to `output_mp4` with zero npm/internet.""" + ffmpeg_bin = shutil.which("ffmpeg") or "/opt/homebrew/bin/ffmpeg" + browser_bin = _find_local_browser() + + # 1. Serve `project_dir` on an ephemeral localhost port + class QuietHandler(http.server.SimpleHTTPRequestHandler): + def __init__(self, *args: Any, **kwargs: Any): + super().__init__(*args, directory=str(project_dir), **kwargs) + + def log_message(self, format: str, *args: Any) -> None: + pass + + httpd = http.server.ThreadingHTTPServer(("127.0.0.1", 0), QuietHandler) + http_port = httpd.server_address[1] + srv_thread = threading.Thread(target=httpd.serve_forever, daemon=True) + srv_thread.start() + + with socket.socket() as s: + s.bind(("127.0.0.1", 0)) + cdp_port = s.getsockname()[1] + + tmp_profile = Path(tempfile.mkdtemp(prefix="deck2video_cdp_")) + master_wav = tmp_profile / "master_mix.wav" + mix_offline_master_audio(ffmpeg_bin, spec, project_dir, master_wav) + + is_headless_shell = "headless-shell" in Path(browser_bin).name.lower() + browser_args = [browser_bin] + if not is_headless_shell: + browser_args.append("--headless=new") + browser_args.extend([ + "--disable-gpu-vsync", + "--hide-scrollbars", + "--mute-audio", + "--no-first-run", + "--no-default-browser-check", + "--window-size=1920,1080", + f"--user-data-dir={tmp_profile / 'profile'}", + f"--remote-debugging-port={cdp_port}", + f"http://127.0.0.1:{http_port}/index.html", + ]) + + browser_proc = subprocess.Popen( + browser_args, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + ) + + cdp: _MiniCDPClient | None = None + try: + ws_url = "" + for _ in range(50): + try: + with urllib.request.urlopen(f"http://127.0.0.1:{cdp_port}/json", timeout=1) as resp: + targets = json.loads(resp.read().decode("utf-8")) + for tgt in targets: + if tgt.get("type") == "page" and "webSocketDebuggerUrl" in tgt: + ws_url = tgt["webSocketDebuggerUrl"] + break + if ws_url: + break + except Exception: + time.sleep(0.15) + if not ws_url: + raise RuntimeError("Failed to attach to headless browser CDP endpoint.") + + cdp = _MiniCDPClient(ws_url) + cdp.call("Page.enable") + cdp.call("Runtime.enable") + cdp.call( + "Emulation.setDeviceMetricsOverride", + {"width": 1920, "height": 1080, "deviceScaleFactor": 1, "mobile": False}, + ) + + # Wait for fonts and timeline registration + cdp.call( + "Runtime.evaluate", + { + "expression": "document.fonts.ready.then(() => Boolean(window.__timelines && window.__timelines['main']))", + "awaitPromise": True, + }, + ) + + # Inject clip visibility helper matching HyperFrames [data-start, data-start + data-duration] + init_js = """ + window.__offlineSeek = function(t) { + var clips = document.querySelectorAll('.clip[data-start]'); + for (var i = 0; i < clips.length; i++) { + var el = clips[i]; + var st = parseFloat(el.getAttribute('data-start') || '0'); + var dur = parseFloat(el.getAttribute('data-duration') || '999999'); + el.style.visibility = (t >= st && t < st + dur) ? 'visible' : 'hidden'; + } + if (window.__timelines && window.__timelines['main']) { + window.__timelines['main'].seek(t, false); + } + }; + """ + cdp.call("Runtime.evaluate", {"expression": init_js}) + + total_frames = max(1, int(round(spec["total_duration"] * fps))) + output_mp4.parent.mkdir(parents=True, exist_ok=True) + + ff_cmd = [ + ffmpeg_bin, "-y", + "-f", "image2pipe", + "-vcodec", "mjpeg", + "-framerate", str(fps), + "-i", "-", + "-i", str(master_wav), + "-c:v", "libx264", + "-preset", "fast", + "-crf", "17", + "-pix_fmt", "yuv420p", + "-c:a", "aac", + "-b:a", "192k", + "-shortest", + str(output_mp4), + ] + ff_proc = subprocess.Popen(ff_cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE) + assert ff_proc.stdin is not None + + for frame_idx in range(total_frames): + t_sec = frame_idx / float(fps) + cdp.call("Runtime.evaluate", {"expression": f"window.__offlineSeek({t_sec:.5f});"}) + shot = cdp.call("Page.captureScreenshot", {"format": "jpeg", "quality": 94}) + ff_proc.stdin.write(base64.b64decode(shot["data"])) + if frame_idx % 60 == 0 or frame_idx == total_frames - 1: + pct = int((frame_idx + 1) * 100 / total_frames) + print(f"\r [Offline Renderer] {pct:3d}% ({frame_idx + 1}/{total_frames} frames)", end="", flush=True) + + print() + ff_proc.stdin.close() + ff_proc.stdin = None + _, stderr_bytes = ff_proc.communicate() + if ff_proc.returncode != 0: + raise RuntimeError(f"FFmpeg encode failed: {stderr_bytes.decode('utf-8', errors='ignore')[:600]}") + + finally: + if cdp: + cdp.close() + browser_proc.terminate() + httpd.shutdown() + shutil.rmtree(tmp_profile, ignore_errors=True) + + return output_mp4 diff --git a/offline_vendor/wheels/aiohappyeyeballs-2.7.1-py3-none-any.whl b/offline_vendor/wheels/aiohappyeyeballs-2.7.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..6446b127cc76a8df67e214271f9318a516f67356 Binary files /dev/null and b/offline_vendor/wheels/aiohappyeyeballs-2.7.1-py3-none-any.whl differ diff --git a/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..a8367439a31857f0e420af8f76cf7ca326587669 --- /dev/null +++ b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-macosx_11_0_arm64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d079c0a0135c36e7beb6f1c88087c8f108dc5891cdd0b5eafa778421bda70ed2 +size 548067 diff --git a/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..509312b97837eca76ff46c681546c8f2061c8dfa --- /dev/null +++ b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20f085697d7e911f1f73c43ed03fafbed1e7121797e2eb5428efa80398060584 +size 1919630 diff --git a/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..f93d6dc5e6a17785d8c19b3483a32232a1732c2e --- /dev/null +++ b/offline_vendor/wheels/aiohttp-3.14.5-cp312-cp312-win_amd64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cc38a4f2b516bef1714e690df87a0e043faf1a7693c82d860091684453d5111 +size 506141 diff --git a/offline_vendor/wheels/aiosignal-1.4.0-py3-none-any.whl b/offline_vendor/wheels/aiosignal-1.4.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..95f31efe3902b15de41e7464f97537a6489a0d25 Binary files /dev/null and b/offline_vendor/wheels/aiosignal-1.4.0-py3-none-any.whl differ diff --git a/offline_vendor/wheels/attrs-26.1.0-py3-none-any.whl b/offline_vendor/wheels/attrs-26.1.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..3f0a9de772705299849e0a0247601f8c76cca99f Binary files /dev/null and b/offline_vendor/wheels/attrs-26.1.0-py3-none-any.whl differ diff --git a/offline_vendor/wheels/beautifulsoup4-4.15.0-py3-none-any.whl b/offline_vendor/wheels/beautifulsoup4-4.15.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..fa7af667482d1a8fa2c0b8bcdc32a13fd991b0ee --- /dev/null +++ b/offline_vendor/wheels/beautifulsoup4-4.15.0-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6f88de62e1d4e38ecb1077eb9724cd0eff29d2a08ca16a401e9b9e93f117cf9 +size 109924 diff --git a/offline_vendor/wheels/certifi-2026.10.23-py3-none-any.whl b/offline_vendor/wheels/certifi-2026.10.23-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..a87ee7739f2d0b4bcff7d6140a1e9fbe37556162 --- /dev/null +++ b/offline_vendor/wheels/certifi-2026.10.23-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1 +size 135082 diff --git a/offline_vendor/wheels/edge_tts-7.3.1-py3-none-any.whl b/offline_vendor/wheels/edge_tts-7.3.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..edfa44e7e6632a3f3e3b0fa163ea583c2cb3a1b6 Binary files /dev/null and b/offline_vendor/wheels/edge_tts-7.3.1-py3-none-any.whl differ diff --git a/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..7474ca4b884057563006bcbec3e04abf294c5d10 Binary files /dev/null and b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-macosx_11_0_arm64.whl differ diff --git a/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..19345212b24adecb807494ce18f7f0530eb70b7b --- /dev/null +++ b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:494a5952b1c597ba44e0e78113a7266e656b9794eec897b19ead706bd7074383 +size 242411 diff --git a/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..cf5d20c0e7b9f15f69e356ffab1b45715e4540ad Binary files /dev/null and b/offline_vendor/wheels/frozenlist-1.8.0-cp312-cp312-win_amd64.whl differ diff --git a/offline_vendor/wheels/idna-3.20-py3-none-any.whl b/offline_vendor/wheels/idna-3.20-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..34af34e714ac6278fe64846856be3ac58cd48f82 Binary files /dev/null and b/offline_vendor/wheels/idna-3.20-py3-none-any.whl differ diff --git a/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-macosx_10_13_universal2.whl b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-macosx_10_13_universal2.whl new file mode 100644 index 0000000000000000000000000000000000000000..52dbf832b17d4f4e00c48079a61bb8ca04d4afb6 --- /dev/null +++ b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-macosx_10_13_universal2.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c0710ac085a157b593c38fbcacd950f15c4afa8e2057527185875ab302752bc +size 8602094 diff --git a/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..8e626a026b80a036e96edc158c6dffd1e33274bd --- /dev/null +++ b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:379f8a75cf6eb7eef0af074b55f49ab73b868388a98de14646abcdfa4564bb11 +size 5105247 diff --git a/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..ccc92feae1e4d97bc614b5a60a35eae3ee45a65f --- /dev/null +++ b/offline_vendor/wheels/lxml-6.1.3-cp312-cp312-win_amd64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e9a00d1c2c30936f7add097c41afc5da6556c580909104aafd382cac92a855c +size 4005999 diff --git a/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..ada4ed0a20989bb36ea979cdcc4353a87826143b --- /dev/null +++ b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-macosx_11_0_arm64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d37773029ba034a2cc970b6eeb67dad3bff9d894393c51f6bb1c6b4f563a032c +size 103911 diff --git a/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..b8e1e6d8696f943012fbbfa8c0718d2cd4b1f111 --- /dev/null +++ b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1fb8c1a3480c130c3a6422d5f16f3cad6552bf08c2089dd288ba7134649183b5 +size 516796 diff --git a/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..e8906fc9f40ef2f35919420e887ee7113a2c5842 Binary files /dev/null and b/offline_vendor/wheels/multidict-7.2.1-cp312-cp312-win_amd64.whl differ diff --git a/offline_vendor/wheels/numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl b/offline_vendor/wheels/numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..cf37ace110ca6599aab764bae0fe0f0baf5e53ed --- /dev/null +++ b/offline_vendor/wheels/numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249 +size 16527618 diff --git a/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-macosx_14_0_arm64.whl b/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-macosx_14_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..783ce9617d9622b49baf053a50376f8a74900503 --- /dev/null +++ b/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-macosx_14_0_arm64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3856a97e48ed8371c680fb04120b99fbcc29f2076ebe6dc3deb34f77947c5ca +size 5513680 diff --git a/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..165dbf61166740b4ed0830b1d8013c8ca66a4f82 --- /dev/null +++ b/offline_vendor/wheels/numpy-2.5.5-cp312-cp312-win_amd64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:919eb420662b0b4ba34889df503f3d5329775b0c1d5f7e5f5af4fba8315b1e30 +size 12580189 diff --git a/offline_vendor/wheels/packaging-26.3-py3-none-any.whl b/offline_vendor/wheels/packaging-26.3-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..5bf95b6e346c879bb6408abc0ffaad98756d8e40 --- /dev/null +++ b/offline_vendor/wheels/packaging-26.3-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c +size 129956 diff --git a/offline_vendor/wheels/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl b/offline_vendor/wheels/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..4d88a7559022a1f4a5903b017e0e229e8a3011fb --- /dev/null +++ b/offline_vendor/wheels/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b86024e52a1b269467a802258c25521e6d742349d760728092e1bc2d135b4d76 +size 8094744 diff --git a/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..d385e0ecf5df32fe794df3a40add54738bc4b1f3 --- /dev/null +++ b/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-macosx_11_0_arm64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc481f742ccda20e9ed760b8f978dff50f2a4e9bc253ac167fb0a05b0783ef52 +size 4852329 diff --git a/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..346ab44272db5b31ebb608fbb91d612244c885e5 --- /dev/null +++ b/offline_vendor/wheels/pillow-13.0.0-cp312-cp312-win_amd64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff3fe9eb621fbb9db4c4be33ab946f6bac5f98ab50ca8d3260503653656c961b +size 7272166 diff --git a/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..91e7159703c6246e94f49328e39be83f113263d3 Binary files /dev/null and b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-macosx_11_0_arm64.whl differ diff --git a/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..929b071050c94200cbf512e17fd5fae8cdac7801 --- /dev/null +++ b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2814ecd8e818f487bee4b0f921bc4d1c176cc5fc71ac0f072d0fa67eda4ac14b +size 250424 diff --git a/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..6aad1f2a8d81600a1ee67bc4076841e150b335c5 Binary files /dev/null and b/offline_vendor/wheels/propcache-0.5.4-cp312-cp312-win_amd64.whl differ diff --git a/offline_vendor/wheels/python_docx-1.2.0-py3-none-any.whl b/offline_vendor/wheels/python_docx-1.2.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..5a62170c588384283bd4d92b483c87bda754828f --- /dev/null +++ b/offline_vendor/wheels/python_docx-1.2.0-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3fd478f3250fbbbfd3b94fe1e985955737c145627498896a8a6bf81f4baf66c7 +size 252987 diff --git a/offline_vendor/wheels/python_pptx-1.0.2-py3-none-any.whl b/offline_vendor/wheels/python_pptx-1.0.2-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..9d560c03e9755e26bb46da1469279954340608d9 --- /dev/null +++ b/offline_vendor/wheels/python_pptx-1.0.2-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:160838e0b8565a8b1f67947675886e9fea18aa5e795db7ae531606d68e785cba +size 472788 diff --git a/offline_vendor/wheels/setuptools-84.2.1-py3-none-any.whl b/offline_vendor/wheels/setuptools-84.2.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..b160a1aad4e15473d03059155c5915b7d33542f8 --- /dev/null +++ b/offline_vendor/wheels/setuptools-84.2.1-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca140b45d5325a9478f880e351484f62fef15f336462e449ca0c03c873d589c2 +size 876263 diff --git a/offline_vendor/wheels/soupsieve-4.1.1-py3-none-any.whl b/offline_vendor/wheels/soupsieve-4.1.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..4509459d25e43ddcf4b8315d5a3d270bb2ccb13e Binary files /dev/null and b/offline_vendor/wheels/soupsieve-4.1.1-py3-none-any.whl differ diff --git a/offline_vendor/wheels/tabulate-0.10.0-py3-none-any.whl b/offline_vendor/wheels/tabulate-0.10.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..0488cd971450b74a3497b49c1cd1498026c46851 Binary files /dev/null and b/offline_vendor/wheels/tabulate-0.10.0-py3-none-any.whl differ diff --git a/offline_vendor/wheels/typing_extensions-4.16.0-py3-none-any.whl b/offline_vendor/wheels/typing_extensions-4.16.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..9f9aae6adc3bf050c4101be0e7037edfedf28b7e Binary files /dev/null and b/offline_vendor/wheels/typing_extensions-4.16.0-py3-none-any.whl differ diff --git a/offline_vendor/wheels/wheel-0.48.0-py3-none-any.whl b/offline_vendor/wheels/wheel-0.48.0-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..f0b0bc67aa9e746e06875546a07e85239f1a6737 Binary files /dev/null and b/offline_vendor/wheels/wheel-0.48.0-py3-none-any.whl differ diff --git a/offline_vendor/wheels/xlsxwriter-3.3.1-py3-none-any.whl b/offline_vendor/wheels/xlsxwriter-3.3.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..d9b4e0f0d507ead57325b69b2c39aebd680250f1 --- /dev/null +++ b/offline_vendor/wheels/xlsxwriter-3.3.1-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e2c89e59d733fe59e112317218c64fbbc276d90a8c144ebd6f7fa15e7ab184a +size 180583 diff --git a/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-macosx_11_0_arm64.whl b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-macosx_11_0_arm64.whl new file mode 100644 index 0000000000000000000000000000000000000000..6348655522aadc21cfe439bb907444e98f42a68d --- /dev/null +++ b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-macosx_11_0_arm64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e029648f9c951db30e98a7d7ec90835db88ec4b32820efe2a9bdc2287e032eb6 +size 104325 diff --git a/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl new file mode 100644 index 0000000000000000000000000000000000000000..86023552005dc008ef17fab59c58a2886e371124 --- /dev/null +++ b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6f117789d22dce188e5754e8bc65b7e6ebf8cb73963b9fa761f672a5883769d +size 117050 diff --git a/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-win_amd64.whl b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000000000000000000000000000000000000..c24217edbb800833bedbb0765981ab4f02967f4f --- /dev/null +++ b/offline_vendor/wheels/yarl-1.25.1-cp312-cp312-win_amd64.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d575b54cb3863ef9bc290ea4b009999d55dc237326131e4853cf33e888fee03 +size 102593 diff --git a/produce_deck_video.py b/produce_deck_video.py new file mode 100644 index 0000000000000000000000000000000000000000..2590f8607a56b6d0c560dbd99908f6b6b59ed2c6 --- /dev/null +++ b/produce_deck_video.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +""" +╔══════════════════════════════════════════════════════════════════════════════╗ +β•‘ Deck2Video Universal Portable & Air-Gapped Pipeline (Mac Β· Windows Β· Linux) β•‘ +β•‘ Inputs : PowerPoint (.pptx), Word (.docx), Markdown (.md), HTML (.html) β•‘ +β•‘ Modes : Online (HyperFrames + Edge-TTS) | Offline (--offline Zero-Network) β•‘ +β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• +""" + +from __future__ import annotations +import argparse +import json +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +PIPELINE_DIR = Path(__file__).resolve().parent +if str(PIPELINE_DIR.parent) not in sys.path: + sys.path.insert(0, str(PIPELINE_DIR.parent)) + +from deck_video_pipeline.ingest_parser import ( + create_sample_docx, + create_sample_html_slides, + create_sample_pptx, + load_input_to_spec, +) +from deck_video_pipeline.tts_timeline import build_audio_and_timeline +from deck_video_pipeline.html_builder import compile_hyperframes_project +from deck_video_pipeline.offline_renderer import render_offline_via_local_browser + + +NPX_BIN = "npx.cmd" if os.name == "nt" else "npx" + + +def ensure_project_scaffold(project_dir: Path, slug: str, offline: bool = False) -> None: + project_dir.mkdir(parents=True, exist_ok=True) + hf_json = project_dir / "hyperframes.json" + if hf_json.exists(): + return + + if not offline and shutil.which(NPX_BIN): + try: + env = dict(os.environ) + env["HYPERFRAMES_SKIP_SKILLS"] = "1" + subprocess.run( + [NPX_BIN, "--yes", "hyperframes", "init", str(project_dir), "--resolution", "landscape", "--non-interactive"], + check=True, + env=env, + timeout=30, + ) + return + except Exception as exc: + print(f"[Scaffold Info] npx init unavailable ({exc}); writing offline project manifest.") + + hf_json.write_text( + json.dumps( + { + "$schema": "https://hyperframes.heygen.com/schema/hyperframes.json", + "paths": { + "blocks": "compositions", + "components": "compositions/components", + "assets": "assets", + }, + "media": {"autoProxy": True}, + }, + indent=2, + ), + encoding="utf-8", + ) + (project_dir / "package.json").write_text( + json.dumps( + { + "name": slug, + "private": True, + "type": "module", + "scripts": { + "dev": "npx --yes hyperframes preview", + "check": "npx --yes hyperframes check", + "render": "npx --yes hyperframes render", + }, + }, + indent=2, + ), + encoding="utf-8", + ) + + +def slugify(name: str) -> str: + s = re.sub(r"[^a-zA-Z0-9_-]+", "_", name).strip("_").lower() + return s or "presentation_deck" + + +def main() -> int: + parser = argparse.ArgumentParser( + description="Convert PPTX / DOCX / Markdown / HTML presentations into code-rendered HTML + SFX MP4 videos." + ) + parser.add_argument("--input", "-i", type=str, help="Input file (.pptx, .docx, .md, .txt, .html, .htm, or .json)") + parser.add_argument("--demo", action="store_true", help="Generate sample PPTX and run full HTML + MP4 demo") + parser.add_argument("--generate-samples", action="store_true", help="Generate sample .pptx, .docx, and .html files in samples/ and exit") + parser.add_argument("--project-name", type=str, default="", help="Optional project folder name") + parser.add_argument("--output", "-o", type=str, default="", help="Output MP4 path (default: ./output/.mp4)") + parser.add_argument("--voice", type=str, default="", help="Edge-TTS voice (e.g. ko-KR-InJoonNeural, ko-KR-SunHiNeural)") + parser.add_argument("--rate", type=str, default="", help="Speech rate (e.g. +6%%)") + parser.add_argument("--offline", action="store_true", help="100%% air-gapped offline mode (OS TTS + Local Chrome/Edge CDP + FFmpeg, zero internet)") + parser.add_argument("--renderer", type=str, default="auto", choices=["auto", "hyperframes", "offline"], help="Video rendering engine") + parser.add_argument("--no-sfx", action="store_true", help="Disable UI sound effects") + parser.add_argument("--no-bgm", action="store_true", help="Disable ambient background music") + parser.add_argument("--quality", type=str, default="looks", choices=["draft", "looks", "delivery"], help="HyperFrames render quality") + parser.add_argument("--html-only", action="store_true", help="Compile HTML without rendering MP4") + args = parser.parse_args() + + use_offline = args.offline or (args.renderer == "offline") + + samples_dir = PIPELINE_DIR / "samples" + if args.generate_samples: + p_pptx = create_sample_pptx(samples_dir / "sample_ai_sync_lecture.pptx") + p_docx = create_sample_docx(samples_dir / "sample_word_guide.docx") + p_html = create_sample_html_slides(samples_dir / "sample_web_slides.html") + print(f"Generated samples:\n - {p_pptx}\n - {p_docx}\n - {p_html}") + return 0 + + if args.demo or not args.input: + sample_pptx = samples_dir / "sample_ai_sync_lecture.pptx" + print(f"[1/5] Generating sample PowerPoint deck: {sample_pptx}") + create_sample_pptx(sample_pptx) + input_path = sample_pptx + else: + input_path = Path(args.input).expanduser().resolve() + if not input_path.exists(): + print(f"[Error] Input file not found: {input_path}", file=sys.stderr) + return 1 + + proj_slug = slugify(args.project_name or input_path.stem) + project_dir = PIPELINE_DIR / "projects" / proj_slug + ensure_project_scaffold(project_dir, proj_slug, offline=use_offline) + + print(f"[2/5] Parsing '{input_path.name}' ({input_path.suffix.lower()}) into motion scene archetypes...") + spec = load_input_to_spec(input_path) + if args.voice: + spec["voice"] = args.voice + if args.rate: + spec["voice_rate"] = args.rate + + print(f"[3/5] Synthesizing {'OFFLINE OS' if use_offline else 'Edge-TTS'} voiceover, 6-type UI SFX & BGM timeline...") + spec = build_audio_and_timeline( + spec=spec, + project_dir=project_dir, + enable_sfx=not args.no_sfx, + enable_bgm=not args.no_bgm, + offline=use_offline, + ) + + spec_out = project_dir / "deck_spec_compiled.json" + spec_out.write_text(json.dumps(spec, ensure_ascii=False, indent=2), encoding="utf-8") + + print(f"[4/5] Compiling HTML composition ({spec['total_duration']}s, {len(spec['slides'])} scenes)...") + index_html = compile_hyperframes_project(spec, project_dir) + print(f" HTML written to: {index_html}") + + if not use_offline and shutil.which(NPX_BIN): + print("[4.5/5] Running HyperFrames check (lint + runtime + layout + WCAG contrast)...") + chk = subprocess.run( + [NPX_BIN, "--yes", "hyperframes", "check", str(project_dir), "--json"], + capture_output=True, + text=True, + ) + try: + chk_data = json.loads(chk.stdout) + print(f" Check ok={chk_data.get('ok')} | browserSkipped={chk_data.get('browserSkipped')}") + except Exception: + pass + + if args.html_only: + print("[Done] HTML-only mode complete.") + return 0 + + default_out_dir = Path.cwd() / "output" + output_mp4 = ( + Path(args.output).expanduser().resolve() + if args.output + else (default_out_dir / f"{proj_slug}.mp4") + ) + output_mp4.parent.mkdir(parents=True, exist_ok=True) + + prefer_hf = (args.renderer in ("auto", "hyperframes")) and (not args.offline) and bool(shutil.which(NPX_BIN)) + if prefer_hf: + try: + print(f"[5/5] Rendering 1920x1080 MP4 via HyperFrames ({args.quality}) -> {output_mp4} ...") + env = dict(os.environ) + env["HYPERFRAMES_RENDER_DETACHED"] = "1" + subprocess.run( + [ + NPX_BIN, "--yes", "hyperframes", "render", + str(project_dir), + "--quality", args.quality, + "--output", str(output_mp4), + ], + check=True, + env=env, + ) + print(f"\nβœ… Render complete: {output_mp4} ({output_mp4.stat().st_size / (1024 * 1024):.2f} MB)") + return 0 + except Exception as exc: + if args.renderer == "hyperframes": + raise + print(f"[Render Fallback] HyperFrames unavailable ({exc}); switching to local offline browser renderer...") + + print(f"[5/5] Rendering 1920x1080 MP4 via Zero-NPM Offline Browser Renderer -> {output_mp4} ...") + render_offline_via_local_browser(project_dir, spec, output_mp4, fps=30) + print(f"\nβœ… Offline Render complete: {output_mp4} ({output_mp4.stat().st_size / (1024 * 1024):.2f} MB)") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..e215c2f4368b624b53402e7e29720616e371e6a7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[build-system] +requires = ["setuptools>=68.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "deck-video-pipeline" +version = "1.0.0" +description = "Universal PPTX / DOCX / Markdown / HTML to Code-Rendered Motion + SFX MP4 Pipeline" +readme = "README.md" +requires-python = ">=3.10" +dependencies = [ + "python-pptx>=0.6.23", + "python-docx>=1.1.0", + "beautifulsoup4>=4.12.0", + "edge-tts>=6.1.12", + "numpy>=1.26.0", +] + +[tool.setuptools] +package-dir = {"deck_video_pipeline" = "."} +packages = ["deck_video_pipeline"] + +[project.scripts] +deck2video = "deck_video_pipeline.produce_deck_video:main" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..9adee8ba200e2c95c619693a9fade7a0bd6ad032 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +python-pptx>=0.6.23 +python-docx>=1.1.0 +beautifulsoup4>=4.12.0 +edge-tts>=6.1.12 +numpy>=1.26.0 diff --git a/samples/sample_ai_sync_lecture.pptx b/samples/sample_ai_sync_lecture.pptx new file mode 100644 index 0000000000000000000000000000000000000000..0f5f25c53d14ab5370bbe998750fd4a4f7e65333 Binary files /dev/null and b/samples/sample_ai_sync_lecture.pptx differ diff --git a/samples/sample_lecture_notes.md b/samples/sample_lecture_notes.md new file mode 100644 index 0000000000000000000000000000000000000000..42605c12c59c9a7ca171574ca5c5d86c940d4624 --- /dev/null +++ b/samples/sample_lecture_notes.md @@ -0,0 +1,13 @@ +# AI 싀무 ꡐ윑 Β· λ¬Έμ„œμ—μ„œ λͺ¨μ…˜ μ˜μƒκΉŒμ§€ + +## 01 μ •μ§€λœ κ΅μ•ˆμ„ μ‚΄μ•„μžˆλŠ” μ˜μƒμœΌλ‘œ +- 핡심 κ°œλ… | ν…μŠ€νŠΈ 쀑심 μŠ¬λΌμ΄λ“œλ₯Ό μ‹œκ° μ»΄ν¬λ„ŒνŠΈλ‘œ μž¬κ΅¬μ„± +- μ‹œμ„  μœ λ„ | ν˜„μž¬ μ„€λͺ… 쀑인 μΉ΄λ“œλ§Œ λ„€μ˜¨ 포컀슀 κ°•μ‘° +- μ‚¬μš΄λ“œ κ²°ν•© | ν™”λ©΄ μ „ν™˜κ³Ό λ™μ‹œμ— UI 효과음 μžλ™ μž¬μƒ +> 이제 κ°•μ˜ κ΅μ•ˆμ„ 직접 λ…Ήν™”ν•˜λ©° νŽΈμ§‘ν•  ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€. || No more manual screen-recording and timeline editing. +> λ§ˆν¬λ‹€μš΄μ΄λ‚˜ νŒŒμ›Œν¬μΈνŠΈ λ¬Έμ„œ ν•˜λ‚˜λ§Œ 있으면 λͺ¨μ…˜ μ˜μƒμ΄ μ™„μ„±λ©λ‹ˆλ‹€. || A single Markdown or PPTX file compiles straight into a motion video. + +## 02 반볡 μž‘μ—…μ€ μ½”λ“œ ν…œν”Œλ¦ΏμœΌλ‘œ μžμ‚°ν™” +- 상단 챕터바, νŒŒν‹°ν΄ μ›¨μ΄λΈŒ, 이쀑 μžλ§‰μ„ ν‘œμ€€ λ ˆμ΄μ•„μ›ƒμœΌλ‘œ κ³ μ • +- μƒˆλ‘œμš΄ κ°•μ˜μ•ˆμ΄ 듀어와도 λ™μΌν•œ λΈŒλžœλ“œ 퀄리티 μ¦‰μ‹œ μž¬ν˜„ +> ν•œ 번 잘 λ§Œλ“  ν”„λ ˆμ  ν…Œμ΄μ…˜ 포맷은 μ½”λ“œλ‘œ 남겨 μž¬μ‚¬μš©ν•˜μ„Έμš”. || Save great presentation formats as reusable code templates. diff --git a/samples/sample_sync_deck.mp4 b/samples/sample_sync_deck.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..53559e7efc02085949d9d2003fff1ba447d47160 --- /dev/null +++ b/samples/sample_sync_deck.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dd7b768c45eab6e92a6684a73585408f90ea892d25634dbfa007902662b1d59 +size 18503625 diff --git a/samples/sample_web_slides.html b/samples/sample_web_slides.html new file mode 100644 index 0000000000000000000000000000000000000000..da5491e514ebcf8dbee9d5b3813b115e343fe413 --- /dev/null +++ b/samples/sample_web_slides.html @@ -0,0 +1,17 @@ + + +μ›Ή μŠ¬λΌμ΄λ“œ μ˜μƒ λ³€ν™˜ μƒ˜ν”Œ + +
    +

    HTML ν”„λ ˆμ  ν…Œμ΄μ…˜λ„ κ·ΈλŒ€λ‘œ MP4둜

    +
      +
    • μ„Ήμ…˜ μžλ™ 인식 | Reveal.js 및 일반 μ›Ή μŠ¬λΌμ΄λ“œ νƒœκ·Έ νŒŒμ‹±
    • +
    • λ°œν‘œ λ…ΈνŠΈ 연동 | aside.notes νƒœκ·Έλ₯Ό 읽어 μ„±μš° λ‚΄λ ˆμ΄μ…˜ ν•©μ„±
    • +
    • 효과음 κ²°ν•© | ν™”λ©΄ μ „ν™˜κ³Ό μΉ΄λ“œ ν¬μ»€μŠ€μ— 맞좰 UI μ‚¬μš΄λ“œ λ―Ήμ‹±
    • +
    + +
    + + diff --git a/samples/sample_word_guide.docx b/samples/sample_word_guide.docx new file mode 100644 index 0000000000000000000000000000000000000000..9cfa2751b1051030baf413d7c03cdf3593b8aeaf Binary files /dev/null and b/samples/sample_word_guide.docx differ diff --git a/sfx_engine.py b/sfx_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..ee8adc7a18815ca063d4301d043650879309d481 --- /dev/null +++ b/sfx_engine.py @@ -0,0 +1,210 @@ +""" +Procedural Broadcast UI & Presentation Sound Effects (SFX) Synthesizer +Generates 48kHz 16-bit Stereo WAV files for Slide Transitions, Card Focus Pops, +Number Counter Ticks, Terminal Typing, Highlighter Sweeps, and Insight Chimes. +""" + +from pathlib import Path +import wave +import numpy as np + +SAMPLE_RATE = 48000 + + +def _save_stereo_wav(path: Path, left: np.ndarray, right: np.ndarray, peak: float = 0.85) -> Path: + path.parent.mkdir(parents=True, exist_ok=True) + max_val = max(float(np.max(np.abs(left))), float(np.max(np.abs(right))), 1e-6) + scale = peak / max_val + stereo = np.stack([left * scale, right * scale], axis=-1) + pcm = np.clip(stereo * 32767.0, -32768, 32767).astype(np.int16) + with wave.open(str(path), "wb") as wf: + wf.setnchannels(2) + wf.setsampwidth(2) + wf.setframerate(SAMPLE_RATE) + wf.writeframes(pcm.tobytes()) + return path + + +def _one_pole_lowpass(signal: np.ndarray, cutoff_hz: np.ndarray) -> np.ndarray: + out = np.zeros_like(signal) + dt = 1.0 / SAMPLE_RATE + rc = 1.0 / (2.0 * np.pi * np.maximum(cutoff_hz, 20.0)) + alpha = dt / (rc + dt) + prev = 0.0 + for i in range(len(signal)): + prev = prev + alpha[i] * (signal[i] - prev) + out[i] = prev + return out + + +def synth_whoosh_transition(out_path: Path) -> Path: + """Airy cinematic slide/chapter transition whoosh + warm sub-thump (0.56s).""" + dur = 0.56 + n = int(SAMPLE_RATE * dur) + t = np.linspace(0.0, dur, n, endpoint=False) + rng = np.random.default_rng(42) + + noise_l = rng.standard_normal(n) + noise_r = rng.standard_normal(n) + + # Sweeping cutoff curve: 180Hz -> 1650Hz -> 220Hz + bell = np.sin(np.pi * (t / dur)) ** 1.6 + cutoff = 180.0 + 1500.0 * bell + swept_l = _one_pole_lowpass(noise_l, cutoff) - _one_pole_lowpass(noise_l, cutoff * 0.28) + swept_r = _one_pole_lowpass(noise_r, cutoff * 1.04) - _one_pole_lowpass(noise_r, cutoff * 0.28) + + env = np.sin(np.pi * (t / dur)) ** 1.8 + # Subtle stereo pan movement L -> R + pan_l = np.cos(0.5 * np.pi * (0.25 + 0.5 * (t / dur))) + pan_r = np.sin(0.5 * np.pi * (0.25 + 0.5 * (t / dur))) + + # Soft warm sub-bass body around peak + sub_freq = 78.0 - 26.0 * (t / dur) + sub_phase = 2.0 * np.pi * np.cumsum(sub_freq) / SAMPLE_RATE + sub = np.sin(sub_phase) * np.exp(-((t - 0.22) ** 2) / (2.0 * 0.085**2)) * 0.45 + + left = swept_l * env * pan_l * 0.9 + sub + right = swept_r * env * pan_r * 0.9 + sub + return _save_stereo_wav(out_path, left, right, peak=0.72) + + +def synth_card_focus_pop(out_path: Path) -> Path: + """Clean Linear/Apple-style glass card highlight pop (0.22s).""" + dur = 0.22 + n = int(SAMPLE_RATE * dur) + t = np.linspace(0.0, dur, n, endpoint=False) + + # Crisp soft transient pitch glide 720Hz -> 440Hz + harmonic overtone + freq = 440.0 + 280.0 * np.exp(-t * 38.0) + phase = 2.0 * np.pi * np.cumsum(freq) / SAMPLE_RATE + attack = np.minimum(t / 0.004, 1.0) + decay = np.exp(-t * 21.0) + + tone = np.sin(phase) * 0.75 + np.sin(phase * 2.0 + 0.3) * 0.25 * np.exp(-t * 34.0) + shimmer_l = np.sin(2.0 * np.pi * 1320.0 * t) * np.exp(-t * 42.0) * 0.14 + shimmer_r = np.sin(2.0 * np.pi * 1326.0 * t + 0.5) * np.exp(-t * 42.0) * 0.14 + + left = (tone + shimmer_l) * attack * decay + right = (tone + shimmer_r) * attack * decay + return _save_stereo_wav(out_path, left, right, peak=0.68) + + +def synth_counter_tick(out_path: Path) -> Path: + """Precision digital UI counter roll-up ticks (0.95s).""" + dur = 0.95 + n = int(SAMPLE_RATE * dur) + left = np.zeros(n) + right = np.zeros(n) + + # 13 ticks with ease-out spacing (fast at start, settling at end) + u = np.linspace(0.0, 1.0, 13) + tick_times = 0.02 + 0.78 * (1.0 - (1.0 - u) ** 1.75) + + for idx, ts in enumerate(tick_times): + start_i = int(ts * SAMPLE_RATE) + tick_len = int(0.032 * SAMPLE_RATE) + end_i = min(n, start_i + tick_len) + seg_t = np.arange(end_i - start_i) / SAMPLE_RATE + pitch = 980.0 + idx * 28.0 + env = np.minimum(seg_t / 0.0015, 1.0) * np.exp(-seg_t * 135.0) + gain = 0.55 + 0.45 * (idx / max(len(tick_times) - 1, 1)) + sig = (np.sin(2.0 * np.pi * pitch * seg_t) + 0.35 * np.sin(2.0 * np.pi * pitch * 2.4 * seg_t)) * env * gain + pan = 0.42 + 0.16 * (idx % 2) + left[start_i:end_i] += sig * (1.0 - pan * 0.3) + right[start_i:end_i] += sig * (0.7 + pan * 0.3) + + return _save_stereo_wav(out_path, left, right, peak=0.62) + + +def synth_terminal_type(out_path: Path) -> Path: + """Soft-tactile dark terminal command typing burst (1.10s).""" + dur = 1.10 + n = int(SAMPLE_RATE * dur) + left = np.zeros(n) + right = np.zeros(n) + rng = np.random.default_rng(108) + + key_offsets = [0.02, 0.09, 0.15, 0.23, 0.29, 0.36, 0.46, 0.53, 0.60, 0.68, 0.75, 0.84, 0.93] + for idx, ts in enumerate(key_offsets): + start_i = int(ts * SAMPLE_RATE) + klen = int(0.028 * SAMPLE_RATE) + end_i = min(n, start_i + klen) + seg_t = np.arange(end_i - start_i) / SAMPLE_RATE + click_noise = rng.standard_normal(len(seg_t)) * np.exp(-seg_t * 260.0) * 0.35 + thock_freq = 310.0 + (idx % 4) * 24.0 + thock = np.sin(2.0 * np.pi * thock_freq * seg_t) * np.exp(-seg_t * 145.0) * 0.65 + sig = (click_noise + thock) * np.minimum(seg_t / 0.001, 1.0) + left[start_i:end_i] += sig * 0.95 + right[start_i:end_i] += sig * 1.0 + + return _save_stereo_wav(out_path, left, right, peak=0.58) + + +def synth_highlighter_sweep(out_path: Path) -> Path: + """Silky crystal shimmer sweep for textbook/quote highlighter (0.65s).""" + dur = 0.65 + n = int(SAMPLE_RATE * dur) + t = np.linspace(0.0, dur, n, endpoint=False) + rng = np.random.default_rng(77) + + # Gentle airy brush + rising harmonic shimmer 587Hz -> 880Hz + brush = _one_pole_lowpass(rng.standard_normal(n), np.linspace(900.0, 2400.0, n)) * 0.18 + freq = np.linspace(587.33, 880.0, n) + phase = 2.0 * np.pi * np.cumsum(freq) / SAMPLE_RATE + env = np.sin(np.pi * (t / dur)) ** 1.4 * np.exp(-t * 1.8) + + left = (brush + np.sin(phase) * 0.55 + np.sin(phase * 1.5) * 0.25) * env + right = (brush + np.sin(phase + 0.35) * 0.55 + np.sin(phase * 1.5 + 0.2) * 0.25) * env + return _save_stereo_wav(out_path, left, right, peak=0.56) + + +def synth_insight_chime(out_path: Path) -> Path: + """Warm ambient Cmaj9 glass bell chime for takeaway/summary reveal (1.25s).""" + dur = 1.25 + n = int(SAMPLE_RATE * dur) + t = np.linspace(0.0, dur, n, endpoint=False) + + notes = [ + (523.25, 0.00, 0.42), # C5 + (659.25, 0.04, 0.34), # E5 + (783.99, 0.08, 0.30), # G5 + (987.77, 0.12, 0.22), # B5 + (1174.66, 0.16, 0.18), # D6 + ] + left = np.zeros(n) + right = np.zeros(n) + for freq, delay, amp in notes: + dt = np.maximum(0.0, t - delay) + active = (t >= delay).astype(float) + env = np.minimum(dt / 0.008, 1.0) * np.exp(-dt * 3.4) * active + left += np.sin(2.0 * np.pi * freq * dt) * env * amp + right += np.sin(2.0 * np.pi * (freq * 1.0015) * dt + 0.25) * env * amp + + return _save_stereo_wav(out_path, left, right, peak=0.65) + + +def ensure_sfx_pack(sfx_dir: Path) -> dict[str, Path]: + """Generates all 6 UI presentation SFX WAVs into `sfx_dir` and returns their paths.""" + sfx_dir.mkdir(parents=True, exist_ok=True) + builders = { + "whoosh": ("sfx_whoosh.wav", synth_whoosh_transition), + "pop": ("sfx_card_pop.wav", synth_card_focus_pop), + "tick": ("sfx_counter_tick.wav", synth_counter_tick), + "type": ("sfx_terminal_type.wav", synth_terminal_type), + "highlight": ("sfx_highlighter_sweep.wav", synth_highlighter_sweep), + "chime": ("sfx_insight_chime.wav", synth_insight_chime), + } + out = {} + for key, (fname, fn) in builders.items(): + target = sfx_dir / fname + if not target.exists() or target.stat().st_size < 1000: + fn(target) + out[key] = target + return out + + +if __name__ == "__main__": + out_dir = Path(__file__).resolve().parent / "assets" / "sfx" + pack = ensure_sfx_pack(out_dir) + for k, p in pack.items(): + print(f"Generated SFX [{k}]: {p} ({p.stat().st_size:,} bytes)") diff --git a/tts_timeline.py b/tts_timeline.py new file mode 100644 index 0000000000000000000000000000000000000000..a9201086389bff4d50ab074413a12e49b3fec31e --- /dev/null +++ b/tts_timeline.py @@ -0,0 +1,373 @@ +""" +Cross-Platform TTS Voiceover (Online Edge-TTS + Offline OS-Native Fallback), +Exact Beat Timeline, SFX Cue Scheduler & BGM Mixer. +Works identically on Windows, macOS, and Linux β€” both ONLINE and OFFLINE. +""" + +from __future__ import annotations +import hashlib +import os +import platform +import shutil +import subprocess +import sys +import wave +from pathlib import Path +from typing import Any +import numpy as np + +PIPELINE_DIR = Path(__file__).resolve().parent +if str(PIPELINE_DIR.parent) not in sys.path: + sys.path.insert(0, str(PIPELINE_DIR.parent)) + +from deck_video_pipeline.sfx_engine import ensure_sfx_pack +from deck_video_pipeline.bgm_engine import get_or_create_bgm_source + + +def _find_binary(name: str) -> str: + found = shutil.which(name) + if found: + return found + for candidate in (f"/opt/homebrew/bin/{name}", f"/usr/local/bin/{name}", f"/usr/bin/{name}"): + if Path(candidate).exists(): + return candidate + raise RuntimeError( + f"Required binary '{name}' not found on PATH. " + f"Install FFmpeg first (macOS: `brew install ffmpeg`, Windows: `winget install Gyan.FFmpeg`, Ubuntu: `sudo apt install ffmpeg`)." + ) + + +def probe_duration(media_path: Path) -> float: + ffprobe_bin = _find_binary("ffprobe") + cmd = [ + ffprobe_bin, + "-v", "error", + "-show_entries", "format=duration", + "-of", "default=noprint_wrappers=1:nokey=1", + str(media_path), + ] + res = subprocess.run(cmd, capture_output=True, text=True, check=True) + return max(0.2, round(float(res.stdout.strip()), 3)) + + +def _synth_offline_os_tts(text: str, raw_audio_out: Path) -> bool: + """ + Attempts OS-native 100% offline TTS synthesis: + - macOS: `/usr/bin/say -v Yuna` (Korean) + - Windows: PowerShell `System.Speech.Synthesis.SpeechSynthesizer` + - Linux: `espeak-ng -v ko` + Returns True if speech audio was written, False otherwise. + """ + system = platform.system().lower() + try: + if system == "darwin" and Path("/usr/bin/say").exists(): + aiff_tmp = raw_audio_out.with_suffix(".aiff") + res = subprocess.run( + ["/usr/bin/say", "-v", "Yuna", "-r", "195", "-o", str(aiff_tmp), text], + capture_output=True, + ) + if res.returncode != 0: + subprocess.run(["/usr/bin/say", "-o", str(aiff_tmp), text], check=True, capture_output=True) + if aiff_tmp.exists() and aiff_tmp.stat().st_size > 500: + aiff_tmp.replace(raw_audio_out) + return True + + elif system == "windows": + wav_tmp = raw_audio_out.with_suffix(".wav") + escaped = text.replace("'", "''") + ps_script = ( + "Add-Type -AssemblyName System.Speech; " + "$s = New-Object System.Speech.Synthesis.SpeechSynthesizer; " + "try { $s.SelectVoiceByHints([System.Speech.Synthesis.VoiceGender]::NotSet, " + "[System.Speech.Synthesis.VoiceAge]::NotSet, 0, [System.Globalization.CultureInfo]::GetCultureInfo('ko-KR')) } catch {}; " + f"$s.SetOutputToWaveFile('{wav_tmp}'); " + f"$s.Speak('{escaped}'); $s.Dispose();" + ) + subprocess.run(["powershell", "-NoProfile", "-Command", ps_script], check=True, capture_output=True) + if wav_tmp.exists() and wav_tmp.stat().st_size > 500: + wav_tmp.replace(raw_audio_out) + return True + + else: + espeak = shutil.which("espeak-ng") or shutil.which("espeak") + if espeak: + wav_tmp = raw_audio_out.with_suffix(".wav") + subprocess.run([espeak, "-v", "ko", "-s", "165", "-w", str(wav_tmp), text], check=True, capture_output=True) + if wav_tmp.exists() and wav_tmp.stat().st_size > 500: + wav_tmp.replace(raw_audio_out) + return True + except Exception as exc: + print(f"[Offline TTS Warning] OS voice fallback error: {exc}") + return False + + +def _synth_silent_timed_wav(text: str, wav_out: Path) -> None: + """Last-resort silent pacing track (approx 0.14s per character, min 2.2s) if headless Linux has no TTS.""" + dur = max(2.2, min(8.0, len(text.strip()) * 0.14)) + sr = 48000 + pcm = np.zeros((int(sr * dur), 2), dtype=np.int16) + with wave.open(str(wav_out), "wb") as wf: + wf.setnchannels(2) + wf.setsampwidth(2) + wf.setframerate(sr) + wf.writeframes(pcm.tobytes()) + + +def synthesize_beat_tts( + text: str, + out_mp3: Path, + voice: str = "ko-KR-InJoonNeural", + rate: str = "+6%", + offline: bool = False, +) -> float: + ffmpeg_bin = _find_binary("ffmpeg") + out_mp3.parent.mkdir(parents=True, exist_ok=True) + raw_src = out_mp3.with_suffix(".raw_src") + + if not out_mp3.exists() or out_mp3.stat().st_size < 500: + used_online = False + if not offline: + try: + raw_mp3 = out_mp3.with_suffix(".raw.mp3") + cmd_tts = [ + sys.executable, "-m", "edge_tts", + "--voice", voice, + f"--rate={rate}", + "--text", text, + "--write-media", str(raw_mp3), + ] + subprocess.run(cmd_tts, check=True, capture_output=True, timeout=20) + raw_mp3.replace(raw_src) + used_online = True + except Exception as exc: + print(f"[TTS Info] Online Edge-TTS unavailable ({type(exc).__name__}); switching to offline OS TTS.") + + if not used_online: + if not _synth_offline_os_tts(text, raw_src): + _synth_silent_timed_wav(text, raw_src) + + cmd_trim = [ + ffmpeg_bin, "-y", + "-i", str(raw_src), + "-af", ( + "silenceremove=start_periods=1:start_duration=0.03:start_threshold=-45dB," + "areverse,silenceremove=start_periods=1:start_duration=0.05:start_threshold=-45dB,areverse" + ), + "-ar", "48000", + "-ac", "2", + "-c:a", "libmp3lame", + "-b:a", "192k", + str(out_mp3), + ] + res = subprocess.run(cmd_trim, capture_output=True) + if res.returncode != 0 or not out_mp3.exists() or out_mp3.stat().st_size < 300: + # In case silenceremove trimmed an all-silent fallback track completely + subprocess.run( + [ffmpeg_bin, "-y", "-i", str(raw_src), "-ar", "48000", "-ac", "2", "-c:a", "libmp3lame", "-b:a", "192k", str(out_mp3)], + check=True, + capture_output=True, + ) + raw_src.unlink(missing_ok=True) + + return probe_duration(out_mp3) + + +def build_audio_and_timeline( + spec: dict[str, Any], + project_dir: Path, + enable_sfx: bool = True, + enable_bgm: bool = True, + offline: bool = False, +) -> dict[str, Any]: + ffmpeg_bin = _find_binary("ffmpeg") + audio_dir = project_dir / "assets" / "audio" + beats_dir = audio_dir / "beats" + sfx_dir = audio_dir / "sfx" + beats_dir.mkdir(parents=True, exist_ok=True) + sfx_dir.mkdir(parents=True, exist_ok=True) + + # Also copy pre-bundled SFX if present, or synthesize missing ones + bundled_sfx = PIPELINE_DIR / "assets" / "sfx" + if bundled_sfx.exists(): + for wav in bundled_sfx.glob("*.wav"): + dst = sfx_dir / wav.name + if not dst.exists(): + shutil.copy2(wav, dst) + + voice = spec.get("voice", "ko-KR-InJoonNeural") + rate = spec.get("voice_rate", "+6%") + + sfx_map = ensure_sfx_pack(sfx_dir) if enable_sfx else {} + sfx_durations = {k: probe_duration(p) for k, p in sfx_map.items()} + + cursor = 0.0 + intro_pad = 0.28 + inter_beat_gap = 0.22 + outro_pad = 0.38 + + sfx_events: list[dict[str, Any]] = [] + + for s_idx, slide in enumerate(spec["slides"]): + slide_start = round(cursor, 3) + t = round(slide_start + intro_pad, 3) + + if enable_sfx: + sfx_events.append({ + "id": f"sfx-whoosh-s{s_idx + 1}", + "kind": "whoosh", + "src": f"assets/audio/sfx/{sfx_map['whoosh'].name}", + "start": round(max(0.0, slide_start + 0.02), 3), + "duration": sfx_durations["whoosh"], + "volume": 0.34, + }) + + enriched_beats = [] + mode_tag = "offline" if offline else voice + for b_idx, beat in enumerate(slide["beats"]): + text_hash = hashlib.md5(f"{mode_tag}:{rate}:{beat['narration']}".encode("utf-8")).hexdigest()[:8] + fname = f"s{s_idx + 1:02d}_b{b_idx + 1:02d}_{text_hash}.mp3" + beat_mp3 = beats_dir / fname + dur = synthesize_beat_tts(beat["narration"], beat_mp3, voice=voice, rate=rate, offline=offline) + + b_start = round(t, 3) + b_end = round(b_start + dur, 3) + enriched_beats.append({ + "id": f"vo-s{s_idx + 1:02d}-b{b_idx + 1:02d}", + "src": f"assets/audio/beats/{fname}", + "narration": beat["narration"], + "sub_ko": beat.get("sub_ko") or beat["narration"], + "sub_en": beat.get("sub_en", ""), + "start": b_start, + "duration": dur, + "end": b_end, + }) + t = round(b_end + inter_beat_gap, 3) + + slide_end = round(t - inter_beat_gap + outro_pad, 3) + slide_dur = round(slide_end - slide_start, 3) + + slide["start"] = slide_start + slide["duration"] = slide_dur + slide["end"] = slide_end + slide["beats"] = enriched_beats + + if enable_sfx: + arch = slide["archetype"] + if arch == "arc_cards": + sfx_events.append({ + "id": f"sfx-tick-s{s_idx + 1}", + "kind": "tick", + "src": f"assets/audio/sfx/{sfx_map['tick'].name}", + "start": round(slide_start + 0.26, 3), + "duration": sfx_durations["tick"], + "volume": 0.28, + }) + if len(enriched_beats) > 1: + sfx_events.append({ + "id": f"sfx-pop-arc-s{s_idx + 1}", + "kind": "pop", + "src": f"assets/audio/sfx/{sfx_map['pop'].name}", + "start": round(enriched_beats[1]["start"] - 0.04, 3), + "duration": sfx_durations["pop"], + "volume": 0.30, + }) + elif arch == "mockup_steps": + for b_i, b_info in enumerate(enriched_beats[:3]): + sfx_events.append({ + "id": f"sfx-pop-s{s_idx + 1}-b{b_i + 1}", + "kind": "pop", + "src": f"assets/audio/sfx/{sfx_map['pop'].name}", + "start": round(max(slide_start + 0.18, b_info["start"] - 0.03), 3), + "duration": sfx_durations["pop"], + "volume": 0.34, + }) + elif arch == "book_quote": + hl_time = enriched_beats[1]["start"] if len(enriched_beats) > 1 else (slide_start + 1.1) + sfx_events.append({ + "id": f"sfx-hl-s{s_idx + 1}", + "kind": "highlight", + "src": f"assets/audio/sfx/{sfx_map['highlight'].name}", + "start": round(max(slide_start + 0.4, hl_time), 3), + "duration": sfx_durations["highlight"], + "volume": 0.32, + }) + elif arch == "terminal_flow": + sfx_events.append({ + "id": f"sfx-type-s{s_idx + 1}", + "kind": "type", + "src": f"assets/audio/sfx/{sfx_map['type'].name}", + "start": round(slide_start + 0.28, 3), + "duration": sfx_durations["type"], + "volume": 0.32, + }) + flow_time = enriched_beats[1]["start"] if len(enriched_beats) > 1 else (slide_start + 1.8) + sfx_events.append({ + "id": f"sfx-pop-flow-s{s_idx + 1}", + "kind": "pop", + "src": f"assets/audio/sfx/{sfx_map['pop'].name}", + "start": round(flow_time, 3), + "duration": sfx_durations["pop"], + "volume": 0.32, + }) + elif arch == "metric_summary": + for p_i in range(3): + sfx_events.append({ + "id": f"sfx-pop-sum-s{s_idx + 1}-{p_i + 1}", + "kind": "pop", + "src": f"assets/audio/sfx/{sfx_map['pop'].name}", + "start": round(slide_start + 0.24 + p_i * 0.26, 3), + "duration": sfx_durations["pop"], + "volume": 0.28, + }) + chime_start = enriched_beats[-1]["start"] if enriched_beats else (slide_start + 1.2) + sfx_events.append({ + "id": f"sfx-chime-s{s_idx + 1}", + "kind": "chime", + "src": f"assets/audio/sfx/{sfx_map['chime'].name}", + "start": round(min(chime_start, max(slide_start + 0.5, slide_end - sfx_durations["chime"] - 0.05)), 3), + "duration": sfx_durations["chime"], + "volume": 0.34, + }) + + cursor = slide_end + + total_duration = round(cursor + 0.35, 3) + spec["total_duration"] = total_duration + + valid_sfx = [ev for ev in sfx_events if ev["start"] + ev["duration"] <= total_duration] + spec["sfx_events"] = valid_sfx + + spec["bgm"] = None + if enable_bgm: + try: + bgm_cache = PIPELINE_DIR / "assets" / "bgm" + src_bgm, bgm_title = get_or_create_bgm_source( + bgm_cache, mood=spec.get("bgm_mood", "focused"), duration_sec=total_duration + ) + bgm_out = audio_dir / "bgm_bed.mp3" + fade_out_start = max(0.5, round(total_duration - 1.8, 3)) + cmd_bgm = [ + ffmpeg_bin, "-y", + "-stream_loop", "-1", + "-i", str(src_bgm), + "-t", str(total_duration), + "-af", f"afade=t=in:st=0:d=1.0,afade=t=out:st={fade_out_start}:d=1.7", + "-ar", "48000", + "-ac", "2", + "-c:a", "libmp3lame", + "-b:a", "192k", + str(bgm_out), + ] + subprocess.run(cmd_bgm, check=True, capture_output=True) + spec["bgm"] = { + "id": "audio-bgm-bed", + "title": bgm_title, + "src": "assets/audio/bgm_bed.mp3", + "start": 0.0, + "duration": total_duration, + "volume": 0.11, + } + except Exception as exc: + print(f"[BGM Warning] Skipping BGM bed: {exc}") + + return spec