Course Narration as Code: Lint and Budget an E-Learning Voiceover in Python Before It Hits Murf

2026-11-18来源 dev.toEnglish

Disclosure: I'm a Murf AI affiliate. This post links only to my own site, infinityme.dev, and some pages there contain affiliate links to Murf. If you buy through them I may earn a commission at no extra cost to you.

If you build onboarding or compliance courses with an AI voice, generating the narration is the easy bit. The parts that cost time are the ones nobody budgets for: sentences that read fine on a slide but are exhausting to hear, acronyms the voice reads before anyone has explained them, and regenerations that quietly eat the yearly voice-time allowance.

So treat the script like code: one text file, a linter, and a budget printout before anything goes into the studio. Here's the workflow and a ~110-line stdlib Python script for it.

The Murf numbers below come from murf.ai/pricing as summarized on my site (checked October 29, 2026). Prices change, so check the live page before you buy. The script and the speaking-speed assumption are mine.

Why Murf fits slide-based training

Training audio has different requirements than a YouTube voiceover or an audiobook:

  • Slide-and-timeline studio. You write narration in blocks and line them up with slides or video. A script edit means regenerating one block, not re-recording a module.
  • Presenter-style voices. The delivery is clear and steady, closer to a corporate trainer than a dramatic storyteller. That's usually what L&D teams want.
  • Languages. Murf lists 150+ voices in 35+ languages and styles, plus Translation and Dub products for localizing a course.
  • Enterprise options. The pricing page lists an Enterprise tier with on-premise deployment, SLAs and Professional Voice Cloning, and security claims including SOC 2 Type II and ISO 27001.

The workflow that goes with it is simple: write one short narration block per slide, keep sentences short, define acronyms the first time, pick one voice for the whole course, and when a policy or UI changes, edit the block and regenerate instead of re-recording.

Three of those rules are mechanical, so a script can check them.

The script format

One # heading per lesson, one paragraph per slide. Nothing else to learn:

# Lesson 2: Signing in with SSO  You sign in to every internal tool with SSO, so you only need to remember one password and your security key. If the sign-in page asks for a code, open your authenticator app, because we never send codes by text message, and anyone who asks you to read a code aloud over the phone is not from IT. 

Paragraph = slide = one block in the studio. That mapping is the whole point: when something changes, you know exactly which block to regenerate.

The linter + budget script

#!/usr/bin/env python3 """Lint and budget e-learning narration before it goes into a TTS studio. Script format: one "# Lesson title" heading per lesson, one paragraph (blank-line separated) per slide. Plan and API numbers: murf.ai/pricing as summarized on infinityme.dev/blog/murf-ai-for-e-learning/ (checked Oct 29, 2026). Edit the constants if the pricing page changes. """ import re import sys WPM = 150 # my own narration-speed assumption, not a vendor number REGEN_FACTOR = 1.4 # pronunciation passes / retakes MAX_WORDS = 25 # per sentence, a readability habit for training audio STUDIO_MIN_PER_YEAR = {"Creator": 24 * 60, "Business": 96 * 60} STUDIO_USD_PER_YEAR = {"Creator": 228, "Business": 792} API_USD_PER_1K_CHARS = {"Falcon": 0.01, "studio-quality": 0.03} KNOWN_ACRONYMS = {"OK", "PDF", "URL", "FAQ", "AI", "TV", "USA", "UK"} def parse(text): """Return [(lesson_title, [slide_text, ...]), ...].""" lessons, title, slides, buf = [], None, [], [] def flush_slide(): if buf: slides.append(" ".join(buf)) buf.clear() for raw in text.splitlines(): line = raw.strip() if line.startswith("# "): flush_slide() if title is not None: lessons.append((title, slides)) title, slides = line[2:].strip(), [] elif not line: flush_slide() else: buf.append(line) flush_slide() if title is not None: lessons.append((title, slides)) return lessons def lint(lessons): """Long sentences and acronyms used before they are expanded.""" issues, seen = [], set(KNOWN_ACRONYMS) for title, slides in lessons: for n, slide in enumerate(slides, 1): where = f"{title} / slide {n}" for sentence in re.split(r"(?<=[.!?])\s+", slide): words = len(sentence.split()) if words > MAX_WORDS: issues.append(f"{where}: {words}-word sentence") for m in re.finditer(r"\b([A-Z]{2,6})s?\b", slide): acro = m.group(1) if acro in seen: continue seen.add(acro) before, after = slide[:m.start()], slide[m.end():] defined = before.endswith("(") or after.lstrip().startswith("(") if not defined: issues.append(f"{where}: '{acro}' not expanded on first use") return issues def budget(lessons): words = sum(len(s.split()) for _, slides in lessons for s in slides) chars = sum(len(s) for _, slides in lessons for s in slides) finished_min = words / WPM generated_min = finished_min * REGEN_FACTOR out = { "lessons": len(lessons), "slides": sum(len(s) for _, s in lessons), "words": words, "finished_min": round(finished_min, 1), "generated_min": round(generated_min, 1), "studio_share": {p: round(100 * generated_min / m, 1) for p, m in STUDIO_MIN_PER_YEAR.items()}, "api_usd": {k: round(chars * REGEN_FACTOR / 1000 * v, 2) for k, v in API_USD_PER_1K_CHARS.items()}, } return out def main(path): with open(path, encoding="utf-8") as f: lessons = parse(f.read()) if not lessons: sys.exit("no '# Lesson' headings found") b = budget(lessons) print(f"{b['lessons']} lessons, {b['slides']} slides, {b['words']:,} words") print(f"~{b['finished_min']} min finished audio at {WPM} wpm, " f"~{b['generated_min']} min generated (x{REGEN_FACTOR})") for plan, pct in b["studio_share"].items(): print(f" Studio {plan}: {pct}% of yearly voice time " f"(${STUDIO_USD_PER_YEAR[plan]}/yr)") for tier, usd in b["api_usd"].items(): print(f" API {tier}: ~${usd}") issues = lint(lessons) for i in issues: print("LINT", i) return 1 if issues else 0 if __name__ == "__main__": sys.exit(main(sys.argv[1])) 

Running it on a three-lesson sample course:

$ python3 narration_budget.py course.md 3 lessons, 5 slides, 118 words ~0.8 min finished audio at 150 wpm, ~1.1 min generated (x1.4) Studio Creator: 0.1% of yearly voice time ($228/yr) Studio Business: 0.0% of yearly voice time ($792/yr) API Falcon: ~$0.01 API studio-quality: ~$0.03 LINT Lesson 2: Signing in with SSO / slide 1: 'SSO' not expanded on first use LINT Lesson 2: Signing in with SSO / slide 2: 37-word sentence LINT Lesson 2: Signing in with SSO / slide 2: 'IT' not expanded on first use $ echo $? 1 

The exit code is non-zero when there are lint issues, so you can drop it into a pre-commit hook or CI job if your course scripts live in a repo. Notice that Lesson 3 defines "Single Sign-On (SSO)", but too late: the learner already heard "SSO" in Lesson 2. That's exactly the kind of mistake you don't catch by reading slides out of order.

The linter accepts both Single Sign-On (SSO) and SOC (Security Operations Center) as a definition. It's a heuristic: add your company's everyday acronyms to KNOWN_ACRONYMS so it doesn't nag about them.

Where the budget numbers come from

The budget part reproduces the worked example on the source page: assume each lesson averages 90 seconds of narration after edits, so 40 lessons are 60 minutes of finished audio. Add a 1.4x regeneration factor for pronunciation passes and you're at about 84 minutes of generated audio.

Feeding the function 40 dummy lessons of 225 words each (90 seconds at my 150 wpm assumption) gives the same answer:

>>> slide = " ".join(["word"] * 225) >>> nb.budget([(f"Lesson {i}", [slide]) for i in range(1, 41)]) {'lessons': 40, 'slides': 40, 'words': 9000, 'finished_min': 60.0, 'generated_min': 84.0, 'studio_share': {'Creator': 5.8, 'Business': 1.5}, 'api_usd': {'Falcon': 0.63, 'studio-quality': 1.89}} 

(The API figures here are low because "word" is a short word. On real text, run it on your actual script, since the API is priced per character.)

The constants map to Murf's pricing page as of October 29, 2026:

Item Listed on murf.ai/pricing
Studio Creator (yearly billing) ~$19/mo, $228/year, 24 hours of voice time per year
Studio Business (yearly billing) ~$66/mo, $792/year, 96 hours of voice time per year
API text to speech, Falcon (real-time) $0.01 per 1,000 characters
API text to speech, studio quality $0.03 per 1,000 characters
API Translation $0.02 per 1,000 characters
API free trial $10 of free credit; purchased credit never expires

Two things worth knowing before you pick:

  • Regenerations count toward voice time. That's why the script budgets generated minutes, not finished minutes. If your product names are hard to pronounce, raise REGEN_FACTOR.
  • Effective cost per minute depends on how much you use. Creator works out to about $228 ÷ 1,440 minutes ≈ $0.16 per generated minute only if you use the full allowance. One 84-minute course is about 6% of it, so the Studio seat makes sense when you have a catalog or frequent updates. If you're generating programmatically, compare the API's per-character pricing against a seat.

Localizing without breaking the workflow

The slide-per-paragraph format also helps when you translate:

  1. Freeze the source script and timing first.
  2. Use the Translation or Dub products listed on the pricing page for target languages, and verify voice availability for each locale before you promise ship dates.
  3. Have a native reviewer fix product names and legal phrases. AI will miss some.
  4. Keep one voice persona per language track so the course feels consistent.

Run the linter on each translated file too. Long sentences tend to get longer in translation.

Honest limits

  • Murf's strength is clarity, not drama. Storytelling-heavy courses or character voices may suit a more expressive engine.
  • Cloning your own voice is listed under Enterprise on the pricing page, so a solo creator on a Creator or Business seat can't count on it.
  • Free has no downloads and no commercial rights. Creator includes commercial rights; Business adds a Business License. Check the license terms against where the course will be distributed (internal LMS vs public ads).
  • Review the pronunciation of product names and jargon before publishing. No linter catches a mispronounced brand name.

The full guide, with the per-slide workflow, the plan table and an FAQ on translation, is here: Murf AI for E-Learning and Training Videos (2026).

原文:https://www.a8q9.cn/en/article/course-narration-as-code-lint-and-budget-an-e-learning-voiceover-in-python-befor-d7df08.html

相关文章