Skip to main content

Simple multi-language document translator in Python. A quick project.

·2 mins
Marc Alier
Author
Marc Alier
Personal homepage and miscellany.
Table of Contents

[Note: this post has been translated with my own translator] [Note: using the API has costs; the cost of use depends on the size of the documents. As a rough guide during development, tests and various translations of 2-page documents I spent 0.0.3€ over 5 days]

In this post I present a small project I’ve published as open source. What would once have been a project of 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.

Screenshot of GPT-Translate

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’s API; you can get one here: https://beta.openai.com/docs/developer-quickstart/api-key this program looks for the key in a file indicated by the “mykeypath” variable, by default at the path ‘..//..//mykey.json’

You need to have Python 3 installed on your system. I used Python 3.10

You need to install the json and openai packages

pip install openai

pip install json

On your system you might need to use pip3 instead of pip.

Usage
#

python3 gpt-traductor.py fitxer_origen idioma_origen idioma_destí fitxer_destí

Example

python3 gpt-translate.py sample.md català italià sample_translated.md

Have fun.

Related

Participation in a session on AI and teaching at UIC

On March 2, 2023, I took part in the session on AI chatbots in higher education organized by the Universitat Internacional de Catalunya UIC. At https://www.linkedin.com/events/sessi-sobrexatbotsd-intel-lig-n7034187811851235329/comments/ you can find the video of the event. Yours truly and his talk appear starting at 1h:25 minutes.

What ChatGPT Is and Isn't?

·10 mins
Contents # What is ChatGPT? ChatGPT is Software As A Service (SaaS) Terms and conditions Authorship rights and responsibility for ChatGPT’s outputs Cost and access What’s ChatGPT for and why is it free? ChatGPT isn’t open source Ethical aspects Ethical reflections from the creators of GPT-3 The ChatGPT Hype What is ChatGPT ? # ChatGTP is a web application based on GPT-3, specifically the GPT-3.5 “text-davinci-003” model developed by OpenAi. The ChatGPT model is optimized to work in conversational form, responding to inputs that users provide as a text “prompt”. ChatGPT is a type of Generative AI based on a Machine Learning Model . We can consider ChatGPT a weak AI (see Types of Artificial Intelligence].