Skip to main content

Traslate a .SRT file using any custom translator

Project description

SRTranslator

Install

PyPI

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


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.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

srtranslator-0.1.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file srtranslator-0.1.2.tar.gz.

File metadata

  • Download URL: srtranslator-0.1.2.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

Hashes for srtranslator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f3288d0fcd20e176f3c3a7a1afe119dd736d311791aacd11374d1cdfc428a6a9
MD5 82c7ebd314ac40c4883ad083622561ea
BLAKE2b-256 bdaa0cbbd1166a5d6a4717cf8c96a2212633a79232648b3dd0bace5bf7192865

See more details on using hashes here.

File details

Details for the file srtranslator-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for srtranslator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d4c3bc28d28d885c0daf10fc44028b2cbcb3ff2edc5f46c51d613b9bf95666c
MD5 d53f4247a7b07e75e4e1381db7b91774
BLAKE2b-256 53303addd6bade5065c02398f6d5d88ed2015982ee4c43bb2f31eb936bad18a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page