Home

Awesome

ebook-GPT-translator: Enjoy reading with your favorite style.

En | 中文说明

This tool is designed to help users convert text from one format to another, as well as translate it into a different language using the OpenAI API (model="gpt-3.5-turbo"). It currently supports converting and translating PDF, DOCX, EPUB, and MOBI file formats into EPUB and text files and can translate text into multiple languages.

Notes:

Installation

To use this tool, you will need to have Python 3 installed on your system, as well as the following packages:

You can install these packages by running the following command:

pip install -r requirements.txt

git clone

git clone https://github.com/jesselau76/ebook-GPT-translator.git

Update to new version

cd ebook-GPT-translator
git pull
pip install -r requirements.txt

Usage

To use this tool, you need rename settings.cfg.example to settings.cfg at first.

cd ebook-GPT-translator
mv settings.cfg.example settings.cfg
nano settings.cfg
openai-apikey = sk-xxxxxxx

replace sk-xxxxxxx to your OpenAI api key (or sk-xxxxxxx,sk-xxxxxxx if you have more than one key). Change others options then press CTRL-X to save.

run the command:

python text_translation.py [-h] [--test] filename

positional arguments:
  filename    Name of the input file

options:
  -h, --help  show this help message and exit
  --test      Only translate the first 3 short texts
  --tlist     Use the translated name table

Simply run the text_translation.py script with the file you want to translate or convert as an argument. For example, to translate a PDF file named example.pdf, you would run the following command:

python text_translation.py example.pdf

or to translate a epub file named example.epub, you would run the following command:

python text_translation.py example.epub

or to translate a docx file named example.docx, you would run the following command:

python3 text_translation.py example.docx

or to translate a text file named example.txt, you would run the following command:

python text_translation.py example.txt

to translate a MOBI file named example.mobi, you would run the following command:

python text_translation.py example.mobi

By default, the script will attempt to translate the text into the language specified in the settings.cfg file under the target-language option. You can also choose to output a bilingual version of the text by setting the bilingual-output option to True.

Feature

Configuration

The settings.cfg file contains several options that can be used to configure the behavior of the script:

Output

The output of the script will be an EPUB file with the same name as the input file, but with _translated appended to the end. For example, if the input file is example.pdf, the output file will be example_translated.epub and example_translated.txt.

License

This tool is released under the MIT License.

Disclaimer:

This project is intended for use with public domain books and materials only. It is not designed for use with copyrighted content. Users are strongly advised to carefully review copyright information before utilizing this project and to adhere to relevant laws and regulations in order to protect their own rights and the rights of others.

The authors and developers of this project shall not be held responsible for any loss or damage resulting from the use of this project. Users assume all risks associated with its use. It is the responsibility of users to ensure they have obtained permission from the original copyright holder or used open-source PDF, EPUB, or MOBI files before employing this project to avoid potential copyright risks.

If you have any concerns or suggestions about the use of this project, please contact us through the issues section.