llsub
is a Python script that helps language learners by generating dual-language subtitles. It takes an original SRT subtitle file and translates it to the target language. The translated and original subtitles are then merged line-by-line to assist in language learning.
Specifically, the original language is displayed on the top line and translation is displayed afterward in parenthesis. This means that while watching, you can read the original language and then check your understanding by reading the translation.
For best results, ensure that the original subtitle file you are translating is a native translation of the original audio. It should not be a computer generated transcript or translation.
- Translates an SRT subtitle file to a target language.
- Optionally merges the original and translated subtitles.
-
Make sure Python 3.x is installed.
-
Install required Python packages in a virtual environment:
python3 -m venv llsub-env source llsub-env/bin/activate # On Windows, use `llsub-env\Scripts\activate` pip install -r requirements.txt
You can also install llsub
as a Python package for system-wide usage:
-
Clone the repository and navigate to the directory.
git clone https://github.com/watkins-matt/llsub.git cd llsub
-
Install the package.
pip install .
-
You can now use
llsub
from anywhere:llsub [--translate-only] input_file [target_language]
To run the script, you can use the following command:
python llsub.py [-h] [-f] [--translate-only] input_file [target_language]
--translate-only
: Translate the input file only, do not generate merged subtitles.-f, --force
: Forcibly overwrites an existing dual language subtitle file if present.input_file
: Path to the input SRT file. Required.target_language
: Target language for translation. Default isen
.
For example:
python llsub.py "Episode Name S01E01.sv.srt" en