regulad / async-gTTS

Asynchronous interfaces to the official Google Text to Speech API written with aiohttp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

asyncgTTS

Asynchronous interfaces to the official Google Text to Speech API written with aiohttp.

Similar to googleapis/python-texttospeech in concept, but asyncgTTS was designed with asynchronously in mind and is expected to be more performant.

Example

import asyncio
import json

from asyncgTTS import AsyncGTTSSession, ServiceAccount


async def main():
    with open("SERVICE_ACCOUNT.JSON") as service_account_json:
        service_account_dict = json.load(service_account_json)
        
    service_account = ServiceAccount.from_service_account_dict(service_account_dict)
    
    async with AsyncGTTSSession.from_service_account(service_account) as google_tts:
        audio_bytes = await google_tts.synthesize("vine boom")

    with open("Hello_world.mp3", "wb") as f:
        f.write(audio_bytes)


asyncio.run(main())

About

Asynchronous interfaces to the official Google Text to Speech API written with aiohttp.

License:MIT License


Languages

Language:Python 100.0%