Traslate a .SRT file using any custom translator
Project description
SRTranslator
Install
pip install srtranslator
Usage in Blender
tin2tin has made this blender addon. Check it out.
Usage from script
Import stuff
import os
from srtranslator import SrtFile
from srtranslator.translators.deepl_api import DeeplApi
from srtranslator.translators.deepl_scrap 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() or DeeplApi(api_key)
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 from GUI
KryptoST has made a graphical user interface. You can check it out here
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] [-t {deepl-scrap,translatepy,deepl-api}] [--auth AUTH] 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
-t {deepl-scrap,translatepy,deepl-api}, --translator {deepl-scrap,translatepy,deepl-api}
Built-in translator to use
--auth AUTH Api key if needed on translator
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.2.3.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file srtranslator-0.2.3.tar.gz
.
File metadata
- Download URL: srtranslator-0.2.3.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45e2c0b4bd0162289baacac7528f62bd5fdcde5fe8b77edb288cda704164a5d4 |
|
MD5 | 4639d8c7f6caf3034914eee237308b95 |
|
BLAKE2b-256 | 175d256e3a7609836ffeefdd4540dac4031a3fd075b0f6af0f4a7bf1d6bfc2e6 |
File details
Details for the file srtranslator-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: srtranslator-0.2.3-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4bb47f0fe220e7dfe7f1688c355f2c78132b12e913118909559c39b32d355f1 |
|
MD5 | ca0e72b1f5b641345b90d41c67dd6eb5 |
|
BLAKE2b-256 | 1325f5312e4f583276a13ef4ec0907ae449650aced878b68c0f19dfa0d03d6d6 |