No project description provided
Project description
SimpleAITranslator
Overview
SimpleAITranslator is a Python library designed to identify the language of a given text and translate text between multiple languages using OpenAI's GPT-4. The library is especially useful for translating text containing multiple languages into a single target language.
Features
- Language Detection: Identify the language of a given text in ISO 639-3 format.
- Translation: Translate text containing multiple languages into another language in ISO 639-3 format.
Requirements
To use this library, you must have an OpenAI API key. This key allows the library to utilize OpenAI's GPT-4 for translation and language detection.
Installation
You can install the SimpleAITranslator library from PyPI:
pip install simpleaitranslator
Usage
Setting Up
Before using the library, set your OpenAI API key:
import os
import simpleaitranslator.translator
# Set your OpenAI API key
simpleaitranslator.translator.OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
# or directly
simpleaitranslator.translator.OPENAI_API_KEY = "<YOUR_OPENAI_API_KEY>"
Language Detection
To detect the language of a given text:
from simpleaitranslator.translator import get_text_language
print(get_text_language("Hello world")) # Output: 'eng'
Translation
To translate text containing multiple languages into another language:
from simpleaitranslator.translator import translate
print(translate("Cześć jak się masz? Meu nome é Adam", "eng")) # Output: "Hello how are you? My name is Adam"
Full Example
Here is a complete example demonstrating how to use the library:
import os
import simpleaitranslator.translator
from simpleaitranslator.translator import get_text_language, translate
# Set your OpenAI API key
simpleaitranslator.translator.OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
# Detect language
print(get_text_language("jak ty się nazywasz")) # Output: 'pol'
# Translate text
print(translate("Cześć jak się masz? Meu nome é Adam", "eng")) # Output: "Hello how are you? My name is Adam"
Supported Languages
SimpleAITranslator supports all languages supported by GPT-4. For a complete list of language codes, you can visit the ISO 639-3 website.
Here are some of the most popular languages and their ISO 639-3 codes:
- English (eng)
- Spanish (spa)
- French (fra)
- German (deu)
- Chinese (zho)
- Japanese (jpn)
- Korean (kor)
- Portuguese (por)
- Russian (rus)
- Italian (ita)
- Dutch (nld)
- Arabic (ara)
- Hindi (hin)
- Bengali (ben)
- Turkish (tur)
- Polish (pol)
- Swedish (swe)
- Norwegian (nor)
- Danish (dan)
- Finnish (fin)
- Greek (ell)
- Hebrew (heb)
Additional Resources
License
SimpleAITranslator is licensed under the MIT License. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for simpleaitranslator-0.1.25.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | de56f0d0c569a3d20ad3cd6fa5ad3017fbb9cc9695e4a23647d39c1dd7cea467 |
|
MD5 | a781faca0b9e0b61ee0cf25d70ded6bc |
|
BLAKE2b-256 | 3954bfa1983e92fc9f2d5e6444d025485ea5e13227ae58964bfca929851c5e5a |
Hashes for simpleaitranslator-0.1.25-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ea38916e8f1dd6983e9295d91b008984b577ea326c604a54f1cdbd80a83582d |
|
MD5 | 72a3caafe0435eb819435f29e17d6af5 |
|
BLAKE2b-256 | d99d9b71e9119740b70d3478bf8fbb39a8fba826548df85b6e67e131a4405174 |