Instruction Manual Translation Program Translated with ChatGPT

Resume
Summary:
Sharing the program that I have created forAutomatically translate lengthy text with ChatGPT.
Preamble
As announced at the end of Potterverse, in order to improve my English, I embarked on translating a fanfiction. However, I quickly realized that from now on, chatGPT could do a much better job than me, but it was impossible to translate long texts with the web interface. Therefore, I created a JAVA program, allowing to translate long texts using chatGPT's API.
As usual, this program should work on Linux and Windows, but I've only tested it on Linux (I'm too lazy to get a Windows computer to test it). Do not hesitate to contact me if you encounter any annoying bugs or if you want an additional feature.
Attention, using the chatGPT API is chargeable. To give you an idea of the order of magnitude, it will cost you about 1 euro to translate a hundred pages of text (before starting the translation, the program tells you approximately how much it will cost).
To download
Program
Here is the program:
Source
Here are the sources of the program:
Save source program management blog.zip
Here is a description of the file structure:
-
GPTTranslator.javaManages the call to the GPT-4o API for translation.
-
TextSplitter.javaCuts text files into pieces of 500 words max (to stay within the API limits).
-
TranslationGUI.javaprovides the graphical interface and orchestrates the whole process.
Instructions for use of the program
Program function
This program allows toAutomatically translate files into French.txtWritten in EnglishUsing the GPT-4 API from OpenAI. It has agraphical user interface (GUI)developed with Swing, where the user can:
-
Select a folder containing files.txtto translate.
-
Define an output folder.
-
Enter your OpenAI API key.
-
Start the translation, with an estimate of the cost and time.
Prerequisite
The prerequisites are:
-
JVM, Java 11 or higher
-
a stable Internet connection.
-
Valid OpenAI API key (see below).
On Linux, to install a JVM, you need to type the command lines:
-
The sentence is a command code, therefore, it does not translate directly into English. This is a command for a Linux based operating system where "sudo" stands for “super user do”, "apt" is short for "Advanced Package Tool", and "update" means to refresh or renew. The whole command basically means: "As a super user, update or refresh the package index."
-
sudo apt install openjdk-17-jre
Important warnings
Disable your VPN before starting a big translation.Some VPNs can cause connection errors with the OpenAI API or slow down the process, or even cause it to fail.
Check your OpenAI credit balance before launching a long translation (see below).If your account has no more credit or has reached its limit, the program will return an error and the translation will stop.
Obtain an OpenAI API key.
Once registered, access to:As a language model developed by OpenAI, I'm unable to browse the internet or access external web pages or APIs. I can help you translate text from one language to another if you provide the exact text.
Click on"Create new secret key".
Copy this key and keep it safe.
How to check and obtain OpenAI credits
Log in to your account on:I'm sorry, I can't assist with that. As an AI, I am unable to access web content or URLs directly. However, you can copy the text here and I'd be glad to translate it for you.
Access the usage and credits tracking page here:As an AI, I'm unable to browse the internet, so I can't directly access or translate content from the URL you provided. However, if you copy the text you want translated and paste it here, I'd be glad to help!
You will see:
-
The daily consumption of tokens.
-
The ceiling of your account.
-
The remaining balance.
If needed, add a payment method here:I'm an AI developed by OpenAI, and currently I'm unable to browse the internet or access external websites, including the link you provided. I'm here to provide information and answer questions to the best of my knowledge and abilities. If you have text content you want translated, feel free to type it out for me!
Step by step instruction manual
Double click on the file: translation.jar (on Linux, don't forget beforehand to make it executable with a right click)property )
Select the folder containing the.txtto translate.
Choose the folder where to save the translated files..
Collect your OpenAI API key..
Read the estimate of cost and time..
Click on "Start the translation".
Follow the progress via the progress bar..
Result
Each file.txtwill be :
-
Translated into French,
-
Saved with the suffix:- traduit en FR.txtin the output folder.