This project is an AI-powered novel translator using OpenAI and DeepSeek APIs. It is designed to translate English novels into Russian (or any other language) while maintaining consistent terminology for character names, locations, skills, etc.
- Automated Novel Translation: Uses DeepSeek API to translate entire novels.
- Consistent Terminology: Ensures uniform translation of names and key terms using OpenAI API.
- Human-Translated Reference Parsing: Extracts terminology from human-translated chapters to improve accuracy.
- Custom Dictionary Management: Builds and updates a translation dictionary dynamically.
- FB2 Format Export: Converts translated chapters into an
.FB2file for easy reading.
.gitignore
env_example # Example of environment variables
demo/ # Directory with processed results
├── chapters_eng/ # Chapters ready for translation
├── chapters_rus/ # Human-translated chapters
├── chapters_translated/ # AI-translated chapters
├── raw_chapters_eng/ # Raw source text
├── raw_chapters_rus/ # Raw human-translated text
├── raw_chapters_translated/# Raw AI-translated text
├── word_translation_parser_responses/ # Translation dictionary per chapter
├── shadow_slave_1000_1004.fb2 # Final translated novel in FB2 format
├── translation_dict.json # Common terminology dictionary
└── translation_dict_short.json # Shortened version for prompt insertion
s1_p1_parse_chapters_raw_rus.py # Parses human-translated text into separate files
s1_p2_parse_chapters_raw_eng.py # Parses original text into separate files
s2_p1_parse_name_translations.py # Extracts and standardizes name translations
s2_p2_merge_translations.py # Processes name translation data
s3_p1_translate_chapters.py # Translates chapters and updates terminology dictionary
s4_p1_fb2_wrap.py # Converts translated chapters into an .FB2 file
- Clone the repository:
git clone <repository_url> cd <repository>
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
- Copy
env_exampleto.envand fill in required API keys.
- Copy
- Place raw English and Russian chapters into
raw_chapters_eng/andraw_chapters_rus/respectively. - Run parsing scripts:
python s1_p1_parse_chapters_raw_rus.py python s1_p2_parse_chapters_raw_eng.py
- Extract and standardize name translations:
python s2_p1_parse_name_translations.py
- Merge and clean translation data:
python s2_p2_merge_translations.py
- Translate the novel:
python s3_p1_translate_chapters.py
- Create
.FB2file for reading:python s4_p1_fb2_wrap.py
Pull requests are welcome! For personal use. No plans to maintain this repo.
MIT License.