Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #277

Closed
AJolly opened this issue Nov 5, 2024 · 8 comments · Fixed by #279
Closed

IndexError: list index out of range #277

AJolly opened this issue Nov 5, 2024 · 8 comments · Fixed by #279
Assignees
Labels
bug Something isn't working

Comments

@AJolly
Copy link

AJolly commented Nov 5, 2024

I've now run into this issue a few times, not sure what I'm doing wrong.
Using WSL Ubuntu 24 in a python virtual environment as suggested.

Part: 38 Traceback (most recent call last): File "/mnt/c/temp/epub2tts/.venv/bin/epub2tts", line 8, in <module> sys.exit(main()) ^^^^^^ File "/mnt/c/temp/epub2tts/.venv/lib/python3.12/site-packages/epub2tts.py", line 1165, in main mybook.get_chapters_text( File "/mnt/c/temp/epub2tts/.venv/lib/python3.12/site-packages/epub2tts.py", line 664, in get_chapters_text print(f"{self.section_names[i]}") ~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range

@aedocw
Copy link
Owner

aedocw commented Nov 5, 2024

Please include the full command you are trying to run.
If it's a text file, does it have chapter breaks? Does it start with one? Something like:

Author: Name
Title: Book title

# Introduction

This is the intro

I think there is minimal error handling for books that might not have the format epub2tts expects. If you can share the source material that causes this it will help diagnose the problem.

@AJolly
Copy link
Author

AJolly commented Nov 8, 2024

I thought I matched the chapter break formatting correctly.
It will always error out at the last chapter in the book.

Was generally running something like epub2tts mybook.txt
--engine edge --speaker en-US-EmmaNeural --sayparts --skipfootnotes --threads 10 --debug

Happy to share the txt file privately.

I was using https://github.com/isaac-mcfadyen/rr-to-epub then Changing the chapter titles to start with #
using --scan gives the same error.

epub2tts-edge worked much more reliably

I also note that it errored out on a chapter that did not exist: The last chapter in this book was # Chapter 37, but the script tries to access chapter 38.

@dmarsh400
Copy link

I'm having the same issue, its not the source material as I tested a book that I already had done previously

File "/home/moderatec/miniconda/envs/epub/bin/epub2tts", line 8, in
sys.exit(main())
^^^^^^
File "/home/moderatec/miniconda/envs/epub/lib/python3.11/site-packages/epub2tts.py", line 1176, in main
mybook.read_book(
File "/home/moderatec/miniconda/envs/epub/lib/python3.11/site-packages/epub2tts.py", line 839, in read_book
if self.section_speakers[i] != None:

IndexError: list index out of range

@aedocw aedocw self-assigned this Nov 9, 2024
@aedocw aedocw added the bug Something isn't working label Nov 9, 2024
@aedocw
Copy link
Owner

aedocw commented Nov 9, 2024

I'm unable to reproduce. It seems like it thinks there are more chapters than exist, but I've tried adding in empty chapters like so:

# Part 3

# Part 4

# Part 5

This chapter has some text.

and that worked fine.

I was able to trigger a different bug by adding in a line that only has #, but that's a problem for another time (or not a problem?)

If anyone can send source material that reliably breaks this I can poke at it. My email is xxx.

@aedocw
Copy link
Owner

aedocw commented Nov 10, 2024

I have a feeling I might know what is going on here. The format of an input text file is very specific at the beginning. It will check the first two lines for Author or Title. Following that (or if there is no Author/Title specified), the next section MUST start with a chapter marker (#).

The format needs to be like:

Author: The Author
Title: The Title

# Beginning

This is where the first text of the book starts.

@aedocw
Copy link
Owner

aedocw commented Nov 13, 2024

I am pretty sure this error is from lacking chapter marker, pushed up a branch that bails if it's missing.

@aedocw aedocw linked a pull request Nov 13, 2024 that will close this issue
@dmarsh400
Copy link

I tested this on other material I had done previously and the same thing is happening.

for context I had installed VoxNovel on a separate Env but it somehow messed with epub2tts

I reinstalled epub2tts and that's when this bug started so I don't think it's the source material causing the issue.

@aedocw
Copy link
Owner

aedocw commented Nov 13, 2024

Can you share the exact command you are calling epub2tts with?

If the source material is a text file, can you share the first 5 lines of the file?

If it's an epub, is epub2tts able to successfully export it to text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants