Skip to main content

A Python3 library for translating text using Google Translate API.

Project description

gpytranslate

A Python3 library for translating text using Google Translate API.


Features

  • Both Synchronous and Asynchronous
  • Dot accessible values
  • Supports emoji
  • Type hinted
  • Free to use
  • Easy

Quick Start

Installation

Requirements:

  • Python 3.6 or higher.
$ python3 -m pip install -U gpytranslate

Usage

Async Example:

from gpytranslate import Translator
import asyncio


async def main():
    t = Translator()
    translation = await t.translate("Ciao come stai? Io bene ahah.", targetlang="en")
    language = await t.detect(translation.text)
    print(f"Translation: {translation.text}\nDetected language: {language}")


if __name__ == "__main__":
    asyncio.run(main())

Sync Example:

from gpytranslate import SyncTranslator

t = SyncTranslator()
translation = t.translate("Ciao come stai? Io bene ahah.", targetlang="en")
language = t.detect(translation.text)
print(f"Translation: {translation.text}\nDetected language: {language}")

Note: you could also check tests folder for extra examples.

Output:

Translation: Hello how are you? I'm fine, haha.
Detected language: en

Text to Speech

Async Example:

import asyncio, aiofiles
from gpytranslate import Translator

async def main():
    translator = Translator()
    async with aiofiles.open("test.mp3", "wb") as file:
        await translator.tts("Hello world!", file=file)

if __name__ == "__main__":
    asyncio.run(main())

Sync Example:

from gpytranslate import SyncTranslator

translator = SyncTranslator()

with open("test.mp3", "wb") as file:
    translator.tts("Hello world!", file=file)

Development

Want to contribute? Pull requests are accepted!


License

Licensed under the GNU GPLv3.

Click here for further information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpytranslate-1.2.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

gpytranslate-1.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file gpytranslate-1.2.0.tar.gz.

File metadata

  • Download URL: gpytranslate-1.2.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for gpytranslate-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ac542f1fa796d89f168a1063b865d81de699602a87dcd343544e7c5aca11182d
MD5 c7c499dc56c2181d28a2c60eea80ce33
BLAKE2b-256 9b9e6c48ceca11c1abd5e35cb80e25ce00de7d902dcc1a080dbe7b5c50ce7f1f

See more details on using hashes here.

File details

Details for the file gpytranslate-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: gpytranslate-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for gpytranslate-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e06dd6e022f82d60afb1a772cf7b50cc6bba02ffa4f192108f882a1cc02ff2f0
MD5 63fa84e8d0f15e3b2ae9c98e527edddc
BLAKE2b-256 3e02cf26ec53006c2c141104fc2210d31a5d89a66d7fa3f762c5096df00b6b55

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page