Smart SRT subtitle translation with optional audio probing and provider abstraction
Project description
Smart SRT Translator
A lightweight, extensible Python package for translating SRT subtitle files, with optional audio probe support and pluggable providers (OpenAI, etc.).
Features
- Smart SRT in/out: preserves timing and structure.
- Provider abstraction: start with a no-op Dummy, optionally use OpenAI.
- Optional audio probe flow: generate JSON requests for uncertain segments.
- CLI
srt-translatefor quick usage; programmatic API for embedding.
Quick Start
- Create venv (choose one, depending on your setup):
- Windows:
py -m venv .venvorpython -m venv .venv - macOS/Linux:
python3 -m venv .venv(orpython -m venv .venv) - Activate:
- PowerShell:
.venv\Scripts\Activate.ps1 - CMD:
.venv\Scripts\activate.bat - bash/zsh:
source .venv/bin/activate
- PowerShell:
- Windows:
- Install (local):
python -m pip install -e .[openai](omit[openai]to skip OpenAI extra) - Translate (CLI):
- Smart (default):
srt-translate translate Sample/firstdayinnewhospital.srt en de - Provider is
openaiby default; modesmartby default. - The CLI auto-loads
.envwithOPENAI_API_KEYand optionalOPENAI_MODEL. - Note: Inside the venv prefer
python -m pip ...(on Unix you may usepython3 -m pip ...). - Basic per-segment:
srt-translate translate Sample/firstdayinnewhospital.srt auto de --provider dummy --mode basic
- Smart (default):
Recommended Defaults
- Wrap width: 40 (
--wrap-width 40) - Review: on, thresholds ASCII=0.6, STOP=0.15 (override with
--no-review,--review-*) - Strict review: on with 2 passes (disable via
--no-strict-review) - Smoothing: on (disable via
--no-smooth) - Balancing: on, ratio=1.8 (disable via
--no-balance, tune with--balance-ratio)
Minimal Usage
srt-translate translate Sample/firstdayinnewhospital.srt en de
Programmatic API
from smart_srt_translator import translate_srt_file, translate_srt_smart, TranslateOptions
res = translate_srt_file(
"Sample/firstdayinnewhospital.srt",
src_lang=None, # auto
tgt_lang="de",
options=TranslateOptions(probe_mode="off")
)
print(res.output_path)
# or Smart mode (uses recommended defaults)
out = translate_srt_smart(
"Sample/firstdayinnewhospital.srt",
src_lang="en",
tgt_lang="de",
# wrap_width=40,
# review=True,
# review_ascii_threshold=0.6,
# review_stop_threshold=0.15,
# strict_review=True,
# strict_max_passes=2,
# smooth=True,
# balance=True,
# balance_ratio=1.8,
)
print(out)
Audio Probe Flow (Concept)
--probe ask: creates<output>.requests.jsonwith segment time windows needing audio review.- Provide
resolutions.jsonlater (same IDs) to finalize improved translations (plannedfinalize). --probe auto: will require a transcriber provider and audio source (roadmap).
Configuration
- OpenAI provider needs
OPENAI_API_KEYand optionalOPENAI_MODEL. - The CLI auto-loads
.envfrom the repo root orVidScalerSubtitleAdder/.envif present.
Status
- MVP scaffold ready. OpenAI provider implemented at a minimal prompt level.
- Finalization flow and advanced sentence-grouping/caching from the app are planned to be ported.
License
MIT
Project details
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 smart_srt_translator-0.1.1.tar.gz.
File metadata
- Download URL: smart_srt_translator-0.1.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e7588ec52b4ceda901ebae3c420722bab2e4e765568d55162e97af094b6be3
|
|
| MD5 |
c21a792f8cf5ca72ab16de7869e0011b
|
|
| BLAKE2b-256 |
65f16ed0611da0cf5a16c3296ebbc9b2248b4ec1bd8fec0bd494807f745352e3
|
File details
Details for the file smart_srt_translator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: smart_srt_translator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fba0868607a9b8ce9f4d32da61e3de0e3f954b6372bdff88157d8ca99d52220
|
|
| MD5 |
3ddbd85eab452c7c3000906b47c56dc9
|
|
| BLAKE2b-256 |
1bf603a65854ac467871345c46d80415091579dc66585a30df3d1e05e14fb1cb
|