gTTS
gTTS copied to clipboard
Progress bar?
Wondering if it'd be possible / worthwhile to implement a progress bar for converting especially large batches of text. Thanks for a great package!
Well, I'm not sure that would still be useful, as I'm noticing that since I installed version 2.2.0 I can only get short sentences transferred into speech. The system crashes on long texts...
converting file testtext.txt into testtext.mp3
Traceback (most recent call last):
File "/home/pi/Python3/TTS/txttodir.py", line 115, in
Well, I'm not sure that would still be useful, as I'm noticing that since I installed version 2.2.0 I can only get short sentences transferred into speech. The system crashes on long texts...
converting file testtext.txt into testtext.mp3
Traceback (most recent call last):
File "/home/pi/Python3/TTS/txttodir.py", line 115, in
main()
File "/home/pi/Python3/TTS/txttodir.py", line 110, in main
convert_files(fromdir, todir)
File "/home/pi/Python3/TTS/txttodir.py", line 77, in convert_files
tts.save(os.path.join(todir, mp3file)) # save as .mp3 file
File "/home/pi/.local/lib/python3.5/site-packages/gtts/tts.py", line 311, in save
self.write_to_fp(f)
File "/home/pi/.local/lib/python3.5/site-packages/gtts/tts.py", line 293, in write_to_fp
raise gTTSError(tts=self, response=r)
gtts.tts.gTTSError: 200 (OK) from TTS API. Probable cause: Unknown
Yes, known issue that was quickly fixed in 2.2.1! See #252
Thanks, I didn't see that yet... Have changed my code in the meantime, so it sends short texts snippets anyhow. That doesn't hurt anyway, so will stick with that. But did upgrade to 2.2.1 now. So I guess a progress bar could be useful after all ;o)
I would recommend breaking up the large piece of text into smaller chunks, such as by sentences or paragraphs.
Then, it should be simple to implement rich's progressbar feature with the context manager they provide.
it will be good to return a progress bar so you can see the state your conversion is in, in-case you want to display it for the user to see