aedocw / epub2tts-edge

epub2tts-edge uses Microsoft Edge cloud-based TTS to create a full featured audiobook m4b from an epub or text file
GNU General Public License v3.0
95 stars 15 forks source link

Remove triple exclamation and question marks #29

Closed erfansamandarian closed 4 months ago

erfansamandarian commented 4 months ago

Fix for https://github.com/aedocw/epub2tts-edge/issues/28

erfansamandarian commented 4 months ago

It feels like a sin doing a PR for only two lines of code...

aedocw commented 4 months ago

I like your approach, but I would suggest making the substitution later on, while doing the TTS rather than during the export. This way if someone is going straight from text, it will still catch/fix the issue, rather than relying on the multiple punctuation to be caught during export from epub to text.

You could basically move your two lines down to line 362 inside the async loop inside parallel_edgespeak. I think this would work:

            async with semaphore:
                loop = asyncio.get_running_loop()
                sentence = re.sub(r'[!]+', '!', sentence)
                sentence = re.sub(r'[?]+', '?', sentence)
                task = loop.run_in_executor(executor, run_edgespeak, sentence, speaker, filename)
                tasks.append(task)
aedocw commented 4 months ago

Looks great, thanks!

friki67 commented 4 months ago

Thank you!