Skip to content

Latest commit

 

History

History
 
 

openai-translator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

OpenAI-Translator


English | 中文

All the code and documentation are entirely generated by OpenAI's GPT-4 Model

Introduction

OpenAI Translator is an AI-powered translation tool designed to translate English PDF books to Chinese. The tool leverages large language models (LLMs) like ChatGLM and OpenAI's GPT-3 and GPT-3.5 Turbo for translation. It's built in Python and has a flexible, modular, and object-oriented design.

Why this project

In the current landscape, there's a lack of non-commercial yet efficient PDF translation tools. Many users have PDF documents with sensitive data that they prefer not to upload to public commercial service websites due to privacy concerns. This project was developed to address this gap, providing a solution for users who need to translate their PDFs while maintaining data privacy.

Sample Results

The OpenAI Translator is still in its early stages of development, and I'm actively working on adding more features and improving its performance. We appreciate any feedback or contributions!

The_Old_Man_of_the_Sea

"The Old Man and the Sea"

Features

  • Translation of English PDF books to Chinese using LLMs.
  • Support for both ChatGLM and OpenAI models.
  • Flexible configuration through a YAML file or command-line arguments.
  • Timeouts and error handling for robust translation operations.
  • Modular and object-oriented design for easy customization and extension.
  • Add support for other languages and translation directions.
  • Implement a graphical user interface (GUI) for easier use.
  • Create a web service or API to enable usage in web applications.
  • Add support for batch processing of multiple PDF files.
  • Add support for preserving the original layout and formatting of the source PDF.
  • Improve translation quality by using custom-trained translation models.

Getting Started

Environment Setup

1.Clone the repository git clone [email protected]:DjangoPeng/openai-translator.git.

2.The OpenAI-Translator requires Python 3.10 or later. Install the dependencies with pip install -r requirements.txt.

3.Set up your OpenAI API key($OPENAI_API_KEY). You can either add it to your environment variables or specify it in the config.yaml file.

Usage

You can use OpenAI-Translator either by specifying a configuration file or by providing command-line arguments.

Using a configuration file:

Adapt config.yaml file with your settings:

model_name: "gpt-3.5-turbo"
input_file: "tests/test.pdf"
output_file_format: "markdown"
source_language: "English"
target_language: "Chinese"

Then run the tool:

python ai_translator/main.py

sample_out

Using command-line arguments:

You can also specify the settings directly on the command line. Here's an example of how to use the OpenAI model:

# Set your api_key as an env variable
export OPENAI_API_KEY="sk-xxx"
python ai_translator/main.py --model_name "gpt-3.5-turbo" --input_file "your_input.pdf" --output_file_format "markdown" --source_language "English" --target_language "Chinese"

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for details.