pndurette / gTTS

Python library and CLI tool to interface with Google Translate's text-to-speech API
http://gtts.readthedocs.org/
MIT License
2.31k stars 362 forks source link

Add support asyncio #228

Open Accipiter7 opened 4 years ago

Accipiter7 commented 4 years ago

Since this is network dependent library it should support async / await for non-blocking access and Hence for better concurrency. Thanks

pndurette commented 4 years ago

Indeed! Part of ripping out Python 2 support too..

thedaynos commented 4 years ago

I needed to use gtts in an async type of way so I set up a queue and a separate python script that only reads text messages from the queue and then calls gtts. That's all it does. Just loops until a message is received and then calls/plays.

JDJGInc commented 3 years ago

I agree with this, plus it makes work better with discord bots.

jacksbox commented 1 year ago

+1 would be super useful in todays async/await world

CDE90 commented 2 months ago

Hey guys, recently for a discord bot I work on, I've forked gTTS to add experimental support for async / await. Feel free to have a look and use it if you want, just be aware that I have not tested it that extensively and I'm not going to be doing any extra work on it other than if I find a critical bug myself. Also just FYI, a significant portion of the async code was generated by AI to convert it from sync to async but it all seems to work.

https://github.com/CDE90/gTTS https://github.com/CDE90/gTTS/blob/main/gtts/tts_async.py

pndurette commented 2 months ago

Ah nice! I'll check it out. Also appreciate the gen AI disclosure! 😝

I wanted to do lots of clean up to that stream function anyway.

JDJGInc commented 2 months ago

I would love if this library had async libraries based with aiohttp. as the aiogtts package is a bit blocking because it uses b8.