Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(narration): order page SRTs and notes numerically, like the slide roster

hugohe31036fd53a254
diff --git a/skills/ppt-master/scripts/narration_sync.py b/skills/ppt-master/scripts/narration_sync.py
index 6eced8df..7b38fcf8 100644
--- a/skills/ppt-master/scripts/narration_sync.py
+++ b/skills/ppt-master/scripts/narration_sync.py
@@ -51,6 +51,7 @@ if str(_SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPTS_DIR))
from console_encoding import configure_utf8_stdio # noqa: E402
+from slide_roster import sort_slide_paths # noqa: E402
from pptx_animations import ( # noqa: E402
ANIMATION_TIMING_OPTION_FIELDS,
animation_seconds_to_milliseconds,
@@ -494,7 +495,7 @@ def _page_subtitle_names(subtitle_dir: Path) -> list[str]:
raise FileNotFoundError(f"Page-local SRT directory not found: {subtitle_dir}")
names = [
path.stem
- for path in sorted(subtitle_dir.glob("*.srt"))
+ for path in sort_slide_paths(subtitle_dir.glob("*.srt"))
if path.stem != "total"
]
if not names:
diff --git a/skills/ppt-master/scripts/notes_to_audio.py b/skills/ppt-master/scripts/notes_to_audio.py
index d105d0fa..81d67c11 100644
--- a/skills/ppt-master/scripts/notes_to_audio.py
+++ b/skills/ppt-master/scripts/notes_to_audio.py
@@ -45,7 +45,7 @@ from pptx_workspace import (
AUTHORING_SVG_FLAT_DIR,
ROUNDTRIP_MANIFEST_PATH,
)
-from slide_roster import discover_slide_svgs
+from slide_roster import discover_slide_svgs, sort_slide_paths
from tts_backends import (
backend_cosyvoice,
backend_edge,
@@ -151,7 +151,7 @@ def _expected_note_roster(project: Path) -> list[NoteRosterEntry]:
svg_files = discover_slide_svgs(project / "svg_output")
if svg_files:
aliases: dict[int, list[Path]] = {}
- for path in sorted(notes_dir.glob("*.md")):
+ for path in sort_slide_paths(notes_dir.glob("*.md")):
match = re.search(r"slide[_]?(\d+)", path.stem)
if match:
aliases.setdefault(int(match.group(1)), []).append(path)
@@ -255,7 +255,7 @@ def _expected_note_roster(project: Path) -> list[NoteRosterEntry]:
note_path=path,
output_stem=path.stem,
)
- for path in sorted(notes_dir.glob("*.md"))
+ for path in sort_slide_paths(notes_dir.glob("*.md"))
if path.name != "total.md"
]
diff --git a/skills/ppt-master/scripts/slide_roster.py b/skills/ppt-master/scripts/slide_roster.py
index 89022e6b..44f9cc24 100644
--- a/skills/ppt-master/scripts/slide_roster.py
+++ b/skills/ppt-master/scripts/slide_roster.py
@@ -17,6 +17,7 @@ Dependencies:
from __future__ import annotations
import re
+from collections.abc import Iterable
from pathlib import Path
@@ -36,9 +37,11 @@ def _slide_filename_sort_key(
return segments, name
+def sort_slide_paths(paths: Iterable[Path]) -> list[Path]:
+ """Order per-page files (SVG, notes, SRT) by numeric filename segments."""
+ return sorted(paths, key=_slide_filename_sort_key)
+
+
def discover_slide_svgs(directory: Path) -> list[Path]:
"""Return direct child SVG files in numeric filename order."""
- return sorted(
- directory.glob("*.svg"),
- key=_slide_filename_sort_key,
- )
+ return sort_slide_paths(directory.glob("*.svg"))
diff --git a/skills/ppt-master/scripts/tests/test_video_subtitles.py b/skills/ppt-master/scripts/tests/test_video_subtitles.py
index 09a40421..7a0728b1 100644
--- a/skills/ppt-master/scripts/tests/test_video_subtitles.py
+++ b/skills/ppt-master/scripts/tests/test_video_subtitles.py
@@ -94,3 +94,19 @@ class FrozenTranscriptTests(unittest.TestCase):
"then iterate.",
],
)
+
+
+class PageSubtitleOrderTests(unittest.TestCase):
+ def test_page_srts_follow_numeric_slide_order(self) -> None:
+ import narration_sync
+
+ with tempfile.TemporaryDirectory() as tmp:
+ for stem in ("slide_9", "slide_10", "slide_100", "slide_11", "total"):
+ Path(tmp, f"{stem}.srt").write_text(
+ "1\n00:00:00,000 --> 00:00:01,000\nx\n", encoding="utf-8"
+ )
+ expected = ["slide_9", "slide_10", "slide_11", "slide_100"]
+ self.assertEqual(
+ [path.stem for path in video_subtitles._page_subtitle_paths(Path(tmp))], expected
+ )
+ self.assertEqual(narration_sync._page_subtitle_names(Path(tmp)), expected)
diff --git a/skills/ppt-master/scripts/video_subtitles.py b/skills/ppt-master/scripts/video_subtitles.py
index 84c4ff1c..c52ccd82 100644
--- a/skills/ppt-master/scripts/video_subtitles.py
+++ b/skills/ppt-master/scripts/video_subtitles.py
@@ -31,6 +31,7 @@ from pathlib import Path
from typing import Any
from console_encoding import configure_utf8_stdio
+from slide_roster import sort_slide_paths
configure_utf8_stdio()
@@ -200,7 +201,7 @@ def _page_subtitle_paths(subtitle_dir: Path) -> list[Path]:
"""Resolve the ordered page-local SRT set without reading notes."""
paths = [
path
- for path in sorted(subtitle_dir.glob("*.srt"))
+ for path in sort_slide_paths(subtitle_dir.glob("*.srt"))
if path.stem != "total"
]
if not paths: