aedocw / epub2tts

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

chapter markers become offset after removing silence #108

Closed danielw97 closed 7 months ago

danielw97 commented 7 months ago

Back again with another issue I'm afraid. Although this is quite minor in the grand scheme of things, I've noticed that the chapter markers in m4b audiobooks become more offset throughout the book. It seems to me as though they are ahead in time, so this makes me suspect that the chapter breaks need to be re-calculated after silence is removed as the initial flacs are fine. Let me know if there's any info I can provide on this.

aedocw commented 7 months ago

YEEEEEEESSSSS!!!!! Thank you for finding this one!!!

I have the script removing silences as the last step, as all the files are combined into the final .m4a. But then to build the metadata which checks for the length of each file, I'm checking the original chapter flac files which do not have the silences replaced/normalized. To fix this, I just have to move the remove silence part up so it happens for each chapter.

Finding this one is a huge weight off for me - I've noticed on the last two books I did the final chapter ends up being listed at like 900 hours long on my phone! I was going down a totally wrong path to try to figure out what was going on, but this was the obvious culprit. Great catch!!

aedocw commented 7 months ago

First pass worked fine with vits, but failed with xtts, which is pretty odd... (noting here in case I get pulled away before I can fix whatever I did wrong)

  File "/home/doc/repos/epub2tts/epub2tts.py", line 354, in read_book
    position += len(self.chapters_to_read[i])
IndexError: list index out of range
aedocw commented 7 months ago

This branch seems to be working fine, but discovered what looks like a new bug. If I specify --start 1 there's an index offset problem. Will log that as a new bug.

aedocw commented 7 months ago

Had to revert the merge, still something wrong with what I merged. Re-opening this bug until I can merge the fix for silence removal.

aedocw commented 7 months ago

UGH, when I moved the silence removal loop into a different for loop, I did not catch that I was using "i" for the index. The inner loop overwrote the index position for the out one. Pushed the fix up into this branch and am doing a few different test runs before merging, but I think this is sorted now.

aedocw commented 7 months ago

Fixed in more-bad-timing branch, and merged to main.