[Feature request] Allow the use of logging
instead of print
#3729
Labels
feature request
feature requests for making TTS better.
wontfix
This will not be worked on but feel free to help.
🚀 Feature Description
The
print
function is in several places, most noticeably (to me) is inutils.synthesizer.Synthesizer.tts
, with lines like:This is great when messing around, but it'd be nice to have the option to use different types of loggers (or even just the root). For instance, if I have a distributed application, I can have this writing to something that would send the messages through a pubsub setup so that another application may read and interpret the output in real time.
Solution
utils.synthesizer.Synthesizer
's signature can be changed to look like:and the
tts
function can look like:A
Protocol
for the logger might work better than just the hint oflogging.Logger
- it'd allow programmers to put in some wackier functionality, such as writing non-loggers that just so happen to have a similar signature.Alternative Solutions
An alternative solution would be to pass the writing function to
tts
itself, something like:This will enable code like:
Additional context
I don't believe that
utils.synthesizer.Synthesizer.tts
is the only location of the standardprint
function. A consistent solution should be applied there.The parameter for the logging functionality will need to be passed through objects and functions that lead to the current
print
statements. For instance,TTS.api.TTS.tts_to_file
would require alogging_function
parameter if it were to the function toself.synthesizer.tts
within thetts
function.The general vibe of the solutions I've provided will make sure that pre-existing code behaves no different, making the new functionality purely opt-in.
I haven't written anything using a progress bar like the one that this uses, so I can't speak up for that aside from the fact that it might need to be excluded.
The text was updated successfully, but these errors were encountered: