slidecast
Turn a list of HTML slides and recorded clips, plus narration, into a narrated MP4.
You bring the slide design — any HTML you like — and the words. slidecast screenshots each slide with a headless browser, narrates it with a pluggable text-to-speech provider, and stitches the frames into one MP4 with ffmpeg. It has no opinion about how your slides look and no hard dependency on a specific voice or browser: every piece is swappable.
Install
pip install slidecast # core (requests only)
pip install slidecast[playwright] # default renderer (headless Chromium)
pip install slidecast[gtts] # Google Translate TTS
pip install slidecast[ffmpeg] # bundled ffmpeg binary (no system install)
pip install 'slidecast[mlx]' # Kokoro in-process on Apple Silicon (no TTS server)
pip install 'slidecast[compose]' # synthesize a music bed and stings (numpy)
After installing the Playwright extra, fetch the browser once:
playwright install chromium
You also need ffmpeg — on PATH, via $SLIDECAST_FFMPEG, or the [ffmpeg]
extra's bundled binary.
Library
from slidecast import Reel, KokoroTTS
reel = Reel(width=1280, height=720, tts=KokoroTTS(voice="af_heart"))
reel.add("<!doctype html><h1>Hello</h1>", "Hello, and welcome.")
reel.add("<!doctype html><h1>Goodbye</h1>", "Thanks for watching.", tail_pad=0.8)
reel.render("out.mp4", make_poster=True)
A slide with empty narration becomes a silent hold (min_duration seconds). When
the TTS provider reports a clip duration, the segment is padded to fit the speech
exactly; when it can't (e.g. MP3), the audio drives the length.
Recorded clips
Mix screen recordings in with the slides. A clip plays through; if its narration runs longer, the last frame holds until the voice finishes. It's letterboxed to the reel's size, never stretched, and its own audio is replaced by the narration.
reel.add("<!doctype html><h1>The demo</h1>", "Here's how it works.")
reel.add_clip("scan.webm", "Click Scan, and every question gets a cited draft.")
reel.add_clip("fill.webm", "Then fill the form.", tail_pad=0.6)
Record the clips any way you like: Playwright's record_video_dir, a
screenshot sequence encoded with ffmpeg, or a screen recorder.
Recording a web page like a person
slidecast.recorder.Recorder drives a Playwright page for a screen recording. A cursor glides to each target before it
acts, every click shows a ripple, a drag draws a dotted path, and scrolling lands the target below any sticky header.
The overlay is injected into the page, so it is in the recording and nowhere else.
from playwright.sync_api import sync_playwright
from slidecast.recorder import Recorder
with sync_playwright() as p:
browser = p.chromium.launch()
with Recorder.open(browser, "http://127.0.0.1:8765/#settings", "settings.mp4") as rec:
rec.click("text=Save settings") # glide, ripple, click
rec.type("#name", "Jordan")
rec.drag("#card", "#done") # the path follows the cursor
rec.hold_until(8.0) # a scene as long as its narration
reel.add_clip("settings.mp4", "Save your settings.")
After every action the recorder runs the framing check, find_clipped(page), and raises ClippedError when the frame's
edge slices a visible element in two: any position: sticky or fixed element (a tab bar cut off after a scroll), a
button, input, heading or tab. Use scroll_to(target) rather than a raw scroll. Recorder(page, shots=DIR) saves a
screenshot after each action instead of recording, to check a scene's framing cheaply; check=False opts out.
Animated slides
Write a page with CSS animations and add_animated turns it into a clip. Every animation is paused and stepped
frame by frame (the Web Animations API), so the result is the same on every run. If the narration is longer than
seconds, the last frame holds.
reel.add_animated("""<!doctype html><style>
body { background: #0b1020; margin: 0 }
.bar { height: 40px; width: 0; background: #7c5cff; animation: grow 3s ease-out forwards }
@keyframes grow { to { width: 100% } }
</style><div class="bar"></div>""", "Watch the bar fill.", seconds=3)
Start animations at page load, with CSS (keyframes, animation-delay). Anything driven by script timers won't
move. It needs a renderer with an animate method; PlaywrightRenderer has one.
Music and stings
Lay a music bed under the narration, and bookend the reel with short stings:
from slidecast import Music, Reel, Sting
reel = Reel(tts=..., music=Music("bed.mp3", volume=0.22, duck=True),
intro="intro.wav", outro=Sting("outro.wav", volume=0.7), loudness=-16)
The bed loops to the reel's length and fades in and out. volume is its level
in the pauses. While someone speaks or a sting plays it dips duck_db lower
(12 dB by default): the reel knows when each line starts and ends, so the bed
eases down just before the line and swells back in the pause after it, with no
pumping between words. The intro plays
from the start, and the first narration waits for it (lead_in, which defaults
to the intro's length). The outro is timed to end on the last frame. The
narration keeps its level. loudness (LUFS) normalizes the final audio, and is
off by default. Only the audio is re-encoded; the video stream is copied, unless
render(fade_in=..., end_hold=...) asks for a re-encoded master anyway.
Composing a bed and stings
No music to hand? slidecast can write its own, synthesized from scratch with numpy, so there is nothing to license. The bed is a soft lo-fi loop (Fmaj7 – G6 – Em7 – Am7 at 84 BPM: pad, electric-piano arpeggio, bass, a soft kick and shaker). The intro is a rising swoosh that lands on a bell chord at 1.0 s; the outro is a run of falling bells that resolves on Cmaj7.
slidecast compose -o audio/ --length 95 --bpm 84 --seed 7
That writes music_bed.wav, intro_sting.wav (5.1 s) and outro_sting.wav
(5.0 s), 16-bit stereo. The same seed gives the same audio. The bed fades out
over its last 3 s, so make it a few seconds longer than the reel, or the fade
dips each time it loops.
Or let the reel compose them as it renders. It writes them into its work directory and makes the bed outlast the reel:
reel = Reel(tts=..., music="compose", intro="compose", outro="compose", lead_in=2.0)
reel = Reel(tts=..., music=Music("compose", volume=0.18)) # a composed bed, your settings
reel = Reel(tts=..., music=Music("compose", style="upbeat"), intro="compose", outro="compose")
style="upbeat" (or slidecast compose --style upbeat) is a 124 BPM dance bed: four-on-the-floor kick,
claps on 2 and 4, 16th hi-hats, an off-beat bass, bright chord stabs and a short lead motif, with a build
and crash every 8 bars. Its stings are punchier to match. The 1-4 kHz speech band is carved out of the mix,
and the bed ducks 18 dB under the voice by default (12 for the calm style).
In Python, music_bed(length, bpm, seed), intro_sting(seed) and
outro_sting() return the audio as numpy arrays, and write_wav(path, audio)
saves one. The intro's ring-out runs to 5.1 s; a lead_in of about 2 s lets
the voice start over its tail instead of waiting for silence.
Story shape
A pattern, not a template: use the parts that fit. A reel that opens with title_card gets the rest by default.
- Title card, briefly.
reel.title_card(html, seconds=3)shows the opening card silent for about 3 s (only the intro sting plays), then the story starts. Setlead_in=0so nothing waits on the sting. - Problem before solution.
reel.problem(html, narration, seconds=...)runs an animated scene (it isadd_animated) that shows the pain before the payoff: the same form retyped forty times, a queue growing. - Tagline at the turn.
reel.tagline("Your paperwork shouldn't be a full-time job.")is spoken and shown big where the problem turns into the solution. Then the walkthrough. - End on the title card, never black. The reel closes on a reprise of the title card with the tagline under
it, held
closing_seconds(4 s), with no fade to black. Opt out withReel(close_on_title=False).Reel(closing_qr="https://example.com/app", closing_qr_label="Get it here")adds a QR code of the link, bottom-right on a white tile with a label under it, so a viewer can scan it from the screen. - Accent text is a gradient, never pure white.
Reel(theme=Theme(accent_gradient=...)), lavender to pink by default, paints the tagline;theme.accent("text")andtheme.accent_css()do the same in your own slides. Pure white is for body text. - A check at the end of the build.
renderrunscheck_endson a reel with a title card and raisesReelCheckErrorif the last 0.5 s has black frames or the first card runs over 4 s before any narration (verify=Falseskips it,verify=Trueforces it). The same check isslidecast check out.mp4.
from slidecast import Reel, Theme
reel = Reel(width=1280, height=720, tts=..., intro="compose", lead_in=0, theme=Theme())
reel.title_card(TITLE_HTML) # silent, 3 s
reel.problem(PROBLEM_HTML, "Forty forms, every one asking the same things.", seconds=12)
reel.tagline("Your paperwork shouldn't be a full-time job.") # the turn
reel.add(PAYOFF_HTML, "Initech's form, filled in seconds.")
reel.render("out.mp4") # closes on the title card, checked
CLI
slidecast render reel.yaml -o out.mp4 --poster
slidecast check out.mp4 [--min-gap 0.6] # exit 1: black in the last 0.5 s, a first card over 4 s before any voice,
# or (with --min-gap) a slide change that cuts the voice off
slidecast youtube out.mp4 [-o out-youtube.mp4] # an upload copy at 2x size, 30 fps, CRF 16
YouTube re-encodes every upload, and a 1280x800 file lands in its 720p tier, which blurs small text. A 2x copy
(2560x1600) lands in 1440p, which gets VP9 and several times the bitrate. Reel.render(..., youtube=True) writes
the same <name>-youtube.mp4 beside the reel. It scales the finished video with Lanczos, so it can't add detail
the reel doesn't have; for the sharpest text, design the slides at 2x too.
Line breaks
Every slide gets a base stylesheet ahead of its own CSS: text-wrap: pretty on paragraphs and list items (no
paragraph ends on a lone word) and balance on headings. A title card, the tagline and the closing reprise put each
sentence of a plain-text <p> on its own line (slidecast.typeset.sentences_on_lines does the same for any card).
With the Playwright renderer, render warns about any text block whose last line is a single word, as laid out.
width: 1280
height: 720
fps: 25
tts:
provider: kokoro # kokoro | mlx | gtts | say | silent
url: http://127.0.0.1:8021/v1/audio/speech
voice: af_heart
response_format: wav
music: bed.mp3 # or compose, or {file, volume: 0.22, fade_in: 1.0, fade_out: 2.0, duck: true, duck_db: 12}
intro: intro.wav # or compose, or {file, volume: 0.75}; the first narration waits for it
outro: {file: outro.wav, volume: 0.7} # ends with the reel
lead_in: 1.8 # optional: silence before the first narration (default: intro length)
loudness: -16 # optional: LUFS target for the final audio
slides:
- video: demo.mp4 # a recorded clip, relative to the spec
narration: "Watch it run."
- html_file: intro.html
narration: "Before any of this, here's why it matters."
tail_pad: 0.8
- html: "<!doctype html><h1>Step one</h1>"
narration: "" # silent slide
min_duration: 3
Rebuilding fast
Narration and built segments are cached, so after editing two slides of a long reel only those two are spoken and encoded again. Entries are keyed on the text, voice and settings, and on the slide's screenshot, so a change to anything that shows or sounds different is picked up.
The cache lives in ~/.cache/slidecast ($XDG_CACHE_HOME/slidecast if set), or wherever SLIDECAST_CACHE
points, and is pruned to 2 GB, least recently used first, at the start and the end of every render. Set SLIDECAST_CACHE_MAX to change that cap: a byte
count, or a whole number with a G or M suffix, such as SLIDECAST_CACHE_MAX=12G or SLIDECAST_CACHE_MAX=800M.
A value it can't read stops the render with an error. Raise the cap when several long videos should keep their
clips, so editing one card doesn't re-render all of it. To turn it off, set SLIDECAST_CACHE=off, pass
--no-cache to slidecast render, or call reel.render(out, cache=False). --cache DIR / cache=DIR use
another directory. A custom TTS provider is keyed on its public attributes; give it a cache_key if its output
depends on anything else.
The swappable pieces
Text-to-speech — anything with synthesize(text, path) -> seconds | None:
KokoroTTS— any OpenAI-compatible/v1/audio/speechendpoint (Kokoro, OpenAI, LocalAI, …). Defaults to WAV so the clip length is measurable.MLXKokoroTTS— Kokoro running in-process on Apple Silicon viamlx-audio, so no server is needed:MLXKokoroTTS(voice="af_heart", speed=1.0, lang_code="a"), ortts: {provider: mlx, voice: af_heart}in YAML. The model (mlx-community/Kokoro-82M-bf16) downloads on first use and loads once per reel. If phonemizing fails with an espeak path under/Users/runner/...(a path baked into theespeakng-loaderwheel), runbrew install espeak-ng. slidecast then pointsESPEAK_DATA_PATHandPHONEMIZER_ESPEAK_LIBRARYat Homebrew's copy itself, unless you've set them.GTTSTTS— Google Translate TTS (gtts).MacSayTTS— macOS's built-insay: offline, no dependencies, WAV. Premium voices (e.g. "Ava (Premium)") are a free download under System Settings › Accessibility › Spoken Content.SilentTTS— a silent track of a fixed length. No dependencies; the default, so a reel renders end to end with nothing configured.
Pass phonetic={r"\bSOC\b": "sock"} to rewrite how tricky tokens are spoken
without changing the on-screen text.
Plural acronyms: Kokoro says "PDFs", "APIs", "W-2s" and "1099s" right when they are written as one word, but a
spelled-out plural ("P D Fs", "P D F s", "A P Is") comes out as the letters and then the letter S ("P D F S").
KokoroTTS and MLXKokoroTTS therefore join a spelled-out plural back into its word before speaking it
(normalize_acronym_plurals("P D Fs") == "PDFs"), also when your own phonetic rule produced the spelling. The
captions keep what you wrote. Turn it off with acronym_plurals=False.
For a word the voice still gets wrong (it says "TINs" as the word "tins"), give a pronunciation dictionary:
pronunciations={"TINs": "tee eye ens"}, or under tts: in YAML. Keys are whole words, matched exactly (case
included), and the value is spoken as it is. It runs after the phonetic rules and the plural fix, and before the
engine's own fixes, so it has the last word on a plural.
Kokoro can't tell "read" (reed) from "read" (red), so slidecast picks from the words around it: red after
have/has/had/'ve/'d/was/were/been/is/are/be/being/get/got/already/just/never/well/widely/recently/once, or
with yesterday/ago/earlier/"last week" a few words after it (also re-read, proofread, misread); reed after
to/will/can/do/I/you/we/they and for an imperative like "Read them out loud". To force a reading, write
{read:past} or {read:present} in the narration ({Read:past}, {re-read:present}, {proofread:past} and
{misread:past} work too); the Kokoro engine turns it into the right sound and keeps the word.
Renderer — a context manager exposing screenshot(html, path, *, width, height):
PlaywrightRenderer— headless Chromium, launched once per reel (default).ChromeBinaryRenderer— drive an existing Chrome/Chromium binary by path.
Music — Music(file, volume, fade_in, fade_out, duck, duck_db) for the bed, and
Sting(file, volume) for the intro and outro. A plain path works for either
and uses the defaults; "compose" synthesizes one.
ffmpeg steps are exposed directly (build_segment, build_clip_segment,
concat, master, mix_music, poster) and
take an injectable runner, so you can compose your own pipeline or test command
construction without invoking ffmpeg.
Releasing
A v* tag publishes to PyPI. scripts/release.py 0.4.1 -m "what's in it" bumps the version in
pyproject.toml and slidecast/__init__.py, runs the tests, commits, tags, pushes, and waits until PyPI
has it (--dry-run shows the bump first).
License
MIT
Metadata
Release files for slidecast 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slidecast-0.5.1.tar.gz | 107.8 kB | With provenance | Details for slidecast-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slidecast-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for slidecast-0.5.1-py3-none-any.whl |
Total release size: 180.1 kB
Release files / slidecast-0.5.1.tar.gz
| Download URL | slidecast-0.5.1.tar.gz |
|---|---|
| Size | 107.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39ae4f0590f4d1db10d59b29d7594c883b268c4fd92b958f718d46d1a926c8da
|
|
BLAKE2b-256 checksum How to use checksums |
d9f3bce57526c22669597a9d4fcecb7d21e4910529e26c1a24b0ef173b0ce94b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / slidecast-0.5.1-py3-none-any.whl
| Download URL | slidecast-0.5.1-py3-none-any.whl |
|---|---|
| Size | 72.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c470fe965376817c63894e695c8bbd7323e33db00131663de83993842b93d248
|
|
BLAKE2b-256 checksum How to use checksums |
a44fe78ed98d4aaddb7d79518c5169dcd3e9016b701a598d8380e9edced47c5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for slidecast 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for slidecast-0.5.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.