gTTS icon indicating copy to clipboard operation
gTTS copied to clipboard

Progress bar?

Open arjunsavel opened this issue 4 years ago • 5 comments

Wondering if it'd be possible / worthwhile to implement a progress bar for converting especially large batches of text. Thanks for a great package!

arjunsavel avatar Nov 08 '20 18:11 arjunsavel

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

glokhoff avatar Nov 17 '20 11:11 glokhoff

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

pndurette avatar Nov 17 '20 15:11 pndurette

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)

glokhoff avatar Nov 17 '20 21:11 glokhoff

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.

ochen1 avatar Jan 25 '21 21:01 ochen1

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

ifeanyidotdev avatar Apr 12 '21 20:04 ifeanyidotdev