aedocw / epub2tts

Turn an epub or text file into an audiobook
Apache License 2.0
433 stars 43 forks source link

failed at the end #152

Closed rejuce closed 6 months ago

rejuce commented 6 months ago

almost convertetd the whole ebook...but right at the end

100%|███████████████████████████████████████████████████████████████████████████████████| 49/49 [11:29<00:00, 14.07s/it] Replacing silences longer than one second with one second of silence (myepub-21.flac) 100%|█████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 53.75it/s] 99.46% spoken so far. Elapsed: 388 minutes, ETA: 2 minutes 0%| | 0/2 [00:00<?, ?it/s]Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (1 retries left) Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (0 retries left) Something is wrong with the audio (97): temp0.wav 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/jk/epub2tts/epub2tts.py", line 665, in main() File "/home/jk/epub2tts/epub2tts.py", line 654, in main mybook.read_book( File "/home/jk/epub2tts/epub2tts.py", line 446, in read_book temp = AudioSegment.from_wav(tempwav) File "/home/jk/.local/lib/python3.10/site-packages/pydub/audio_segment.py", line 808, in from_wav return cls.from_file(file, 'wav', parameters=parameters) File "/home/jk/.local/lib/python3.10/site-packages/pydub/audio_segment.py", line 651, in from_file file, close_file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False) File "/home/jk/.local/lib/python3.10/site-packages/pydub/utils.py", line 60, in _fd_or_path_or_tempfile fd = open(fd, mode=mode) FileNotFoundError: [Errno 2] No such file or directory: 'temp0.wav'

I tried to run it again...and it finds all them fragments...but fails again at the very end ... Elapsed: 0 minutes, ETA: 0 minutes myepub-19.flac exists, skipping to next chapter 92.35% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes myepub-20.flac exists, skipping to next chapter 93.56% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes myepub-21.flac exists, skipping to next chapter 99.46% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes 0%| | 0/2 [00:00<?, ?it/s]Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (1 retries left) Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (0 retries left) 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/jk/epub2tts/epub2tts.py", line 665, in main() File "/home/jk/epub2tts/epub2tts.py", line 654, in main mybook.read_book( File "/home/jk/epub2tts/epub2tts.py", line 443, in read_book f"Something is wrong with the audio ({ratio}): {tempwav}" UnboundLocalError: local variable 'ratio' referenced before assignment

rejuce commented 6 months ago

myepub.epub.txt

here the epub remove the ending for reference

aedocw commented 6 months ago

This looks a lot like https://github.com/aedocw/epub2tts/issues/133, which we were not able to reliably reproduce.

Could you try re-running but this time add "--minratio 0 --debug" - this will skip the part where it uses whisper to transcribe the audio file and try to compare that to the original text. It might still fail, but it might fail in a different way this time.

rejuce commented 6 months ago

nope same... python3 /home/jk/epub2tts/epub2tts.py ~/epubconvert/myepub.epub --engine xtts --speaker "Badr Odhiambo" --minratio 0 --debug

myepub-20.flac exists, skipping to next chapter 93.56% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes myepub-21.flac exists, skipping to next chapter 99.46% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes 0%| | 0/2 [00:00<?, ?it/s]text to read: Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (1 retries left) text to read: Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (0 retries left) 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/jk/epub2tts/epub2tts.py", line 681, in main() File "/home/jk/epub2tts/epub2tts.py", line 670, in main mybook.read_book( File "/home/jk/epub2tts/epub2tts.py", line 456, in read_book f"Something is wrong with the audio ({ratio}): {tempwav}" UnboundLocalError: local variable 'ratio' referenced before assignment

aedocw commented 6 months ago

Weird! Ok could you try one more thing, delete the file myepub-21.flac and run again, see what happens? I’ll try with the epub you shared when I get to a computer later today.

On Tue, Jan 2, 2024 at 2:16 PM rejuce @.***> wrote:

nope same... python3 /home/jk/epub2tts/epub2tts.py ~/epubconvert/myepub.epub --engine xtts --speaker "Badr Odhiambo" --minratio 0 --debug

myepub-20.flac exists, skipping to next chapter 93.56% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes myepub-21.flac exists, skipping to next chapter 99.46% spoken so far. Elapsed: 0 minutes, ETA: 0 minutes 0%| | 0/2 [00:00<?, ?it/s]text to read: Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (1 retries left) text to read: Error: You need to define either text (for sythesis) or a reference_wav (for voice conversion) to use the Coqui TTS API. ... Retrying (0 retries left) 0%| | 0/2 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/jk/epub2tts/epub2tts.py", line 681, in main() File "/home/jk/epub2tts/epub2tts.py", line 670, in main mybook.read_book( File "/home/jk/epub2tts/epub2tts.py", line 456, in read_book f"Something is wrong with the audio ({ratio}): {tempwav}" UnboundLocalError: local variable 'ratio' referenced before assignment

— Reply to this email directly, view it on GitHub https://github.com/aedocw/epub2tts/issues/152#issuecomment-1874631418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFBJGJEWNV4GT2R6Y2UE3TYMSBNHAVCNFSM6AAAAABBKKY742VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGYZTCNBRHA . You are receiving this because you commented.Message ID: @.***>

aedocw commented 6 months ago

Good news! or Bad news! - either way, I was able to recreate this:

ᐅ epub2tts books/myepub.epub --engine xtts --speaker "Badr Odhiambo" --start 20 --minratio 0
[...]
93.00% spoken so far.
Elapsed: 17 minutes, ETA: 1 minutes
  0%|                                                                                                                    | 0/2 [00:00<?, ?it/s]Error: You need to define either `text` (for sythesis) or a `reference_wav` (for voice conversion) to use the Coqui TTS API. ... Retrying (1 retries left)
Error: You need to define either `text` (for sythesis) or a `reference_wav` (for voice conversion) to use the Coqui TTS API. ... Retrying (0 retries left)
Something is wrong with the audio (0): temp0.wav
  0%|                                                                                                                    | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/doc/.local/bin/epub2tts", line 8, in <module>
    sys.exit(main())
  File "/home/doc/.local/lib/python3.10/site-packages/epub2tts.py", line 670, in main
    mybook.read_book(
  File "/home/doc/.local/lib/python3.10/site-packages/epub2tts.py", line 462, in read_book
    temp = AudioSegment.from_wav(tempwav)
  File "/home/doc/.local/lib/python3.10/site-packages/pydub/audio_segment.py", line 808, in from_wav
    return cls.from_file(file, 'wav', parameters=parameters)
  File "/home/doc/.local/lib/python3.10/site-packages/pydub/audio_segment.py", line 651, in from_file
    file, close_file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False)
  File "/home/doc/.local/lib/python3.10/site-packages/pydub/utils.py", line 60, in _fd_or_path_or_tempfile
    fd = open(fd, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'temp0.wav'

I'll keep poking at this and figure out what is going on, this one is pretty weird, glad you found it!

aedocw commented 6 months ago

Found it! Somehow a completely empty item ends up in the list of sentences to speak. Then TTS chokes when it tries to do something with it (which is pretty reasonable). Adding a test that skips that loop if the length of that sentence is 0 fixes this. I'm pretty certain this was what happened with https://github.com/aedocw/epub2tts/issues/133 as well.

Tested the fix, and will be merging it shortly.