Introducing the srt-GPT-Translator Project
The srt-GPT-Translator project is a powerful tool that leverages the capabilities of OpenAI's API, specifically the "gpt-3.5-turbo" model, to translate SRT subtitle files into different languages. This tool is particularly useful for individuals or businesses seeking to create bilingual subtitles with ease.
Key Features
One of the standout features of this tool is its ability to maintain the context of translations by using multiple subtitle blocks, each not exceeding 1024 characters. This helps ensure a smooth flow of dialogue and context within the translated output. Furthermore, the tool is equipped with a robust mechanism to verify translation results. If the translated text does not align with the format of the original text, it will attempt to re-translate it up to three times. Should the translation remain incorrect, the original short text for that section is preserved.
Installation Guide
To get started with the srt-GPT-translator, users must have Python 3 installed on their systems. A set of necessary packages is also required, which can be easily installed using the following command:
pip install -r requirements.txt
Once these prerequisites are in place, the tool can be cloned from its GitHub repository:
git clone https://github.com/jesselau76/srt-gpt-translator.git
For updating to a new version, navigate into the project directory and run:
cd srt-gpt-translator
git pull
pip install -r requirements.txt
How to Use
Before using the tool, users must configure it by renaming settings.cfg.example
to settings.cfg
. This step involves personalizing the configuration file with an OpenAI API key and other necessary options. Here is how it is done:
cd srt-gpt-translator
mv settings.cfg.example settings.cfg
nano settings.cfg
In the configuration file, replace sk-xxxxxxx
with the actual OpenAI API key. Adjust other settings as needed, then save the changes.
To translate a subtitle file, users simply run the srt_translation.py
script with the name of the file as an argument. For instance:
python3 srt_translation.py example.srt
The script translates the subtitles into the target language specified in the settings.cfg
file.
Additional Features
The configuration file contains options such as the API key and target language (e.g., English, Chinese, Japanese). Additionally, the tool offers a progress bar for translation and a test function to translate only three short sections for testing, conserving API usage.
Output
For each translation run, the output consists of two files:
- A translated SRT file with
_translated
appended to its name. - A bilingual subtitle SRT file with
_translated_bilingual
added to its name.
License and Disclaimer
The srt-GPT-translator is licensed under the MIT License, making it freely available for use. However, it is important to note the disclaimer: the accuracy and reliability of translations depend on the OpenAI model, and users are encouraged to verify translations independently.
For further inquiries or suggestions, users are directed to reach out via the issues section of the project.
By making subtitle translations more accessible, the srt-GPT-translator project stands as an invaluable tool for enhancing communication and content accessibility across language barriers.