Traslate a .SRT file using any custom translator
Project description
SRTranslator
Install
pip install srtranslator
Usage from script
Import stuff
from srtranslator import SrtFile
from srtranslator.translators.deepl import DeeplTranslator
from srtranslator.translators.translatepy import TranslatePy
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()
Load, translate and save. For multiple recursive files in folder, check examples folder
filepath = "./filepath/to/srt"
srt = SrtFile(filepath)
srt.translate(translator, "en", "es")
# Making the result subtitles prettier
srt.wrap_lines()
srt.save(f"{os.path.splitext(filepath)[0]}_translated.srt")
Quit translator
translator.quit()
Usage command line
python -m srtranslator ./filepath/to/srt -i SRC_LANG -o DEST_LANG
Advanced usage
usage: __main__.py [-h] [-i SRC_LANG] [-o DEST_LANG] [-v] [-vv] [-s] [-w WRAP_LIMIT] path
Translate an .STR 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
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
srtranslator-0.1.94.tar.gz
(8.8 kB
view details)
Built Distribution
File details
Details for the file srtranslator-0.1.94.tar.gz
.
File metadata
- Download URL: srtranslator-0.1.94.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8574d9702d23ed81773f502904f051663bce89c9bdada1c0dba0e66cc519edf |
|
MD5 | 69d3bed4645f520ac5a38ed0fd8434f2 |
|
BLAKE2b-256 | 658ac041836deeb0820e74e0678a8e8ad04ed9aec38a108b487ab092e59ebb59 |
File details
Details for the file srtranslator-0.1.94-py3-none-any.whl
.
File metadata
- Download URL: srtranslator-0.1.94-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59a7b5057b6649535893f95348a404911cc710265b72427688383e799115709c |
|
MD5 | 476974d48c408fac14e47066d2d52fc5 |
|
BLAKE2b-256 | 7b51e60dbb8107293b873bccd57f1af5468e8bf0fb88d864b79f62decbe46f5b |