It is a tool to translate subtitles into any language, that is supported by google translator
Project description
TranslateSubs
It's a tool to translate subtitles into any language, that is supported by google translator :)
About
The translator can be either used to extract the subtitle from the video file and then perform translation on that file or process a subtitle file instead. The first required an ffpmeg installed and setup to work from terminal. If you extract subtitle yourself, note that often the file format for subtitles is SRT. This only has minimal styling and anime usually ASS format, which can even do animations. I recommend sticking to ACC if you want the styling to remain.
Another really nice feature is being able to merge both the translation AND the original subtitles together. The original can be made smaller and slightly opaque to not distract and not take up too much space:
Usage
Basic Example
To translate an existing subtitle file (e.g. the provided truncated.ass) and translate to Spanish (default is Spanish):
python substranslator.py truncated.ass out.ass --to_lang es
This will generate out.ass subtitle file, which can be imported in the VLC player via Subtitles -> Add Subtitle File...
Use video file
If a video file is being used instead e.g. video.mkv, add --video_file flag and the first parameter becomes a video file:
python substranslator.py video.mkv out.ass --video_file
Display two languages
If you would like to learn a new language you might as well show both the original AND the translated languages (original letters are smaller and slightly transparent, as shown in the example picture) using flag --combine:
python substranslator.py truncated.ass out.ass --combine
Select different subtitle track
Some video files might have multiple subtitle tracks. You can select the track you want to use (starting from 0) using argument --subs_track:
python substranslator.py video.mkv out.ass --video_file --subs_track 1
Note
The tool uses a free googletrans API, which uses one of the google domains e.g. translate.google.com or translate.google.co.uk to perform translation. After a couple of calls that domain gets blocked and thus another one is selected instead. I added 17 domains, which should ensure that you will always have a domain that still works, because after about 1h that domain gets unblocked. Don't worry, you can still go to chrome and use the google translate :)
The tool works best with English language, since some others might have strange characters that might make things funny... I did see Portugese fail for some reason, might have to investigate later. Although I made sure that even if it fails, it continues and produces the subs, just they imght be misaligned...
Building
python setup.py sdist bdist_wheel
Debug
pip install -e .
- Where e is for editable
Then can perform building and after every build translatesubs
will get updated.
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
Built Distribution
Hashes for translatesubs-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b4dae47f5a3ad844100a0cc8a30ab858af16f5ff98e67777e661b02b4744092 |
|
MD5 | b869e1e11a6ba9c067fb1ffd7bd23f90 |
|
BLAKE2b-256 | 9ac6cce4ba9c21ecdbb61aa69fd8e1a9c7231e89d34b00a9b5629b3bf1357829 |