aedocw / epub2tts

Turn an epub or text file into an audiobook
Apache License 2.0
445 stars 44 forks source link

Replace double spaces in the final combined sentence #117

Closed martinmildner closed 7 months ago

martinmildner commented 7 months ago

The use of the sample.txt text reveals that double spaces sometimes occur when combining sentences. To prevent this, we should remove them.

Before: ['This script takes an epub (or text file) and reads it to an m4b audiobook file,DoubleSpaceusing TTS by Coqui or OpenAI.',

After: ['This script takes an epub (or text file) and reads it to an m4b audiobook file, using TTS by Coqui or OpenAI.',

aedocw commented 7 months ago

Does the double-space have any impact on the speech synthesis? I appreciate the PR, but I'm wondering if this has any impact.

martinmildner commented 7 months ago

Hmm, I tested it with a few voices. Some had a longer pause, others did not. For example, 307 doesn't care...

aedocw commented 7 months ago

Interesting! My belief had been that whitespace was generally ignored, but I have not spent any time validating that. I'll try to do some tests of my own later this week and will note what I find here.

aedocw commented 7 months ago

I had a chance to do some tests with and without whitespace, using the following:


a lot    of   unnecessary   white   space.```
and
```This is an example of text with no unnecessary white space.
I wonder if it will sound any different.```
I ran them each with no options (so using default VITS p335 speaker), and with XTTS using a fine-tuned voice I have used for several books. I could not detect any difference between the samples, so I don't think this is necessary.

I do want to say though I really appreciate you submitting the PR and making an effort to improve things! Also if you have an example you can share that reliably produces longer pauses or any other unusual behavior please share and I'll do my best to replicate your findings.