SRTranslator
Install
pip install srtranslator
Usage in Blender
tin2tin has made this blender addon. Check it out.
Usage from script
Import stuff
import os
# SRT File
from srtranslator import SrtFile
# ASS File
from srtranslator import AssFile
from srtranslator.translators.deepl_api import DeeplApi
from srtranslator.translators.deepl_scrap import DeeplTranslator
from srtranslator.translators.translatepy import TranslatePy
from srtranslator.translators.pydeeplx import PyDeepLX
Initialize translator. It can be any translator, even your own, check the docs, there are instructions per translator and how to create your own.
translator = DeeplTranslator() # or TranslatePy() or DeeplApi(api_key) or DeepLX()
Load, translate and save. For multiple recursive files in folder, check examples folder
filepath = "./filepath/to/srt"
# SRT File
sub = SrtFile(filepath)
# ASS File
sub = AssFile(filepath)
# Translate
sub.translate(translator, "en", "es")
# Making the result subtitles prettier
sub.wrap_lines()
sub.save(f"{os.path.splitext(filepath)[0]}_translated.srt")
Quit translator
translator.quit()
Usage from GUI
Last release has installers for the official srtranslatorGUI on windows (.msi) and linux (.deb, .flatpak)
Package from source
In folder srtranslatorGUI there is a briefcase/toga GUI implementation in top of the translator core. You could create your own binary with:
cd srtranslatorGUI
pip install briefcase
briefcase create
briefcase build
briefcase package
Binaries found in dist folder
Alternatives
KryptoST has made a graphical user interface. You can check it out here
Usage command line
# SRT file
python -m srtranslator ./filepath/to/srt -i SRC_LANG -o DEST_LANG
# ASS file
python -m srtranslator ./filepath/to/ass -i SRC_LANG -o DEST_LANG
Advanced usage
usage: __main__.py [-h] [-i SRC_LANG] [-o DEST_LANG] [-v] [-vv] [-s] [-w WRAP_LIMIT] [-t {deepl-scrap,translatepy,deepl-api,pydeeplx}] [--auth AUTH] path
Translate an .STR and .ASS file
positional arguments:
path File to translate
options:
-h, --help show this help message and exit
-i SRC_LANG, --src-lang SRC_LANG
Source language. Default: auto
-o DEST_LANG, --dest-lang DEST_LANG
Destination language. Default: es (spanish)
-v, --verbose Increase output verbosity
-vv, --debug Increase output verbosity for debugging
-s, --show-browser Show browser window
-w WRAP_LIMIT, --wrap-limit WRAP_LIMIT
Number of characters -including spaces- to wrap a line of text. Default: 50
-t {deepl-scrap,translatepy,deepl-api}, --translator {deepl-scrap,translatepy,deepl-api,pydeeplx}
Built-in translator to use
--auth AUTH Api key if needed on translator
--proxies Use proxy by default for pydeeplx
Metadata
Release files for srtranslator 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| srtranslator-0.3.9.tar.gz | 12.1 kB | Without provenance | Details for srtranslator-0.3.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| srtranslator-0.3.9-py3-none-any.whl | Python 3 | none | any | Details for srtranslator-0.3.9-py3-none-any.whl |
Total release size: 27.3 kB
Release files / srtranslator-0.3.9.tar.gz
| Download URL | srtranslator-0.3.9.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d29124e592ef8ad1d459dea8d5ab7e12c044dca7e4748d4ce19d9e33045b3b3f
|
|
BLAKE2b-256 checksum How to use checksums |
30c3741ec95bf92cb40723eb739201d52976c26f77c19a783dab34512bd6400e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / srtranslator-0.3.9-py3-none-any.whl
| Download URL | srtranslator-0.3.9-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0d0742f1927127de40d39a93eb645cb20cc7c9d7a875e26a4f79989681b6c48
|
|
BLAKE2b-256 checksum How to use checksums |
eff8228d5521e25333b7ba9afed739729976f32ad2508ce89dfd6bacf2d32aba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for srtranslator 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.