slidecast 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidecast-0.1.0/.github/workflows/publish.yml +41 -0
- slidecast-0.1.0/.github/workflows/tests.yml +24 -0
- slidecast-0.1.0/.gitignore +18 -0
- slidecast-0.1.0/LICENSE +21 -0
- slidecast-0.1.0/PKG-INFO +123 -0
- slidecast-0.1.0/README.md +92 -0
- slidecast-0.1.0/pyproject.toml +45 -0
- slidecast-0.1.0/src/slidecast/__init__.py +67 -0
- slidecast-0.1.0/src/slidecast/cli.py +112 -0
- slidecast-0.1.0/src/slidecast/ffmpeg.py +42 -0
- slidecast-0.1.0/src/slidecast/models.py +34 -0
- slidecast-0.1.0/src/slidecast/reel.py +123 -0
- slidecast-0.1.0/src/slidecast/render.py +131 -0
- slidecast-0.1.0/src/slidecast/tts.py +144 -0
- slidecast-0.1.0/src/slidecast/video.py +110 -0
- slidecast-0.1.0/tests/fakes.py +48 -0
- slidecast-0.1.0/tests/test_cli.py +66 -0
- slidecast-0.1.0/tests/test_ffmpeg.py +45 -0
- slidecast-0.1.0/tests/test_models.py +22 -0
- slidecast-0.1.0/tests/test_reel.py +83 -0
- slidecast-0.1.0/tests/test_tts.py +76 -0
- slidecast-0.1.0/tests/test_video.py +58 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI via Trusted Publishing (OIDC) — no API token stored.
|
|
4
|
+
# Configure the publisher once at https://pypi.org/manage/account/publishing/
|
|
5
|
+
# (project: slidecast, workflow: publish.yml, environment: pypi), then push a
|
|
6
|
+
# version tag: git tag v0.1.0 && git push origin v0.1.0
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags: ["v*"]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
- name: Build sdist + wheel
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip build
|
|
23
|
+
python -m build
|
|
24
|
+
- uses: actions/upload-artifact@v4
|
|
25
|
+
with:
|
|
26
|
+
name: dist
|
|
27
|
+
path: dist/
|
|
28
|
+
|
|
29
|
+
publish:
|
|
30
|
+
needs: build
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
environment: pypi
|
|
33
|
+
permissions:
|
|
34
|
+
id-token: write # required for Trusted Publishing
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/download-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: dist
|
|
39
|
+
path: dist/
|
|
40
|
+
- name: Publish to PyPI
|
|
41
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- name: Install
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: pytest -q
|
slidecast-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vinay Vobbilichetty
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
slidecast-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: slidecast
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn a list of HTML slides + narration into a narrated MP4. Headless-browser screenshots, pluggable text-to-speech, ffmpeg stitching. Bring your own slide design and voice.
|
|
5
|
+
Project-URL: Homepage, https://github.com/vinayvobbili/slidecast
|
|
6
|
+
Project-URL: Source, https://github.com/vinayvobbili/slidecast
|
|
7
|
+
Author: Vinay Vobbilichetty
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ffmpeg,kokoro,narration,playwright,screencast,slides,tts,video
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
16
|
+
Classifier: Topic :: Multimedia :: Video
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: requests>=2
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
21
|
+
Requires-Dist: pyyaml>=6; extra == 'dev'
|
|
22
|
+
Provides-Extra: ffmpeg
|
|
23
|
+
Requires-Dist: imageio-ffmpeg>=0.4; extra == 'ffmpeg'
|
|
24
|
+
Provides-Extra: gtts
|
|
25
|
+
Requires-Dist: gtts>=2.3; extra == 'gtts'
|
|
26
|
+
Provides-Extra: playwright
|
|
27
|
+
Requires-Dist: playwright>=1.40; extra == 'playwright'
|
|
28
|
+
Provides-Extra: yaml
|
|
29
|
+
Requires-Dist: pyyaml>=6; extra == 'yaml'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# slidecast
|
|
33
|
+
|
|
34
|
+
Turn a list of HTML slides + narration into a narrated MP4.
|
|
35
|
+
|
|
36
|
+
You bring the slide design — any HTML you like — and the words. slidecast
|
|
37
|
+
screenshots each slide with a headless browser, narrates it with a pluggable
|
|
38
|
+
text-to-speech provider, and stitches the frames into one MP4 with ffmpeg. It
|
|
39
|
+
has no opinion about how your slides look and no hard dependency on a specific
|
|
40
|
+
voice or browser: every piece is swappable.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
pip install slidecast # core (requests only)
|
|
46
|
+
pip install slidecast[playwright] # default renderer (headless Chromium)
|
|
47
|
+
pip install slidecast[gtts] # Google Translate TTS
|
|
48
|
+
pip install slidecast[ffmpeg] # bundled ffmpeg binary (no system install)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
After installing the Playwright extra, fetch the browser once:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
playwright install chromium
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You also need ffmpeg — on `PATH`, via `$SLIDECAST_FFMPEG`, or the `[ffmpeg]`
|
|
58
|
+
extra's bundled binary.
|
|
59
|
+
|
|
60
|
+
## Library
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from slidecast import Reel, KokoroTTS
|
|
64
|
+
|
|
65
|
+
reel = Reel(width=1280, height=720, tts=KokoroTTS(voice="af_heart"))
|
|
66
|
+
reel.add("<!doctype html><h1>Hello</h1>", "Hello, and welcome.")
|
|
67
|
+
reel.add("<!doctype html><h1>Goodbye</h1>", "Thanks for watching.", tail_pad=0.8)
|
|
68
|
+
reel.render("out.mp4", make_poster=True)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
A slide with empty narration becomes a silent hold (`min_duration` seconds). When
|
|
72
|
+
the TTS provider reports a clip duration, the segment is padded to fit the speech
|
|
73
|
+
exactly; when it can't (e.g. MP3), the audio drives the length.
|
|
74
|
+
|
|
75
|
+
## CLI
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
slidecast render reel.yaml -o out.mp4 --poster
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
width: 1280
|
|
83
|
+
height: 720
|
|
84
|
+
fps: 25
|
|
85
|
+
tts:
|
|
86
|
+
provider: kokoro # kokoro | gtts | silent
|
|
87
|
+
url: http://127.0.0.1:8021/v1/audio/speech
|
|
88
|
+
voice: af_heart
|
|
89
|
+
response_format: wav
|
|
90
|
+
slides:
|
|
91
|
+
- html_file: intro.html
|
|
92
|
+
narration: "Before any of this, here's why it matters."
|
|
93
|
+
tail_pad: 0.8
|
|
94
|
+
- html: "<!doctype html><h1>Step one</h1>"
|
|
95
|
+
narration: "" # silent slide
|
|
96
|
+
min_duration: 3
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## The swappable pieces
|
|
100
|
+
|
|
101
|
+
**Text-to-speech** — anything with `synthesize(text, path) -> seconds | None`:
|
|
102
|
+
|
|
103
|
+
- `KokoroTTS` — any OpenAI-compatible `/v1/audio/speech` endpoint (Kokoro,
|
|
104
|
+
OpenAI, LocalAI, …). Defaults to WAV so the clip length is measurable.
|
|
105
|
+
- `GTTSTTS` — Google Translate TTS (`gtts`).
|
|
106
|
+
- `SilentTTS` — a silent track of a fixed length. No dependencies; the default,
|
|
107
|
+
so a reel renders end to end with nothing configured.
|
|
108
|
+
|
|
109
|
+
Pass `phonetic={r"\bSOC\b": "sock"}` to rewrite how tricky tokens are spoken
|
|
110
|
+
without changing the on-screen text.
|
|
111
|
+
|
|
112
|
+
**Renderer** — a context manager exposing `screenshot(html, path, *, width, height)`:
|
|
113
|
+
|
|
114
|
+
- `PlaywrightRenderer` — headless Chromium, launched once per reel (default).
|
|
115
|
+
- `ChromeBinaryRenderer` — drive an existing Chrome/Chromium binary by path.
|
|
116
|
+
|
|
117
|
+
**ffmpeg steps** are exposed directly (`build_segment`, `concat`, `poster`) and
|
|
118
|
+
take an injectable `runner`, so you can compose your own pipeline or test command
|
|
119
|
+
construction without invoking ffmpeg.
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# slidecast
|
|
2
|
+
|
|
3
|
+
Turn a list of HTML slides + narration into a narrated MP4.
|
|
4
|
+
|
|
5
|
+
You bring the slide design — any HTML you like — and the words. slidecast
|
|
6
|
+
screenshots each slide with a headless browser, narrates it with a pluggable
|
|
7
|
+
text-to-speech provider, and stitches the frames into one MP4 with ffmpeg. It
|
|
8
|
+
has no opinion about how your slides look and no hard dependency on a specific
|
|
9
|
+
voice or browser: every piece is swappable.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install slidecast # core (requests only)
|
|
15
|
+
pip install slidecast[playwright] # default renderer (headless Chromium)
|
|
16
|
+
pip install slidecast[gtts] # Google Translate TTS
|
|
17
|
+
pip install slidecast[ffmpeg] # bundled ffmpeg binary (no system install)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
After installing the Playwright extra, fetch the browser once:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
playwright install chromium
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
You also need ffmpeg — on `PATH`, via `$SLIDECAST_FFMPEG`, or the `[ffmpeg]`
|
|
27
|
+
extra's bundled binary.
|
|
28
|
+
|
|
29
|
+
## Library
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from slidecast import Reel, KokoroTTS
|
|
33
|
+
|
|
34
|
+
reel = Reel(width=1280, height=720, tts=KokoroTTS(voice="af_heart"))
|
|
35
|
+
reel.add("<!doctype html><h1>Hello</h1>", "Hello, and welcome.")
|
|
36
|
+
reel.add("<!doctype html><h1>Goodbye</h1>", "Thanks for watching.", tail_pad=0.8)
|
|
37
|
+
reel.render("out.mp4", make_poster=True)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A slide with empty narration becomes a silent hold (`min_duration` seconds). When
|
|
41
|
+
the TTS provider reports a clip duration, the segment is padded to fit the speech
|
|
42
|
+
exactly; when it can't (e.g. MP3), the audio drives the length.
|
|
43
|
+
|
|
44
|
+
## CLI
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
slidecast render reel.yaml -o out.mp4 --poster
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
width: 1280
|
|
52
|
+
height: 720
|
|
53
|
+
fps: 25
|
|
54
|
+
tts:
|
|
55
|
+
provider: kokoro # kokoro | gtts | silent
|
|
56
|
+
url: http://127.0.0.1:8021/v1/audio/speech
|
|
57
|
+
voice: af_heart
|
|
58
|
+
response_format: wav
|
|
59
|
+
slides:
|
|
60
|
+
- html_file: intro.html
|
|
61
|
+
narration: "Before any of this, here's why it matters."
|
|
62
|
+
tail_pad: 0.8
|
|
63
|
+
- html: "<!doctype html><h1>Step one</h1>"
|
|
64
|
+
narration: "" # silent slide
|
|
65
|
+
min_duration: 3
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## The swappable pieces
|
|
69
|
+
|
|
70
|
+
**Text-to-speech** — anything with `synthesize(text, path) -> seconds | None`:
|
|
71
|
+
|
|
72
|
+
- `KokoroTTS` — any OpenAI-compatible `/v1/audio/speech` endpoint (Kokoro,
|
|
73
|
+
OpenAI, LocalAI, …). Defaults to WAV so the clip length is measurable.
|
|
74
|
+
- `GTTSTTS` — Google Translate TTS (`gtts`).
|
|
75
|
+
- `SilentTTS` — a silent track of a fixed length. No dependencies; the default,
|
|
76
|
+
so a reel renders end to end with nothing configured.
|
|
77
|
+
|
|
78
|
+
Pass `phonetic={r"\bSOC\b": "sock"}` to rewrite how tricky tokens are spoken
|
|
79
|
+
without changing the on-screen text.
|
|
80
|
+
|
|
81
|
+
**Renderer** — a context manager exposing `screenshot(html, path, *, width, height)`:
|
|
82
|
+
|
|
83
|
+
- `PlaywrightRenderer` — headless Chromium, launched once per reel (default).
|
|
84
|
+
- `ChromeBinaryRenderer` — drive an existing Chrome/Chromium binary by path.
|
|
85
|
+
|
|
86
|
+
**ffmpeg steps** are exposed directly (`build_segment`, `concat`, `poster`) and
|
|
87
|
+
take an injectable `runner`, so you can compose your own pipeline or test command
|
|
88
|
+
construction without invoking ffmpeg.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "slidecast"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Turn a list of HTML slides + narration into a narrated MP4. Headless-browser screenshots, pluggable text-to-speech, ffmpeg stitching. Bring your own slide design and voice."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Vinay Vobbilichetty" }]
|
|
13
|
+
keywords = ["video", "tts", "slides", "screencast", "ffmpeg", "playwright", "narration", "kokoro"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Multimedia :: Video",
|
|
20
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"requests>=2",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
playwright = ["playwright>=1.40"]
|
|
28
|
+
gtts = ["gtts>=2.3"]
|
|
29
|
+
ffmpeg = ["imageio-ffmpeg>=0.4"]
|
|
30
|
+
yaml = ["pyyaml>=6"]
|
|
31
|
+
dev = ["pytest>=7", "pyyaml>=6"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
slidecast = "slidecast.cli:main"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/vinayvobbili/slidecast"
|
|
38
|
+
Source = "https://github.com/vinayvobbili/slidecast"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/slidecast"]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
pythonpath = ["src"]
|
|
45
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""slidecast — turn a list of HTML slides + narration into a narrated MP4.
|
|
2
|
+
|
|
3
|
+
You bring the slide design (any HTML you like) and the words; slidecast
|
|
4
|
+
screenshots each slide with a headless browser, narrates it with a pluggable
|
|
5
|
+
text-to-speech provider, and stitches the frames into one MP4 with ffmpeg.
|
|
6
|
+
|
|
7
|
+
Quick start
|
|
8
|
+
-----------
|
|
9
|
+
from slidecast import Reel, KokoroTTS
|
|
10
|
+
|
|
11
|
+
reel = Reel(width=1280, height=720, tts=KokoroTTS(voice="af_heart"))
|
|
12
|
+
reel.add("<!doctype html><h1>Hello</h1>", "Hello, and welcome.")
|
|
13
|
+
reel.add("<!doctype html><h1>Bye</h1>", "Thanks for watching.", tail_pad=0.8)
|
|
14
|
+
reel.render("out.mp4", make_poster=True)
|
|
15
|
+
|
|
16
|
+
Pieces (all swappable)
|
|
17
|
+
----------------------
|
|
18
|
+
Model:
|
|
19
|
+
Slide(html, narration="", tail_pad=0.0, min_duration=0.0)
|
|
20
|
+
Reel(width, height, fps, tts=..., renderer=...).add(...).render(out)
|
|
21
|
+
Text-to-speech (``synthesize(text, path) -> seconds | None``):
|
|
22
|
+
KokoroTTS — any OpenAI-compatible /v1/audio/speech endpoint
|
|
23
|
+
GTTSTTS — Google Translate TTS (mp3)
|
|
24
|
+
SilentTTS — silent track, no deps (default)
|
|
25
|
+
Renderers (HTML -> PNG, used as a context manager):
|
|
26
|
+
PlaywrightRenderer — headless Chromium (default)
|
|
27
|
+
ChromeBinaryRenderer — drive an existing Chrome binary by path
|
|
28
|
+
ffmpeg steps (injectable runner, for direct use/testing):
|
|
29
|
+
build_segment(...) / concat(...) / poster(...)
|
|
30
|
+
find_ffmpeg() -> path (PATH, $SLIDECAST_FFMPEG, or imageio-ffmpeg)
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
from .ffmpeg import FFmpegNotFound, find_ffmpeg
|
|
34
|
+
from .models import Slide
|
|
35
|
+
from .reel import Reel
|
|
36
|
+
from .render import ChromeBinaryRenderer, PlaywrightRenderer, Renderer
|
|
37
|
+
from .tts import (
|
|
38
|
+
GTTSTTS,
|
|
39
|
+
KokoroTTS,
|
|
40
|
+
SilentTTS,
|
|
41
|
+
TTSProvider,
|
|
42
|
+
apply_phonetic,
|
|
43
|
+
wav_duration,
|
|
44
|
+
)
|
|
45
|
+
from .video import build_segment, concat, poster
|
|
46
|
+
|
|
47
|
+
__version__ = "0.1.0"
|
|
48
|
+
|
|
49
|
+
__all__ = [
|
|
50
|
+
"Slide",
|
|
51
|
+
"Reel",
|
|
52
|
+
"Renderer",
|
|
53
|
+
"PlaywrightRenderer",
|
|
54
|
+
"ChromeBinaryRenderer",
|
|
55
|
+
"TTSProvider",
|
|
56
|
+
"KokoroTTS",
|
|
57
|
+
"GTTSTTS",
|
|
58
|
+
"SilentTTS",
|
|
59
|
+
"apply_phonetic",
|
|
60
|
+
"wav_duration",
|
|
61
|
+
"build_segment",
|
|
62
|
+
"concat",
|
|
63
|
+
"poster",
|
|
64
|
+
"find_ffmpeg",
|
|
65
|
+
"FFmpegNotFound",
|
|
66
|
+
"__version__",
|
|
67
|
+
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Command line: render a reel from a spec file.
|
|
2
|
+
|
|
3
|
+
slidecast render reel.yaml -o out.mp4 --poster
|
|
4
|
+
|
|
5
|
+
A spec is YAML or JSON::
|
|
6
|
+
|
|
7
|
+
width: 1280
|
|
8
|
+
height: 720
|
|
9
|
+
fps: 25
|
|
10
|
+
tts:
|
|
11
|
+
provider: kokoro # kokoro | gtts | silent
|
|
12
|
+
url: http://127.0.0.1:8021/v1/audio/speech
|
|
13
|
+
voice: af_heart
|
|
14
|
+
response_format: wav
|
|
15
|
+
slides:
|
|
16
|
+
- html_file: intro.html # path (relative to the spec) ...
|
|
17
|
+
narration: "Welcome."
|
|
18
|
+
tail_pad: 0.8
|
|
19
|
+
- html: "<!doctype html>..." # ... or inline HTML
|
|
20
|
+
narration: "" # empty => silent slide
|
|
21
|
+
min_duration: 3
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import json
|
|
28
|
+
import sys
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
from typing import Any, Dict
|
|
31
|
+
|
|
32
|
+
from .reel import Reel
|
|
33
|
+
from .render import ChromeBinaryRenderer
|
|
34
|
+
from .tts import GTTSTTS, KokoroTTS, SilentTTS
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _load_spec(path: Path) -> Dict[str, Any]:
|
|
38
|
+
text = path.read_text()
|
|
39
|
+
if path.suffix in (".yaml", ".yml"):
|
|
40
|
+
try:
|
|
41
|
+
import yaml
|
|
42
|
+
except ImportError: # noqa: BLE001
|
|
43
|
+
raise SystemExit("YAML spec needs PyYAML — `pip install slidecast[yaml]`")
|
|
44
|
+
return yaml.safe_load(text)
|
|
45
|
+
return json.loads(text)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _build_tts(cfg: Dict[str, Any]):
|
|
49
|
+
cfg = dict(cfg or {})
|
|
50
|
+
provider = (cfg.pop("provider", "silent") or "silent").lower()
|
|
51
|
+
if provider == "kokoro":
|
|
52
|
+
return KokoroTTS(**cfg)
|
|
53
|
+
if provider == "gtts":
|
|
54
|
+
return GTTSTTS(**cfg)
|
|
55
|
+
if provider == "silent":
|
|
56
|
+
return SilentTTS(**cfg) if cfg else SilentTTS()
|
|
57
|
+
raise SystemExit(f"Unknown tts provider: {provider!r}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _build_reel(spec: Dict[str, Any], base: Path) -> Reel:
|
|
61
|
+
reel = Reel(
|
|
62
|
+
width=int(spec.get("width", 1920)),
|
|
63
|
+
height=int(spec.get("height", 1080)),
|
|
64
|
+
fps=int(spec.get("fps", 25)),
|
|
65
|
+
tts=_build_tts(spec.get("tts", {})),
|
|
66
|
+
silent_slide_seconds=float(spec.get("silent_slide_seconds", 3.0)),
|
|
67
|
+
)
|
|
68
|
+
chrome = spec.get("chrome")
|
|
69
|
+
if chrome:
|
|
70
|
+
reel.renderer = ChromeBinaryRenderer(chrome=chrome)
|
|
71
|
+
for s in spec.get("slides", []):
|
|
72
|
+
html = s.get("html")
|
|
73
|
+
if not html and s.get("html_file"):
|
|
74
|
+
html = (base / s["html_file"]).read_text()
|
|
75
|
+
if not html:
|
|
76
|
+
raise SystemExit("each slide needs 'html' or 'html_file'")
|
|
77
|
+
reel.add(html, s.get("narration", ""),
|
|
78
|
+
tail_pad=float(s.get("tail_pad", 0.0)),
|
|
79
|
+
min_duration=float(s.get("min_duration", 0.0)))
|
|
80
|
+
return reel
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def main(argv=None) -> int:
|
|
84
|
+
parser = argparse.ArgumentParser(prog="slidecast", description=__doc__,
|
|
85
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
86
|
+
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
87
|
+
r = sub.add_parser("render", help="render a reel spec to an MP4")
|
|
88
|
+
r.add_argument("spec", type=Path, help="YAML or JSON reel spec")
|
|
89
|
+
r.add_argument("-o", "--out", type=Path, required=True, help="output .mp4 path")
|
|
90
|
+
r.add_argument("--poster", action="store_true", help="also write <stem>_poster.jpg")
|
|
91
|
+
r.add_argument("--keep-work", type=Path, default=None,
|
|
92
|
+
help="keep intermediate frames/audio in this directory")
|
|
93
|
+
args = parser.parse_args(argv)
|
|
94
|
+
|
|
95
|
+
if args.cmd == "render":
|
|
96
|
+
spec = _load_spec(args.spec)
|
|
97
|
+
reel = _build_reel(spec, args.spec.resolve().parent)
|
|
98
|
+
n = len(reel.slides)
|
|
99
|
+
|
|
100
|
+
def progress(i, total, slide):
|
|
101
|
+
head = slide.narration[:48].replace("\n", " ") or "(silent)"
|
|
102
|
+
print(f" [{i}/{total}] {head}", file=sys.stderr)
|
|
103
|
+
|
|
104
|
+
out = reel.render(args.out, make_poster=args.poster,
|
|
105
|
+
workdir=args.keep_work, on_progress=progress)
|
|
106
|
+
size_mb = out.stat().st_size / 1e6
|
|
107
|
+
print(f"✓ wrote {out} ({size_mb:.1f} MB) from {n} slides")
|
|
108
|
+
return 0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Locate an ffmpeg binary without forcing a system install.
|
|
2
|
+
|
|
3
|
+
Resolution order:
|
|
4
|
+
1. ``$SLIDECAST_FFMPEG`` — an explicit path, wins over everything.
|
|
5
|
+
2. ``ffmpeg`` on ``$PATH`` — the normal case on a dev box or CI image.
|
|
6
|
+
3. The binary bundled with ``imageio-ffmpeg`` (the ``[ffmpeg]`` extra), so a pure
|
|
7
|
+
``pip install`` with no system package still works.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import shutil
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FFmpegNotFound(RuntimeError):
|
|
17
|
+
"""Raised when no ffmpeg binary can be located by any strategy."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def find_ffmpeg() -> str:
|
|
21
|
+
"""Return a path to an ffmpeg executable, or raise :class:`FFmpegNotFound`."""
|
|
22
|
+
explicit = os.environ.get("SLIDECAST_FFMPEG")
|
|
23
|
+
if explicit:
|
|
24
|
+
if shutil.which(explicit) or os.path.isfile(explicit):
|
|
25
|
+
return explicit
|
|
26
|
+
raise FFmpegNotFound(f"SLIDECAST_FFMPEG={explicit!r} is not an executable")
|
|
27
|
+
|
|
28
|
+
on_path = shutil.which("ffmpeg")
|
|
29
|
+
if on_path:
|
|
30
|
+
return on_path
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
import imageio_ffmpeg # type: ignore
|
|
34
|
+
|
|
35
|
+
return imageio_ffmpeg.get_ffmpeg_exe()
|
|
36
|
+
except Exception: # noqa: BLE001 — any failure here means "not available"
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
raise FFmpegNotFound(
|
|
40
|
+
"ffmpeg not found. Install it on PATH, set $SLIDECAST_FFMPEG, or "
|
|
41
|
+
"`pip install slidecast[ffmpeg]` to use the bundled binary."
|
|
42
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Core data model: a slide is one screen of HTML plus what the voice says over it."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class Slide:
|
|
10
|
+
"""One frame of a reel.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
html: A complete, self-contained HTML document. slidecast does not style
|
|
14
|
+
your slides — it screenshots exactly what you hand it, so the design,
|
|
15
|
+
fonts, and layout are entirely yours.
|
|
16
|
+
narration: What the voice reads over this slide. Empty string => a silent
|
|
17
|
+
slide that holds for ``min_duration`` seconds.
|
|
18
|
+
tail_pad: Seconds of silence appended after the narration so the last word
|
|
19
|
+
is never clipped. Only applied when the narration duration is known.
|
|
20
|
+
min_duration: A floor on the segment length in seconds. For silent slides
|
|
21
|
+
this *is* the duration; for narrated slides the segment is at least
|
|
22
|
+
this long even if the narration is shorter.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
html: str
|
|
26
|
+
narration: str = ""
|
|
27
|
+
tail_pad: float = 0.0
|
|
28
|
+
min_duration: float = 0.0
|
|
29
|
+
|
|
30
|
+
def __post_init__(self) -> None:
|
|
31
|
+
if not isinstance(self.html, str) or not self.html.strip():
|
|
32
|
+
raise ValueError("Slide.html must be a non-empty HTML string")
|
|
33
|
+
if self.tail_pad < 0 or self.min_duration < 0:
|
|
34
|
+
raise ValueError("tail_pad and min_duration must be non-negative")
|