aedocw / epub2tts

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

Text files with chapter breaks not working #187

Closed aedocw closed 6 months ago

aedocw commented 6 months ago

A text file with the attached contents fails during processing, mistakenly thinking there are 5 chapters to be read rather than three.

testing.txt

The error is:

Traceback (most recent call last):
  File "/Users/doc/repos/epub2tts/.venv/bin/epub2tts", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/doc/repos/epub2tts/.venv/lib/python3.11/site-packages/epub2tts.py", line 757, in main
    mybook.read_book(
  File "/Users/doc/repos/epub2tts/.venv/lib/python3.11/site-packages/epub2tts.py", line 534, in read_book
    chunks = split_on_silence(
             ^^^^^^^^^^^^^^^^^
  File "/Users/doc/repos/epub2tts/.venv/lib/python3.11/site-packages/pydub/silence.py", line 150, in split_on_silence
    in detect_nonsilent(audio_segment, min_silence_len, silence_thresh, seek_step)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/doc/repos/epub2tts/.venv/lib/python3.11/site-packages/pydub/silence.py", line 86, in detect_nonsilent
    silent_ranges = detect_silence(audio_segment, min_silence_len, silence_thresh, seek_step)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/doc/repos/epub2tts/.venv/lib/python3.11/site-packages/pydub/silence.py", line 19, in detect_silence
    seg_len = len(audio_segment)
              ^^^^^^^^^^^^^^^^^^
TypeError: object of type 'int' has no len()