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
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())
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
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())
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 MIT License.
Click here for further information.
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
gpytranslate-1.3.0.tar.gz
(6.8 kB
view details)
Built Distribution
File details
Details for the file gpytranslate-1.3.0.tar.gz
.
File metadata
- Download URL: gpytranslate-1.3.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 767b9085818b70edacfb85a358661929686e2e31deb1618f7856388076db7407 |
|
MD5 | 435c0b2582bba984f159d086a9d18ff3 |
|
BLAKE2b-256 | 86ab5d16734c74c5483694c360db82ae02de8ab7bee0423cd7e73d8d65abef6a |
File details
Details for the file gpytranslate-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: gpytranslate-1.3.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 789483dbc6acfe181bf01de3b30f9a5979fd072a91e4f35ffcb5e808b018ea4b |
|
MD5 | 9d95bd7f0e9fd1425d3a6be4c260c461 |
|
BLAKE2b-256 | 311aa00b0c0d088aecb2ccf224a7d5139461584cde9b3b48a8398f2decfa639e |