Skip to main content

Traslate a .SRT file using any custom translator

Project description

SRTranslator

Install

PyPI

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


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

Uploaded Source

Built Distribution

srtranslator-0.2.8-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: srtranslator-0.2.8.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for srtranslator-0.2.8.tar.gz
Algorithm Hash digest
SHA256 ee17a1f749409e1fa908d928907263863b53a073710694b13be8f55ecede8d90
MD5 db8c6348697d4cbe51de121bb36aec5c
BLAKE2b-256 3ae989e0a31169c4b3b72465ddc25b00d041627cd86fa42618f92e4318163a55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: srtranslator-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for srtranslator-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a40721f8927a7664497e661c676f4c0fee09dd56aa05025c36228abb898343c8
MD5 393e9e21666335f4e4d4c9cf77428cd1
BLAKE2b-256 3be004d78036162aa40a20e2a0866fc56ab3450477184a82c425ae4f335c4701

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