LLM-powered subtitle translation CLI with batch memory and review passes.
Project description
subbake
subbake 是一个简单的字幕翻译 CLI,默认将字幕翻译为中文。
它的目标是用尽量直接的命令行工作流处理字幕翻译,同时保留对批量翻译、断点续跑、缓存和复审这些实用能力的支持。
核心能力
- 支持
.srt、.vtt和按行处理的.txt - 默认翻译目标语言为中文,支持双语输出
- 智能批量翻译与上下文记忆,默认批次大小上限为
30 - glossary 持久化、缓存复用、增量式断点续跑
- 输出校验、失败重试、失败样本落盘
- 针对高风险 batch 的最终复审,统一术语、语气和风格
- 基于
rich的命令行可视化,包括进度、时间线和 Token 用量
安装
pip install subbake
本地开发可使用:
pip install -e .
或:
uv sync
快速开始
最常见的用法如下:
sbake translate input.srt --provider openai --model your-model
使用 OpenAI 兼容接口时,可通过环境变量配置:
export OPENAI_API_KEY="your_api_key"
export OPENAI_BASE_URL="https://your-provider.example.com/v1"
Anthropic 使用:
export ANTHROPIC_API_KEY="your_api_key"
sbake translate input.srt --provider anthropic --model your-model
内置 mock 后端可用于本地联调:
sbake translate input.srt --provider mock
常用命令
翻译字幕:
sbake translate input.srt --provider openai --model your-model
输出双语字幕:
sbake translate input.vtt --provider openai --model your-model --bilingual
仅检查切分结果,不调用模型:
sbake translate input.txt --dry-run --batch-size 30
指定 glossary 文件:
sbake translate input.srt --provider openai --model your-model --glossary-path ./glossary.json
跳过已有状态,从头重新执行:
sbake translate input.srt --provider openai --model your-model --no-resume --no-cache
清理运行期文件:
sbake clean input.srt
sbake clean . --all
检查 Key 是否可用:
sbake check-key --provider openai
sbake check-key --provider anthropic
模型接入
支持以下后端:
mockopenaianthropic
其中 openai 后端也可用于 OpenAI 兼容接口。API Key 既可以通过环境变量提供,也可以通过 --api-key 直接传入;兼容接口地址可通过 OPENAI_BASE_URL 或 --base-url 指定。
运行期文件
默认情况下,工具会在输入文件同级目录下创建 .subbake/ 目录,包含:
cache/:按 prompt hash 缓存的模型响应runs/.../run_state.json:运行状态与断点续跑信息runs/.../translated_batches/:每个翻译 batch 的分片结果runs/.../reviewed_batches/:每个复审 batch 的分片结果runs/.../failures/:失败 batch 样本glossary.json:持久化 glossary
可通过 --work-dir 指定运行目录,通过 --glossary-path 单独指定 glossary 文件位置。
输出约定
- 普通输出:
input.translated.srt/input.translated.vtt/input.translated.txt - 双语输出:
input.bilingual.srt/input.bilingual.vtt/input.bilingual.txt
常用参数
--provider:模型提供方--model:模型名称--api-key:直接传入 API Key--base-url:OpenAI 兼容接口地址--batch-size:批次大小,默认30--bilingual:输出双语字幕--dry-run:只解析和切分 batch,不调用模型--resume / --no-resume:是否使用断点续跑--cache / --no-cache:是否启用缓存--work-dir:运行期目录--glossary-path:glossary 文件位置--final-review / --no-final-review:是否对高风险 batch 执行最终复审
完整命令说明请参考:
sbake translate --help
sbake check-key --help
sbake clean --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subbake-0.2.0.tar.gz.
File metadata
- Download URL: subbake-0.2.0.tar.gz
- Upload date:
- Size: 45.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb372be23522eb7c336ea129a9ab505be0f48f1d35c8a0cede64774a368a45eb
|
|
| MD5 |
22f05b28d95fe9e0e4918e3702a800eb
|
|
| BLAKE2b-256 |
e09c0c5e6a0c91269c73d57306030b0ad4cd02b7f1dea4ba767ca7b4e4e233cc
|
Provenance
The following attestation bundles were made for subbake-0.2.0.tar.gz:
Publisher:
release.yml on heyifan142857/SubBake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
subbake-0.2.0.tar.gz -
Subject digest:
bb372be23522eb7c336ea129a9ab505be0f48f1d35c8a0cede64774a368a45eb - Sigstore transparency entry: 1347747072
- Sigstore integration time:
-
Permalink:
heyifan142857/SubBake@6ff3d6b926651cdc19e68bd3eeab4810ace8b319 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/heyifan142857
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6ff3d6b926651cdc19e68bd3eeab4810ace8b319 -
Trigger Event:
push
-
Statement type:
File details
Details for the file subbake-0.2.0-py3-none-any.whl.
File metadata
- Download URL: subbake-0.2.0-py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af95bedfa515f904d06a0cc5568e729597a254d3b74bbfd695e28db9449e4215
|
|
| MD5 |
4157803df4ebc19bc15192b2958124ac
|
|
| BLAKE2b-256 |
070dd87a36e060f74fe0fead22003b4df01bd2c7cdb4f25607833c7eef1f578c
|
Provenance
The following attestation bundles were made for subbake-0.2.0-py3-none-any.whl:
Publisher:
release.yml on heyifan142857/SubBake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
subbake-0.2.0-py3-none-any.whl -
Subject digest:
af95bedfa515f904d06a0cc5568e729597a254d3b74bbfd695e28db9449e4215 - Sigstore transparency entry: 1347747174
- Sigstore integration time:
-
Permalink:
heyifan142857/SubBake@6ff3d6b926651cdc19e68bd3eeab4810ace8b319 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/heyifan142857
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6ff3d6b926651cdc19e68bd3eeab4810ace8b319 -
Trigger Event:
push
-
Statement type: