subpeeko 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.
- subpeeko-0.1.0/BUILD.md +70 -0
- subpeeko-0.1.0/LICENSE +21 -0
- subpeeko-0.1.0/MANIFEST.in +10 -0
- subpeeko-0.1.0/PKG-INFO +240 -0
- subpeeko-0.1.0/README.md +215 -0
- subpeeko-0.1.0/README.zh-CN.md +144 -0
- subpeeko-0.1.0/RELEASES.md +42 -0
- subpeeko-0.1.0/THIRD_PARTY_NOTICES.md +16 -0
- subpeeko-0.1.0/pyproject.toml +37 -0
- subpeeko-0.1.0/setup.cfg +4 -0
- subpeeko-0.1.0/setup.py +25 -0
- subpeeko-0.1.0/src/subpeeko/__init__.py +3 -0
- subpeeko-0.1.0/src/subpeeko/__main__.py +3 -0
- subpeeko-0.1.0/src/subpeeko/checkpoint.py +88 -0
- subpeeko-0.1.0/src/subpeeko/cli.py +266 -0
- subpeeko-0.1.0/src/subpeeko/config.py +171 -0
- subpeeko-0.1.0/src/subpeeko/data/LICENSE-KyleBing.txt +28 -0
- subpeeko-0.1.0/src/subpeeko/data/vocabulary-source.json +4 -0
- subpeeko-0.1.0/src/subpeeko/data/vocabulary.json +1 -0
- subpeeko-0.1.0/src/subpeeko/model.py +328 -0
- subpeeko-0.1.0/src/subpeeko/rate_limit.py +54 -0
- subpeeko-0.1.0/src/subpeeko/subtitles.py +187 -0
- subpeeko-0.1.0/src/subpeeko/vocabulary.py +79 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/PKG-INFO +240 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/SOURCES.txt +31 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/dependency_links.txt +1 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/entry_points.txt +2 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/requires.txt +2 -0
- subpeeko-0.1.0/src/subpeeko.egg-info/top_level.txt +1 -0
- subpeeko-0.1.0/tests/test_subpeeko.py +738 -0
- subpeeko-0.1.0/tests/test_vocabulary_build.py +64 -0
- subpeeko-0.1.0/vocabulary_build.py +81 -0
subpeeko-0.1.0/BUILD.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Build and package SubPeeko
|
|
2
|
+
|
|
3
|
+
The project requires Python 3.10 or later. Build commands should run from the
|
|
4
|
+
repository root.
|
|
5
|
+
|
|
6
|
+
## Prepare a build environment
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
python -m venv .venv
|
|
10
|
+
python -m pip install --upgrade pip
|
|
11
|
+
python -m pip install --upgrade build twine
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install the project and its runtime dependencies when running the command-line
|
|
15
|
+
tool locally.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m pip install -e .
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Run checks
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip check
|
|
25
|
+
python -m unittest discover -s tests -v
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The test suite uses synthetic model responses and does not require an API key.
|
|
29
|
+
|
|
30
|
+
## Build artifacts
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m build
|
|
34
|
+
python -m twine check dist/*
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The build creates a wheel and a source distribution in `dist/`. The custom
|
|
38
|
+
build step checks the upstream vocabulary revision and license. When the
|
|
39
|
+
upstream check is unavailable, it keeps the bundled vocabulary snapshot and
|
|
40
|
+
reports the fallback. It does not fetch vocabulary at runtime.
|
|
41
|
+
|
|
42
|
+
Inspect the contents before publishing.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
python -c "import zipfile; print(zipfile.ZipFile('dist/subpeeko-0.1.0-py3-none-any.whl').namelist())"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The artifacts must not contain `sample/`, `.env`, API keys, or ASS files. They
|
|
49
|
+
must contain the project `LICENSE`, `THIRD_PARTY_NOTICES.md`, and the bundled
|
|
50
|
+
KyleBing license under `subpeeko/data/`.
|
|
51
|
+
|
|
52
|
+
## Test the wheel
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m pip install --force-reinstall --no-deps dist/subpeeko-0.1.0-py3-none-any.whl
|
|
56
|
+
subpeeko --help
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Use an isolated environment for this check so that the wheel is tested instead
|
|
60
|
+
of an editable checkout.
|
|
61
|
+
|
|
62
|
+
## Publish
|
|
63
|
+
|
|
64
|
+
Publishing is intentionally a separate step from building. After reviewing the
|
|
65
|
+
release notes, artifacts, license files, and package index settings, upload the
|
|
66
|
+
artifacts with the package index's approved credentials.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python -m twine upload dist/*
|
|
70
|
+
```
|
subpeeko-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SubPeeko contributors
|
|
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.
|
subpeeko-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: subpeeko
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Create level-aware English-learning subtitles from bilingual ASS files
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/zhaneran/SubPeeko
|
|
7
|
+
Project-URL: Repository, https://github.com/zhaneran/SubPeeko
|
|
8
|
+
Project-URL: Issues, https://github.com/zhaneran/SubPeeko/issues
|
|
9
|
+
Project-URL: Releases, https://github.com/zhaneran/SubPeeko/releases
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
21
|
+
License-File: src/subpeeko/data/LICENSE-KyleBing.txt
|
|
22
|
+
Requires-Dist: keyring>=24
|
|
23
|
+
Requires-Dist: python-dotenv>=1
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# SubPeeko
|
|
27
|
+
|
|
28
|
+
[中文文档](README.zh-CN.md)
|
|
29
|
+
|
|
30
|
+
<p>
|
|
31
|
+
<a href="https://github.com/zhaneran/SubPeeko/actions/workflows/tests.yml?query=branch%3Amain"><img src="https://github.com/zhaneran/SubPeeko/actions/workflows/tests.yml/badge.svg?branch=main" alt="Build status"></a>
|
|
32
|
+
<a href="https://github.com/zhaneran/SubPeeko/releases"><img src="https://img.shields.io/github/v/release/zhaneran/SubPeeko?display_name=tag" alt="Latest release"></a>
|
|
33
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/zhaneran/SubPeeko" alt="License"></a>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
SubPeeko creates English-learning subtitles from bilingual English–Chinese ASS
|
|
37
|
+
files. It retains the original English and replaces the dialogue's Chinese
|
|
38
|
+
translation with concise annotations for language points above the selected
|
|
39
|
+
learning level.
|
|
40
|
+
|
|
41
|
+
The current package version is `0.1.0`. See [RELEASES.md](RELEASES.md) for the
|
|
42
|
+
release record and [BUILD.md](BUILD.md) for build and publishing instructions.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
With Python 3.10 or later, install from a local checkout:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
When using a virtual environment, activate it first so that the `subpeeko`
|
|
53
|
+
command is available. After publication, the package can be installed with
|
|
54
|
+
`python -m pip install subpeeko`.
|
|
55
|
+
|
|
56
|
+
## Configure the model
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
subpeeko config # interactively set the API root, model, and API key
|
|
60
|
+
subpeeko config show # show settings without revealing the key
|
|
61
|
+
subpeeko config test # send a small request to verify the connection
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The API must support OpenAI-compatible Chat Completions. Set the base URL to the
|
|
65
|
+
provider's API root, for example `https://example.com/v1`, without appending
|
|
66
|
+
`/chat/completions`. The connection test makes a real request and may incur a
|
|
67
|
+
charge.
|
|
68
|
+
|
|
69
|
+
The model name and base URL are stored in the user's configuration directory.
|
|
70
|
+
The API key is stored in the system credential store, not that configuration
|
|
71
|
+
file. If no supported credential store is available, set `SUBPEEKO_API_KEY` in
|
|
72
|
+
the environment. Non-interactive environments can set all three variables:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
SUBPEEKO_BASE_URL=https://example.com/v1
|
|
76
|
+
SUBPEEKO_MODEL_NAME=your-model
|
|
77
|
+
SUBPEEKO_API_KEY=your-api-key
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Environment variables override the current directory's optional `.env` file,
|
|
81
|
+
which in turn overrides saved settings. The key from either source takes
|
|
82
|
+
priority over the credential store. See [.env.example](.env.example); never
|
|
83
|
+
commit a real `.env` file or put the key on the command line.
|
|
84
|
+
|
|
85
|
+
## Convert subtitles
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
subpeeko "movie.ass" --level cet4
|
|
89
|
+
subpeeko "./subtitles" --level cet4
|
|
90
|
+
subpeeko "./subtitles" --level cet4 --recursive
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The available levels are `highschool`, `cet4`, `cet6`, and `postgrad`, in
|
|
94
|
+
ascending cumulative order. Each result is written beside its input, for example
|
|
95
|
+
`movie.cet4.subpeeko.ass`. The input is never overwritten. Existing results are
|
|
96
|
+
not replaced unless `--overwrite` is specified, and generated files are skipped
|
|
97
|
+
when scanning a directory. A directory is scanned without recursion by default.
|
|
98
|
+
|
|
99
|
+
Use `--dry-run` to list inputs and destinations without making model requests or
|
|
100
|
+
writing files. In a batch, errors are reported per file and remaining inputs are
|
|
101
|
+
still processed; a nonzero exit status indicates a failure.
|
|
102
|
+
|
|
103
|
+
### Processing parameters
|
|
104
|
+
|
|
105
|
+
`--batch-size N` sets the number of target dialogues included in one model
|
|
106
|
+
request. It defaults to 5 and accepts values from 1 to 100. It is independent
|
|
107
|
+
of `--concurrency`, which controls how many requests may run at the same time.
|
|
108
|
+
Nearby dialogues are also included as context, so the request payload can
|
|
109
|
+
contain more dialogue rows than its target batch size.
|
|
110
|
+
|
|
111
|
+
Increasing the batch size reduces the number of requests but creates larger
|
|
112
|
+
prompts and larger failure units. Decreasing it makes failures easier to isolate
|
|
113
|
+
but increases the number of requests. A timed-out, truncated, or malformed
|
|
114
|
+
batch is split and retried without permanently reducing the size of later
|
|
115
|
+
batches.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
subpeeko "movie.ass" --level cet4 --batch-size 20 --concurrency 4
|
|
119
|
+
subpeeko "movie.ass" --level cet4 --batch-size 1 --concurrency 5
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The first command sends up to 20 target dialogues per request and runs up to 4
|
|
123
|
+
requests in parallel. The second sends one target dialogue per request and runs
|
|
124
|
+
up to 5 requests in parallel.
|
|
125
|
+
|
|
126
|
+
Requests send `enable_thinking: false` by default for every OpenAI-compatible
|
|
127
|
+
endpoint. Use `--thinking on` to enable it, or `--thinking auto` to omit the
|
|
128
|
+
parameter and use the provider's default. `enable_thinking` is a provider
|
|
129
|
+
extension, not a standard OpenAI field: if a provider rejects it, use
|
|
130
|
+
`--thinking auto`. Some models cannot disable thinking.
|
|
131
|
+
|
|
132
|
+
SubPeeko processes up to four batches concurrently by default. The default
|
|
133
|
+
per-process budgets are 60 requests per minute and 5,000,000 input and output
|
|
134
|
+
tokens per minute. The TPM default matches an Alibaba Cloud `qwen3.8-flash`
|
|
135
|
+
quota in Beijing; the RPM default is a conservative client setting, not a
|
|
136
|
+
provider limit. Check your provider, model, region, and account quota before
|
|
137
|
+
using these defaults, and reserve capacity for any other applications.
|
|
138
|
+
|
|
139
|
+
The defaults can be changed independently. For example:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
subpeeko "movie.ass" --level cet4 --concurrency 2 --rpm 30 --tpm 500000 --qps 0.5
|
|
143
|
+
subpeeko "movie.ass" --level cet4 --concurrency 1 # process batches serially
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`--qps` is optional and is capped at RPM / 60. The limiter uses 80% of the
|
|
147
|
+
configured quotas, spreads requests, and
|
|
148
|
+
reserves estimated input plus output tokens for every request, including
|
|
149
|
+
retries. `--max-output-tokens` controls the output reservation and API output
|
|
150
|
+
limit when rate limiting is enabled (default: 2048). For Alibaba Qwen3.8
|
|
151
|
+
Flash and Max the limit includes both reasoning and the final answer. For
|
|
152
|
+
other models or providers in thinking or auto mode, an additional estimated 8192 tokens
|
|
153
|
+
are reserved by default; adjust with `--reasoning-reserve` to match the model.
|
|
154
|
+
This reservation is not a hard limit on those providers' reasoning. A 429
|
|
155
|
+
response pauses subsequent requests before one retry, using a numeric
|
|
156
|
+
`Retry-After` when supplied.
|
|
157
|
+
|
|
158
|
+
Token reservation uses request UTF-8 bytes plus a fixed allowance rather than
|
|
159
|
+
the provider's tokenizer. This is a conservative estimate, not a guarantee:
|
|
160
|
+
providers may use different accounting or burst rules, and account quotas may
|
|
161
|
+
be shared with other processes. Allocate only this process's available share and
|
|
162
|
+
monitor the provider's actual usage.
|
|
163
|
+
|
|
164
|
+
SubPeeko reports each request's target count, network time, local rate-limit
|
|
165
|
+
wait, status, and input/output/reasoning Token usage when supplied by the
|
|
166
|
+
provider. A final summary includes total elapsed time and retry/split events.
|
|
167
|
+
No subtitle text or API keys are printed in these diagnostics.
|
|
168
|
+
|
|
169
|
+
Completed model batches are saved to an automatic local checkpoint, so rerun
|
|
170
|
+
the same command after an interruption to resume. Checkpoints are isolated by
|
|
171
|
+
file contents and path, level, model, credentials, prompt, vocabulary and
|
|
172
|
+
relevant settings. They contain English spans and Chinese annotations, but
|
|
173
|
+
not the API key or full original subtitle. They remain on disk after success;
|
|
174
|
+
use `--no-resume` to avoid reading and writing checkpoints and request fresh
|
|
175
|
+
results. In particular, `--overwrite` can reuse an existing checkpoint unless
|
|
176
|
+
`--no-resume` is also supplied. Checkpoints live in
|
|
177
|
+
`%LOCALAPPDATA%\subpeeko\checkpoints` on Windows and
|
|
178
|
+
`${XDG_CACHE_HOME:-~/.cache}/subpeeko/checkpoints` on Linux.
|
|
179
|
+
|
|
180
|
+
## How it works
|
|
181
|
+
|
|
182
|
+
Each identified bilingual dialogue is sent to the configured model, along with
|
|
183
|
+
the original Chinese and nearby dialogue as context. Word-list hints are
|
|
184
|
+
computed locally, and dialogues are grouped into batches to reduce the number
|
|
185
|
+
of requests. The model returns concise Chinese explanations for language points
|
|
186
|
+
above the selected level.
|
|
187
|
+
|
|
188
|
+
SubPeeko preserves original event timing, English text, styles, metadata, and
|
|
189
|
+
other events. It processes confidently identified bilingual dialogue whose
|
|
190
|
+
Chinese and English occupy separate contiguous ASS line groups. Single-line
|
|
191
|
+
mixed-language or otherwise ambiguous layouts are kept unchanged. The input
|
|
192
|
+
encoding is preserved for UTF-8, UTF-16 with a byte-order mark, and GB18030.
|
|
193
|
+
If a model response is incomplete or invalid, no result is written for that
|
|
194
|
+
file. Review long annotations for readability during short subtitle events.
|
|
195
|
+
|
|
196
|
+
The local `sample/` directory is excluded from Git and distribution packages.
|
|
197
|
+
Use subtitles you are allowed to process; their text is sent to your configured
|
|
198
|
+
model provider.
|
|
199
|
+
|
|
200
|
+
## Vocabulary source and updates
|
|
201
|
+
|
|
202
|
+
The bundled word list is derived from
|
|
203
|
+
[KyleBing/english-vocabulary](https://github.com/KyleBing/english-vocabulary),
|
|
204
|
+
which provides a BSD 3-Clause license. SubPeeko keeps normalized word heads and
|
|
205
|
+
their earliest associated level. The exact upstream revision in each package is
|
|
206
|
+
recorded in `subpeeko/data/vocabulary-source.json`; see
|
|
207
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for attribution and provenance.
|
|
208
|
+
These lists are references, not official exam syllabuses. The underlying data's
|
|
209
|
+
redistribution permissions need review before public release.
|
|
210
|
+
|
|
211
|
+
Each source-distribution or wheel build checks the upstream repository for a
|
|
212
|
+
new revision and, when available, builds an updated list into the package. It
|
|
213
|
+
checks the upstream license and validates the downloaded lists first. If the
|
|
214
|
+
check fails, the build warns and uses the bundled snapshot. The source checkout
|
|
215
|
+
is not modified, and installed SubPeeko does not fetch vocabulary at runtime.
|
|
216
|
+
|
|
217
|
+
## Release, build, and license
|
|
218
|
+
|
|
219
|
+
The source code is released under the [MIT License](LICENSE). The bundled
|
|
220
|
+
vocabulary data is third-party material with its own license and provenance
|
|
221
|
+
notice in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
222
|
+
|
|
223
|
+
Build and validate the wheel and source distribution with:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
python -m pip install --upgrade build twine
|
|
227
|
+
python -m build
|
|
228
|
+
python -m twine check dist/*
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
See [RELEASES.md](RELEASES.md) for version history and the release checklist.
|
|
232
|
+
See [BUILD.md](BUILD.md) for package inspection, wheel testing, and publishing
|
|
233
|
+
steps.
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
python -m pip install -e .
|
|
239
|
+
python -m unittest discover -s tests -v
|
|
240
|
+
```
|
subpeeko-0.1.0/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# SubPeeko
|
|
2
|
+
|
|
3
|
+
[中文文档](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://github.com/zhaneran/SubPeeko/actions/workflows/tests.yml?query=branch%3Amain"><img src="https://github.com/zhaneran/SubPeeko/actions/workflows/tests.yml/badge.svg?branch=main" alt="Build status"></a>
|
|
7
|
+
<a href="https://github.com/zhaneran/SubPeeko/releases"><img src="https://img.shields.io/github/v/release/zhaneran/SubPeeko?display_name=tag" alt="Latest release"></a>
|
|
8
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/zhaneran/SubPeeko" alt="License"></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
SubPeeko creates English-learning subtitles from bilingual English–Chinese ASS
|
|
12
|
+
files. It retains the original English and replaces the dialogue's Chinese
|
|
13
|
+
translation with concise annotations for language points above the selected
|
|
14
|
+
learning level.
|
|
15
|
+
|
|
16
|
+
The current package version is `0.1.0`. See [RELEASES.md](RELEASES.md) for the
|
|
17
|
+
release record and [BUILD.md](BUILD.md) for build and publishing instructions.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
With Python 3.10 or later, install from a local checkout:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
When using a virtual environment, activate it first so that the `subpeeko`
|
|
28
|
+
command is available. After publication, the package can be installed with
|
|
29
|
+
`python -m pip install subpeeko`.
|
|
30
|
+
|
|
31
|
+
## Configure the model
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
subpeeko config # interactively set the API root, model, and API key
|
|
35
|
+
subpeeko config show # show settings without revealing the key
|
|
36
|
+
subpeeko config test # send a small request to verify the connection
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The API must support OpenAI-compatible Chat Completions. Set the base URL to the
|
|
40
|
+
provider's API root, for example `https://example.com/v1`, without appending
|
|
41
|
+
`/chat/completions`. The connection test makes a real request and may incur a
|
|
42
|
+
charge.
|
|
43
|
+
|
|
44
|
+
The model name and base URL are stored in the user's configuration directory.
|
|
45
|
+
The API key is stored in the system credential store, not that configuration
|
|
46
|
+
file. If no supported credential store is available, set `SUBPEEKO_API_KEY` in
|
|
47
|
+
the environment. Non-interactive environments can set all three variables:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
SUBPEEKO_BASE_URL=https://example.com/v1
|
|
51
|
+
SUBPEEKO_MODEL_NAME=your-model
|
|
52
|
+
SUBPEEKO_API_KEY=your-api-key
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Environment variables override the current directory's optional `.env` file,
|
|
56
|
+
which in turn overrides saved settings. The key from either source takes
|
|
57
|
+
priority over the credential store. See [.env.example](.env.example); never
|
|
58
|
+
commit a real `.env` file or put the key on the command line.
|
|
59
|
+
|
|
60
|
+
## Convert subtitles
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
subpeeko "movie.ass" --level cet4
|
|
64
|
+
subpeeko "./subtitles" --level cet4
|
|
65
|
+
subpeeko "./subtitles" --level cet4 --recursive
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The available levels are `highschool`, `cet4`, `cet6`, and `postgrad`, in
|
|
69
|
+
ascending cumulative order. Each result is written beside its input, for example
|
|
70
|
+
`movie.cet4.subpeeko.ass`. The input is never overwritten. Existing results are
|
|
71
|
+
not replaced unless `--overwrite` is specified, and generated files are skipped
|
|
72
|
+
when scanning a directory. A directory is scanned without recursion by default.
|
|
73
|
+
|
|
74
|
+
Use `--dry-run` to list inputs and destinations without making model requests or
|
|
75
|
+
writing files. In a batch, errors are reported per file and remaining inputs are
|
|
76
|
+
still processed; a nonzero exit status indicates a failure.
|
|
77
|
+
|
|
78
|
+
### Processing parameters
|
|
79
|
+
|
|
80
|
+
`--batch-size N` sets the number of target dialogues included in one model
|
|
81
|
+
request. It defaults to 5 and accepts values from 1 to 100. It is independent
|
|
82
|
+
of `--concurrency`, which controls how many requests may run at the same time.
|
|
83
|
+
Nearby dialogues are also included as context, so the request payload can
|
|
84
|
+
contain more dialogue rows than its target batch size.
|
|
85
|
+
|
|
86
|
+
Increasing the batch size reduces the number of requests but creates larger
|
|
87
|
+
prompts and larger failure units. Decreasing it makes failures easier to isolate
|
|
88
|
+
but increases the number of requests. A timed-out, truncated, or malformed
|
|
89
|
+
batch is split and retried without permanently reducing the size of later
|
|
90
|
+
batches.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
subpeeko "movie.ass" --level cet4 --batch-size 20 --concurrency 4
|
|
94
|
+
subpeeko "movie.ass" --level cet4 --batch-size 1 --concurrency 5
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The first command sends up to 20 target dialogues per request and runs up to 4
|
|
98
|
+
requests in parallel. The second sends one target dialogue per request and runs
|
|
99
|
+
up to 5 requests in parallel.
|
|
100
|
+
|
|
101
|
+
Requests send `enable_thinking: false` by default for every OpenAI-compatible
|
|
102
|
+
endpoint. Use `--thinking on` to enable it, or `--thinking auto` to omit the
|
|
103
|
+
parameter and use the provider's default. `enable_thinking` is a provider
|
|
104
|
+
extension, not a standard OpenAI field: if a provider rejects it, use
|
|
105
|
+
`--thinking auto`. Some models cannot disable thinking.
|
|
106
|
+
|
|
107
|
+
SubPeeko processes up to four batches concurrently by default. The default
|
|
108
|
+
per-process budgets are 60 requests per minute and 5,000,000 input and output
|
|
109
|
+
tokens per minute. The TPM default matches an Alibaba Cloud `qwen3.8-flash`
|
|
110
|
+
quota in Beijing; the RPM default is a conservative client setting, not a
|
|
111
|
+
provider limit. Check your provider, model, region, and account quota before
|
|
112
|
+
using these defaults, and reserve capacity for any other applications.
|
|
113
|
+
|
|
114
|
+
The defaults can be changed independently. For example:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
subpeeko "movie.ass" --level cet4 --concurrency 2 --rpm 30 --tpm 500000 --qps 0.5
|
|
118
|
+
subpeeko "movie.ass" --level cet4 --concurrency 1 # process batches serially
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`--qps` is optional and is capped at RPM / 60. The limiter uses 80% of the
|
|
122
|
+
configured quotas, spreads requests, and
|
|
123
|
+
reserves estimated input plus output tokens for every request, including
|
|
124
|
+
retries. `--max-output-tokens` controls the output reservation and API output
|
|
125
|
+
limit when rate limiting is enabled (default: 2048). For Alibaba Qwen3.8
|
|
126
|
+
Flash and Max the limit includes both reasoning and the final answer. For
|
|
127
|
+
other models or providers in thinking or auto mode, an additional estimated 8192 tokens
|
|
128
|
+
are reserved by default; adjust with `--reasoning-reserve` to match the model.
|
|
129
|
+
This reservation is not a hard limit on those providers' reasoning. A 429
|
|
130
|
+
response pauses subsequent requests before one retry, using a numeric
|
|
131
|
+
`Retry-After` when supplied.
|
|
132
|
+
|
|
133
|
+
Token reservation uses request UTF-8 bytes plus a fixed allowance rather than
|
|
134
|
+
the provider's tokenizer. This is a conservative estimate, not a guarantee:
|
|
135
|
+
providers may use different accounting or burst rules, and account quotas may
|
|
136
|
+
be shared with other processes. Allocate only this process's available share and
|
|
137
|
+
monitor the provider's actual usage.
|
|
138
|
+
|
|
139
|
+
SubPeeko reports each request's target count, network time, local rate-limit
|
|
140
|
+
wait, status, and input/output/reasoning Token usage when supplied by the
|
|
141
|
+
provider. A final summary includes total elapsed time and retry/split events.
|
|
142
|
+
No subtitle text or API keys are printed in these diagnostics.
|
|
143
|
+
|
|
144
|
+
Completed model batches are saved to an automatic local checkpoint, so rerun
|
|
145
|
+
the same command after an interruption to resume. Checkpoints are isolated by
|
|
146
|
+
file contents and path, level, model, credentials, prompt, vocabulary and
|
|
147
|
+
relevant settings. They contain English spans and Chinese annotations, but
|
|
148
|
+
not the API key or full original subtitle. They remain on disk after success;
|
|
149
|
+
use `--no-resume` to avoid reading and writing checkpoints and request fresh
|
|
150
|
+
results. In particular, `--overwrite` can reuse an existing checkpoint unless
|
|
151
|
+
`--no-resume` is also supplied. Checkpoints live in
|
|
152
|
+
`%LOCALAPPDATA%\subpeeko\checkpoints` on Windows and
|
|
153
|
+
`${XDG_CACHE_HOME:-~/.cache}/subpeeko/checkpoints` on Linux.
|
|
154
|
+
|
|
155
|
+
## How it works
|
|
156
|
+
|
|
157
|
+
Each identified bilingual dialogue is sent to the configured model, along with
|
|
158
|
+
the original Chinese and nearby dialogue as context. Word-list hints are
|
|
159
|
+
computed locally, and dialogues are grouped into batches to reduce the number
|
|
160
|
+
of requests. The model returns concise Chinese explanations for language points
|
|
161
|
+
above the selected level.
|
|
162
|
+
|
|
163
|
+
SubPeeko preserves original event timing, English text, styles, metadata, and
|
|
164
|
+
other events. It processes confidently identified bilingual dialogue whose
|
|
165
|
+
Chinese and English occupy separate contiguous ASS line groups. Single-line
|
|
166
|
+
mixed-language or otherwise ambiguous layouts are kept unchanged. The input
|
|
167
|
+
encoding is preserved for UTF-8, UTF-16 with a byte-order mark, and GB18030.
|
|
168
|
+
If a model response is incomplete or invalid, no result is written for that
|
|
169
|
+
file. Review long annotations for readability during short subtitle events.
|
|
170
|
+
|
|
171
|
+
The local `sample/` directory is excluded from Git and distribution packages.
|
|
172
|
+
Use subtitles you are allowed to process; their text is sent to your configured
|
|
173
|
+
model provider.
|
|
174
|
+
|
|
175
|
+
## Vocabulary source and updates
|
|
176
|
+
|
|
177
|
+
The bundled word list is derived from
|
|
178
|
+
[KyleBing/english-vocabulary](https://github.com/KyleBing/english-vocabulary),
|
|
179
|
+
which provides a BSD 3-Clause license. SubPeeko keeps normalized word heads and
|
|
180
|
+
their earliest associated level. The exact upstream revision in each package is
|
|
181
|
+
recorded in `subpeeko/data/vocabulary-source.json`; see
|
|
182
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for attribution and provenance.
|
|
183
|
+
These lists are references, not official exam syllabuses. The underlying data's
|
|
184
|
+
redistribution permissions need review before public release.
|
|
185
|
+
|
|
186
|
+
Each source-distribution or wheel build checks the upstream repository for a
|
|
187
|
+
new revision and, when available, builds an updated list into the package. It
|
|
188
|
+
checks the upstream license and validates the downloaded lists first. If the
|
|
189
|
+
check fails, the build warns and uses the bundled snapshot. The source checkout
|
|
190
|
+
is not modified, and installed SubPeeko does not fetch vocabulary at runtime.
|
|
191
|
+
|
|
192
|
+
## Release, build, and license
|
|
193
|
+
|
|
194
|
+
The source code is released under the [MIT License](LICENSE). The bundled
|
|
195
|
+
vocabulary data is third-party material with its own license and provenance
|
|
196
|
+
notice in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
197
|
+
|
|
198
|
+
Build and validate the wheel and source distribution with:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python -m pip install --upgrade build twine
|
|
202
|
+
python -m build
|
|
203
|
+
python -m twine check dist/*
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
See [RELEASES.md](RELEASES.md) for version history and the release checklist.
|
|
207
|
+
See [BUILD.md](BUILD.md) for package inspection, wheel testing, and publishing
|
|
208
|
+
steps.
|
|
209
|
+
|
|
210
|
+
## Development
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
python -m pip install -e .
|
|
214
|
+
python -m unittest discover -s tests -v
|
|
215
|
+
```
|