Giter Site home page Giter Site logo

justinwlin / chatgpt-for-translation-with-updated-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yuxuanxiu/chatgpt-for-translation-with-updated-api

1.0 0.0 0.0 32.22 MB

因为OpenAI更新了Python API,Raychanan大佬的ChatGPT-for-Translation暂时不可用了。本项目对ChatGPT-for-Translation中的API进行了更新,亲测可用。

License: MIT License

Python 100.00%

chatgpt-for-translation-with-updated-api's Introduction

ChatGPT for Translation | ChatGPT用于翻译

Use ChatGPT to complete document translations. This tool accepts a text file (.pdf, .txt, .md, .html, or .rtf) or a folder containing text files. It will generate both a direct translation and a bilingual text file. Special optimization has been done for parsing PDFs.

使用ChatGPT完成文件翻译。该工具接受一个文本文件(.pdf, .txt, .md, .html.rtf)或者一个包含文本的文件夹。它将生成一个直接翻译和一个双语文本文件。对于 PDF 解析做了优化。

Use this on Google Colab (recommended). See here

Google Colab上使用这个工具(推荐)。见这里

Example | 例子

# Install
git clone https://github.com/Raychanan/ChatGPT-for-Translation.git
cd ./ChatGPT-for-Translation/
pip install -r requirements.txt --quiet

# Run
python ChatGPT-translate.py --input_path=input.txt --openai_key=password

This command will translate the text in input.txt into simplified Chinese using ChatGPT. You can also specify any language you want. For example, --target_language="Traditional Chinese".

这个命令将使用ChatGPT把input.txt中的文本翻译成简体中文。你也可以指定任何你想要的语言。例如,--target_language="Traditional Chinese"

Translate All Files Within the Folder | 翻译文件夹内所有文本文件

python ChatGPT-translate.py --input_path=./folder_name/ --openai_key=password

Other Examples | 其它例子

Azure:

python ChatGPT-translate.py --input_path=input.pdf --use_azure --azure_endpoint=endpoint_uri --azure_deployment_name=deployment_name --openai_key=your_AOAI_key

GPT-4:

python ChatGPT-translate.py --input_path=input.txt --model=gpt-4 --openai_key=password

Virtual Environment Setup

Note:

Run: python --version to see if it is Python 3.6 or above. Run python3 --version to see if it is aliased under python3 instead.

If it is python3 then use python3 when creating the virtual environment.

First create virtual environment if it doesn't exist: (Use python3 here if needed.)

python -m venv venv

Second activate it:

source venv/bin/activate

Third install requirements.txt:

pip install -r requirements.txt

If necessary sometimes dependencies may have changed and no longer works. You can instead run:

pip install stable_requirements.txt

Prerequisites | 要求

OpenAI API key (https://beta.openai.com/signup/) or Azure

You need to link a payment method in the OpenAI API, otherwise you'll face extremely stringent API rate limits.

OpenAI API 里面要绑定支付方式,否则会有极其严苛的API速率限制.

Arguments | 可用参数

--num_threads: The number of threads to use for translation (default: 10).
--only_process_this_file_extension. For example, set only_process_this_file_extension="txt".
--not_to_translate_references. By default, not to translate references.

Acknowledge

The PDF parser is built on Grobid, a machine learning-driven PDF content extraction tool.

chatgpt-for-translation-with-updated-api's People

Contributors

justinwlin avatar yuxuanxiu avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.