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(notes-to-audio): only real Markdown headings are left out of narration

hugohe306008e8ed723
diff --git a/skills/ppt-master/scripts/notes_to_audio.py b/skills/ppt-master/scripts/notes_to_audio.py
index 81d67c11..f0f56454 100644
--- a/skills/ppt-master/scripts/notes_to_audio.py
+++ b/skills/ppt-master/scripts/notes_to_audio.py
@@ -93,11 +93,15 @@ def _load_tts_env_file() -> None:
))
+# A Markdown heading needs a space after the hashes; "#1 revenue grew" is speech.
+_ATX_HEADING_RE = re.compile(r" {0,3}#{1,6}(?:[ \t]|$)")
+
+
def spoken_text(markdown: str) -> str:
"""Return narration text exactly from notes, except Markdown headings."""
lines: list[str] = []
for raw in markdown.splitlines():
- if raw.lstrip().startswith("#"):
+ if _ATX_HEADING_RE.match(raw):
continue
line = raw.rstrip()
if not line.strip():
diff --git a/skills/ppt-master/scripts/tests/test_edit_native_batch_a.py b/skills/ppt-master/scripts/tests/test_edit_native_batch_a.py
index 442d52c8..446f2709 100644
--- a/skills/ppt-master/scripts/tests/test_edit_native_batch_a.py
+++ b/skills/ppt-master/scripts/tests/test_edit_native_batch_a.py
@@ -392,3 +392,11 @@ class EditNativeBatchATests(unittest.TestCase):
with patch.object(sys, 'argv', ['notes_to_audio.py', '--list-common-voices', '--rate', '-5%']):
with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):
self.assertEqual(notes_to_audio.main(), 0)
+
+
+class SpokenTextHeadingTests(unittest.TestCase):
+ def test_only_real_markdown_headings_are_silent(self) -> None:
+ notes = "# Slide 1\n#1 产品收入增长 20%。\n## 小节\n其次是服务收入。"
+ self.assertEqual(
+ notes_to_audio.spoken_text(notes), "#1 产品收入增长 20%。\n其次是服务收入。"
+ )