playht / pyht

PlayHT Python SDK - AI Text-to-Speech Streaming & Voice Cloning API
https://play.ht/
Apache License 2.0
178 stars 23 forks source link

Adds asyncio.to_thread compatibility for python 3.8. #30

Closed NCarrollPlay closed 9 months ago

NCarrollPlay commented 9 months ago

The only thing I think could affect readability is the declaration of to_thread (and its imports) under a conditional logic. I would have the conditional implemented under to_thread instead, and move the imports to the file header. But this is really just a coding styling thing, so feel free to do what feels natural for you 😄

Yeah, I didn't want to litter the top level with imports that won't get used by the majority of our clients. So if I move the conditional inside a function call (with the imports), then it will effectively lazy import on the first call, which could lead to a perf drop on the first pass.