subreel 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.
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-10-10
11
+
12
+ ### Added
13
+
14
+ - `subreel tts` — synthesize speech with edge-tts and capture per-word timings
15
+ from `WordBoundary` events (zero ASR error), written as a documented
16
+ `words.json` file.
17
+ - `subreel render` — render word-by-word karaoke subtitles over a green or
18
+ transparent canvas in three flavours:
19
+ - `green`: opaque H.264 MP4 on a `0x00B140` chroma-key background,
20
+ - `webm`: transparent VP9 (`yuva420p`) WebM,
21
+ - `mov`: transparent ProRes 4444 (`yuva444p10le`) MOV.
22
+ - `--asr` mode — derive word-level timings for any audio with faster-whisper,
23
+ with an on-disk cache and a Hugging Face mirror hint on download failure.
24
+ - Line-breaking with CJK-aware width budgeting, punctuation-priority wrapping
25
+ and a configurable karaoke hold.
26
+ - ASS generation with a correct light-on-key colour model, `\kf` per-word
27
+ sweep, optional fade and selectable font/size/alignment/colours.
28
+ - Clear, actionable errors: ffmpeg/ffprobe discovery with per-platform install
29
+ commands, and exit code `2` for every recoverable failure.
30
+ - Fully offline test suite (76+ tests) covering line-breaking, ASS output,
31
+ words.json validation, the CLI surface and mocked TTS/ASR/ffmpeg paths.
32
+ - GitHub Actions CI (`.github/workflows/ci.yml`): pytest on Python 3.9–3.13,
33
+ byte-compile check, plus a packaging job that builds the sdist + wheel,
34
+ runs `twine check --strict` and smoke-installs the wheel.
35
+ - Release workflow (`.github/workflows/release.yml`): pushing a `v*` tag
36
+ publishes to PyPI via OIDC trusted publishing (no stored token) and opens a
37
+ GitHub Release with the artefacts attached.
38
+ - `docs/releasing.md` — one-time PyPI trusted-publisher setup and the release
39
+ checklist.
40
+
41
+ ### Changed
42
+
43
+ - Relicensed from MIT to Apache-2.0.
44
+ - Packaging metadata modernised to PEP 639: `license = "Apache-2.0"` and
45
+ `license-files` replace the legacy table form; the build backend now requires
46
+ `setuptools>=77`.
47
+
48
+ ### Fixed
49
+
50
+ - Punctuation re-attachment keeps its alignment when a spoken token contains an
51
+ intra-word `.` or `-` (`4.1`, `e-mail`); previously such a token made the
52
+ alignment check fail and silently disabled punctuation-aware line breaking
53
+ for the whole script.
54
+
55
+ [Unreleased]: https://github.com/paxoscn/subreel/compare/v0.1.0...HEAD
56
+ [0.1.0]: https://github.com/paxoscn/subreel/releases/tag/v0.1.0
subreel-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 paxoscn
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ # Files that belong in the sdist on top of what setuptools auto-includes
2
+ # (README.md, LICENSE, pyproject.toml and the package sources).
3
+ include CHANGELOG.md
4
+ include README.zh-CN.md
5
+ recursive-include docs *.md
6
+ recursive-include tests *.py
7
+ exclude .github
subreel-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,370 @@
1
+ Metadata-Version: 2.4
2
+ Name: subreel
3
+ Version: 0.1.0
4
+ Summary: Turn speech audio into subtitle reels: green-screen H.264, transparent WebM/ProRes, with word-by-word karaoke highlight.
5
+ Author: paxoscn
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/paxoscn/subreel
8
+ Project-URL: Repository, https://github.com/paxoscn/subreel
9
+ Project-URL: Issues, https://github.com/paxoscn/subreel/issues
10
+ Project-URL: Changelog, https://github.com/paxoscn/subreel/blob/main/CHANGELOG.md
11
+ Keywords: subtitles,captions,karaoke,tts,asr,whisper,ffmpeg,ass,green-screen,chroma-key,video,cli
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: End Users/Desktop
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
23
+ Classifier: Topic :: Multimedia :: Video :: Non-Linear Editor
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Provides-Extra: tts
28
+ Requires-Dist: edge-tts>=6; extra == "tts"
29
+ Provides-Extra: asr
30
+ Requires-Dist: faster-whisper>=1.0; extra == "asr"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # subreel
36
+
37
+ **Turn speech audio into subtitle reels: green-screen H.264, transparent
38
+ WebM/ProRes, with word-by-word karaoke highlight.**
39
+
40
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
41
+ [![CI](https://github.com/paxoscn/subreel/actions/workflows/ci.yml/badge.svg)](https://github.com/paxoscn/subreel/actions/workflows/ci.yml)
42
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/)
43
+ <!-- Uncomment once the first release is on PyPI (see docs/releasing.md):
44
+ [![PyPI](https://img.shields.io/pypi/v/subreel.svg)](https://pypi.org/project/subreel/)
45
+ -->
46
+ [![No runtime deps](https://img.shields.io/badge/runtime%20deps-none-success.svg)](#installation)
47
+
48
+ subreel is a small, dependency-free CLI that turns a voice-over into a subtitle
49
+ clip you can drop straight onto a video timeline. It renders the subtitles onto
50
+ a chroma-key green background (for editors that key out green) or onto a
51
+ transparent canvas (for editors that take alpha directly), and it lights up each
52
+ word as it is spoken — classic karaoke style.
53
+
54
+ Two ways to get the timeline:
55
+
56
+ 1. **`subreel tts` — the accurate path.** Synthesize the speech with
57
+ [edge-tts](https://github.com/rany2/edge-tts) and capture the per-word
58
+ timestamps straight from the synthesis events. The subtitle timing is exact,
59
+ because it comes from the same engine that produced the audio — **zero ASR
60
+ error**.
61
+ 2. **`subreel render --asr` — the any-audio path.** Run
62
+ [faster-whisper](https://github.com/SYSTRAN/faster-whisper) on any existing
63
+ audio file to get word-level timestamps.
64
+
65
+ ---
66
+
67
+ ## Features
68
+
69
+ - **Three output flavours** from one command:
70
+ - **Green-screen MP4** — H.264 / `yuv420p`, ready for chroma key in 剪映, Premiere, DaVinci, Final Cut.
71
+ - **Transparent WebM** — VP9 with an alpha channel (`yuva420p`).
72
+ - **Transparent ProRes 4444 MOV** — with alpha (`yuva444p10le`), for Premiere / Final Cut / DaVinci.
73
+ - **Per-word karaoke highlight** — each word is wrapped in an ASS `\kf` sweep,
74
+ so the current and already-sung words are drawn in the highlight colour.
75
+ - **edge-tts precise timelines** — word timings captured from `WordBoundary`
76
+ events, no speech recognition involved.
77
+ - **Whisper ASR fallback** — word-level recognition for audio you did not
78
+ synthesize, with caching.
79
+ - **Zero mandatory Python dependencies** — ffmpeg is the only system
80
+ requirement; `edge-tts` and `faster-whisper` are opt-in extras.
81
+ - **A documented, portable timeline format** — the [`words.json`](#wordsjson-timing-format) file.
82
+
83
+ <!-- Demo — uncomment and add the files when they are recorded.
84
+ <p align="center">
85
+ <img src="docs/demo-green.gif" alt="Green-screen karaoke subtitles" width="640">
86
+ <img src="docs/demo-alpha.gif" alt="Transparent karaoke subtitles" width="640">
87
+ </p>
88
+ -->
89
+
90
+ ---
91
+
92
+ ## Installation
93
+
94
+ ### 1. ffmpeg (required)
95
+
96
+ subreel shells out to `ffmpeg` / `ffprobe` and checks for them at startup.
97
+
98
+ | Platform | Command |
99
+ | --------------- | ------------------------------------------ |
100
+ | Ubuntu / Debian | `sudo apt install ffmpeg` |
101
+ | macOS | `brew install ffmpeg` |
102
+ | Windows | `winget install Gyan.FFmpeg` |
103
+ | Conda | `conda install -c conda-forge ffmpeg` |
104
+
105
+ For CJK subtitles, install a CJK font as well (e.g. `fonts-noto-cjk` on Debian
106
+ / Ubuntu); the default style uses `Noto Sans CJK SC`.
107
+
108
+ ### 2. subreel
109
+
110
+ Packaging is CI-verified: `pip install subreel` works as soon as the first
111
+ release lands on PyPI (see [`docs/releasing.md`](docs/releasing.md)). Until then
112
+ install straight from GitHub:
113
+
114
+ ```bash
115
+ pip install "git+https://github.com/paxoscn/subreel.git"
116
+ ```
117
+
118
+ With the optional features:
119
+
120
+ ```bash
121
+ # edge-tts synthesis (subreel tts)
122
+ pip install "git+https://github.com/paxoscn/subreel.git#egg=subreel[tts]"
123
+
124
+ # faster-whisper ASR (subreel render --asr)
125
+ pip install "git+https://github.com/paxoscn/subreel.git#egg=subreel[asr]"
126
+
127
+ # both
128
+ pip install "git+https://github.com/paxoscn/subreel.git#egg=subreel[tts,asr]"
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Quick start
134
+
135
+ ### A. Synthesize *and* render (most accurate)
136
+
137
+ ```bash
138
+ # 1. make the voice-over plus its exact word timings
139
+ subreel tts \
140
+ --text script.txt \
141
+ --voice zh-CN-XiaoxiaoNeural \
142
+ --rate +15% \
143
+ --out voice.mp3
144
+ # -> voice.mp3 and voice.words.json
145
+
146
+ # 2. render all three flavours
147
+ subreel render voice.mp3 \
148
+ --timings voice.words.json \
149
+ --formats green,webm,mov \
150
+ --out-dir out
151
+ # -> out/subs-green.mp4, out/subs-alpha.webm, out/subs-alpha.mov
152
+ ```
153
+
154
+ ### B. You already have audio — let Whisper transcribe it
155
+
156
+ ```bash
157
+ subreel render narration.m4a --asr --asr-model small --formats green,webm
158
+ ```
159
+
160
+ The recognised timings are cached to `out/narration.words.json` and reused on
161
+ the next run (pass `--force-asr` to re-run).
162
+
163
+ ### C. You already have timings
164
+
165
+ Any tool that emits the [`words.json`](#wordsjson-timing-format) format can
166
+ drive subreel:
167
+
168
+ ```bash
169
+ subreel render voice.mp3 --timings my-alignment.json --formats mov
170
+ ```
171
+
172
+ ### Decoding the transparent WebM from the command line
173
+
174
+ `subs-alpha.webm` carries its alpha channel as a VP9 *BlockAdditional* layer
175
+ (`alpha_mode=1`). NLEs and browsers handle this natively, but ffmpeg's
176
+ **native** `vp9` decoder silently drops that layer, so a plain
177
+ `ffmpeg -i subs-alpha.webm frame.png` yields an opaque black frame. Decode
178
+ with libvpx instead:
179
+
180
+ ```bash
181
+ ffmpeg -c:v libvpx-vp9 -i subs-alpha.webm -frames:v 1 frame.png # RGBA, alpha intact
182
+ ```
183
+
184
+ The ProRes `.mov` needs no such flag — every ffmpeg/ProRes toolchain reads its
185
+ alpha directly.
186
+
187
+ ---
188
+
189
+ ## Compositing guide
190
+
191
+ All three outputs are subtitle *overlays*: they contain only the text (and the
192
+ audio), so you place them on top of your footage and key out the background.
193
+
194
+ ### 剪映 (CapCut / JianYing)
195
+
196
+ 1. Import `subs-green.mp4` and drop it on a track above your video.
197
+ 2. Select the clip → **画面 (Picture)** → **抠像 (Key)** → **色度抠图 (Chroma key)**.
198
+ 3. Pick the key colour from the green background — it is `0x00B140`
199
+ (RGB `0, 177, 64`). Use the eyedropper on the green area.
200
+ 4. Raise **强度 (Strength)** until the green is fully gone, then adjust
201
+ **阴影 (Shadow)** to clean up the antialiased edges around the glyphs.
202
+
203
+ ### Adobe Premiere Pro
204
+
205
+ - **Green MP4**: apply **Ultra Key**, eyedrop the green, set *Matte Generation*
206
+ → *Tolerance* ~ 30–40 % and *Pedestal* ~ 10 %.
207
+ - **Transparent WebM / MOV**: just drop `subs-alpha.webm` (VP9 with alpha) or
208
+ `subs-alpha.mov` (ProRes 4444) onto the timeline — no keying needed.
209
+
210
+ ### DaVinci Resolve
211
+
212
+ - **Green MP4**: add a **3D Keyer** node, eyedrop the green, then refine with
213
+ the *Clean Black* / *Clean White* controls.
214
+ - **Transparent MOV**: import `subs-alpha.mov` and place it on a higher track;
215
+ Resolve honours the ProRes 4444 alpha directly.
216
+
217
+ ### Final Cut Pro
218
+
219
+ - **Green MP4**: apply the **Keyer** effect and pick the green.
220
+ - **Transparent MOV**: add `subs-alpha.mov` above your footage — the alpha is
221
+ used automatically.
222
+
223
+ ### Any NLE
224
+
225
+ Transparent WebM (VP9 `yuva420p`) and transparent MOV (ProRes 4444) can be
226
+ dragged straight onto the timeline in Premiere, DaVinci and Final Cut with no
227
+ keying. If your editor is unhappy with VP9 alpha, use the MOV.
228
+
229
+ ---
230
+
231
+ ## `words.json` timing format
232
+
233
+ subreel's public interchange format. Times are in **seconds** (`float`).
234
+
235
+ ```json
236
+ {
237
+ "language": "zh",
238
+ "source": "edge-tts",
239
+ "words": [
240
+ { "text": "你", "start": 0.12, "end": 0.31 },
241
+ { "text": "好", "start": 0.31, "end": 0.58 }
242
+ ]
243
+ }
244
+ ```
245
+
246
+ | Field | Type | Required | Notes |
247
+ | ---------- | ------ | -------- | ------------------------------------------------------------ |
248
+ | `words` | array | yes | Non-empty list of word objects. |
249
+ | `words[].text` | string | yes | The word or character as it should be displayed. |
250
+ | `words[].start` | number | yes | Start time in seconds. |
251
+ | `words[].end` | number | yes | End time in seconds; must be strictly greater than `start`. |
252
+ | `language` | string | no | Best-effort language tag (e.g. `zh`, `en`). |
253
+ | `source` | string | no | Free-form provenance (`edge-tts`, `faster-whisper`, …). |
254
+
255
+ Validation rules (enforced on load, with a clear error otherwise):
256
+
257
+ - `words` must be present and non-empty;
258
+ - every word needs `text` (string) and numeric `start` / `end`;
259
+ - `start < end` for every word;
260
+ - `start` values are monotonically non-decreasing (equal is allowed, so two
261
+ words may share a boundary).
262
+
263
+ ---
264
+
265
+ ## CLI reference
266
+
267
+ ```
268
+ subreel [-h] [--version] [-v] [-q] {tts,render} ...
269
+ ```
270
+
271
+ Global options: `--version`, `-v/--verbose` (INFO logging), `-q/--quiet`.
272
+
273
+ ### `subreel tts`
274
+
275
+ ```
276
+ subreel tts (--text FILE | --text-inline STR) [--voice VOICE]
277
+ [--rate RATE] [--pitch PITCH] --out AUDIO [--timings JSON]
278
+ ```
279
+
280
+ | Option | Default | Description |
281
+ | ------------------- | ------------------------ | --------------------------------------------- |
282
+ | `--text FILE` | — | Read the script from a UTF-8 file. |
283
+ | `--text-inline STR` | — | Use the given text directly. |
284
+ | `--voice` | `zh-CN-XiaoxiaoNeural` | edge-tts voice name. |
285
+ | `--rate` | `+0%` | Speaking rate, e.g. `+30%`. |
286
+ | `--pitch` | `+0Hz` | Pitch shift, e.g. `+8Hz`. |
287
+ | `--out` | *(required)* | Output audio file. |
288
+ | `--timings` | next to `--out` | words.json output path. |
289
+
290
+ ### `subreel render`
291
+
292
+ ```
293
+ subreel render AUDIO [--timings JSON] [--asr] [--asr-model M] [--language L]
294
+ [--force-asr] [--formats F] [--out-dir DIR] [--size WxH]
295
+ [--fps N] [--green HEX] [--no-audio] [--fontsdir DIR]
296
+ [--font NAME] [--fontsize N] [--align POS] [--highlight HEX]
297
+ [--color HEX] [--no-fade] [--max-chars N] [--max-lines N]
298
+ [--hold SEC]
299
+ ```
300
+
301
+ | Option | Default | Description |
302
+ | --------------- | ------------------- | -------------------------------------------------------------- |
303
+ | `AUDIO` | *(required)* | Source audio file. |
304
+ | `--timings` | — | words.json word timings (takes precedence over `--asr`). |
305
+ | `--asr` | off | Derive timings with faster-whisper. |
306
+ | `--asr-model` | `base` | faster-whisper model size / name. |
307
+ | `--language` | auto | Force the ASR language (e.g. `zh`, `en`). |
308
+ | `--force-asr` | off | Re-run ASR even if a cached words.json exists. |
309
+ | `--formats` | `green` | Comma-separated subset of `green`, `webm`, `mov`. |
310
+ | `--out-dir` | `./out` | Output directory (created if missing). |
311
+ | `--size` | `1280x720` | Canvas size. |
312
+ | `--fps` | `30` | Frame rate. |
313
+ | `--green` | `0x00B140` | Chroma-key green colour for the `green` format. |
314
+ | `--no-audio` | off | Omit the audio track from the outputs. |
315
+ | `--fontsdir` | — | Extra font directory for libass. |
316
+ | `--font` | `Noto Sans CJK SC` | Subtitle font name. |
317
+ | `--fontsize` | `64` | Subtitle font size. |
318
+ | `--align` | `bottom` | `bottom`, `center`/`middle` or `top`. |
319
+ | `--highlight` | `#FFE500` | Karaoke highlight colour (sung words), `#RRGGBB`. |
320
+ | `--color` | `#FFFFFF` | Base colour (not-yet-sung words). |
321
+ | `--no-fade` | off | Disable the per-line fade in/out. |
322
+ | `--max-chars` | `22` | Per-line width budget, in CJK cells. |
323
+ | `--max-lines` | `2` | Soft maximum lines per sentence. |
324
+ | `--hold` | `0.3` | Karaoke hold tail, in seconds. |
325
+
326
+ **Exit codes:** `0` on success, `2` for every recoverable error (missing
327
+ ffmpeg, missing audio, no timing source, bad words.json, ffmpeg failure).
328
+
329
+ ---
330
+
331
+ ## Development
332
+
333
+ ```bash
334
+ git clone https://github.com/paxoscn/subreel.git
335
+ cd subreel
336
+ pip install -e ".[dev,tts,asr]"
337
+
338
+ # run the offline test suite (no network, no model downloads)
339
+ python3 -m pytest tests/ -q
340
+
341
+ # byte-compile check
342
+ python3 -m compileall src/
343
+ ```
344
+
345
+ The tests mock `edge-tts`, `faster-whisper` and `ffmpeg`, so they run anywhere.
346
+
347
+ CI ([`.github/workflows/ci.yml`](.github/workflows/ci.yml)) runs the suite on
348
+ Python 3.9–3.13, then builds the sdist + wheel, `twine check --strict`s the
349
+ metadata and smoke-installs the wheel. Release automation (tag → PyPI via OIDC
350
+ trusted publishing) is documented in [`docs/releasing.md`](docs/releasing.md).
351
+
352
+ ---
353
+
354
+ ## License
355
+
356
+ [Apache-2.0](LICENSE) © 2026 paxoscn
357
+
358
+ ---
359
+
360
+ ## Credits
361
+
362
+ subreel stands on the shoulders of these projects:
363
+
364
+ - [**ffmpeg**](https://ffmpeg.org/) — probing, filtering and encoding;
365
+ - [**libass**](https://github.com/libass/libass) — ASS subtitle rendering (via
366
+ ffmpeg's `ass` filter);
367
+ - [**edge-tts**](https://github.com/rany2/edge-tts) — neural text-to-speech and
368
+ word-boundary timings;
369
+ - [**faster-whisper**](https://github.com/SYSTRAN/faster-whisper) — fast
370
+ word-level speech recognition.