Easy async interface to easy-gtts-api
Project description
py-easygTTS
Asynchronous interface to an easy-gtts server written with aiohttp.
One class currently exists, easygTTS.gtts, which takes 2 optional args base_url (url to a easy-gtts server) and session (aiohttp.ClientSession)
Examples
One time use
import easygTTS
import asyncio
async def main():
async with easygTTS.gtts() as gtts:
hello_uk = await gtts.get(text="Hello World", lang="en-uk")
hello_usa = await gtts.get(text="Hello World", lang="en-us")
langs = await gtts.langs()
with open("Hello World (UK).mp3", "wb") as f:
f.write(hello_uk)
with open("Hello World (USA).mp3", "wb") as f:
f.write(hello_usa)
print(f"Returned langs = {langs}")
asyncio.run(main())
Using a global session
import easygTTS
import asyncio
import aiohttp
async def main():
session = aiohttp.ClientSession()
gtts = easygTTS.gtts(session=session)
hello = await gtts.get(text="Hello World")
with open("Hello.mp3", "wb") as f:
f.write(hello)
# later in your code
extra = await gtts.get(text="even more to TTS")
with open("Extra.mp3", "wb") as f:
f.write(extra)
# at the end
await session.close()
asyncio.run(main())
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
easygTTS-1.0.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easygTTS-1.0.tar.gz.
File metadata
- Download URL: easygTTS-1.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d47f66a1db1337980798ec2cd5c4d37e2f729bb3f670dd031975a915b890839
|
|
| MD5 |
0d90df945de5dcee6c8854e278c609f4
|
|
| BLAKE2b-256 |
ebd28ed99b2739787d0168505867bdb88823a0be29dae0d2fdc504c2158f9513
|
File details
Details for the file easygTTS-1.0-py2.py3-none-any.whl.
File metadata
- Download URL: easygTTS-1.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21e552398e696ebfffd51833d2d47491446e5731fff2cd49b1bec51b10422803
|
|
| MD5 |
e6e19a9f490361fa38de89051060a5c7
|
|
| BLAKE2b-256 |
de72fbd9fc1f931df440fbc9c79398b22f627512fc1bef6b580cdf14dcf4e41c
|