[Note: using OpenAI’s API has its costs. The cost of using the translator will depend on the size of the documents you translate. As a guideline, so far with development, tests, and translating a few documents I’ve spent €0.03. ]
In this post I present a small project I’ve released as open source. What would once have been a project taking many years and several million euros is now a small experiment done on a Saturday morning. The keys are GitHub Copilot, ChatGPT 4 as programming assistants, and the GPT-3.5 Turbo API.

gpt-translator#
You can download it from https://github.com/granludo/gpt-test/tree/main/file-trasnlator
Licensed under the GNU General Public License v3.0
Simple Python 3 program that uses OpenAI’s GPT-3.5-turbo model to translate files from one language to another. It splits the file into 20-line chunks.
Requirements#
You need an API key to use OpenAI. You can get one here: https://beta.openai.com/docs/developer-quickstart/api-key this program looks for the key in a file indicated in the variable “mykeypath” by default at the path ‘..//..//mykey.json’
You need to have Python 3 installed on your system. I’ve used Python 3.10
You need to install the json and openai packages
pip install openai
pip install json
On your system you may need to use pip3 instead of pip.
Usage#
python3 gpt-traductor.py archivo_origen idioma_origen idioma_destino archivo_destinoExample
python3 gpt-translate.py sample.md catalan italian sample_translated.md
Have fun.
