aedocw / epub2tts-edge

epub2tts-edge uses Microsoft Edge cloud-based TTS to create a full featured audiobook m4b from an epub or text file
GNU General Public License v3.0
77 stars 13 forks source link

The script quits over not being able to access the local "e" variable #15

Closed AriaShishegaran closed 5 months ago

AriaShishegaran commented 5 months ago

This is a new book I'm testing the script with and it returns this, I've also added the book I'm using for you to be able to test further.

The command I'm entering: epub2tts-edge --speaker en-CA-LiamNeural Harvard\ Business\ Review\ -\ Generative\ AI\ _\ Generative\ AI_\ The\ Insights\ You\ Need\ from\ Harvard\ Business\ Review-Harvard\ Business\ Review\ Press\ \(2024\).txt

Namespace(sourcefile='Harvard Business Review - Generative AI _ Generative AI_ The Insights You Need from Harvard Business Review-Harvard Business Review Press (2024).txt', speaker='en-CA-LiamNeural', cover=None)
Chapter: Insights You Need from Harvard Business Review

Chapter: GENERATIVE AI

Chapter: Part 5

Chapter: 1

Attempt 1/3 failed with '.' in run_edgespeak with error: cannot access local variable 'e' where it is not associated with a value
Attempt 2/3 failed with '.' in run_edgespeak with error: cannot access local variable 'e' where it is not associated with a value
Attempt 3/3 failed with '.' in run_edgespeak with error: cannot access local variable 'e' where it is not associated with a value
Giving up on sentence '.' after 3 attempts in run_edgespeak.

Harvard Business Review - Generative AI Generative AI The Insights You Need from Harvard Business Review-Harvard Business Review Press (2024).txt

aedocw commented 5 months ago

Thanks for finding this. Looks like it's finding a sentence that has nothing but a period in it, which gives edge-tts nothing to actually speak. I'll figure out how that is slipping through, it should have been caught and ignored.

aedocw commented 5 months ago

OK this is fixed in the PR I'm about to merge (tested with a snippet of your sample). Thanks for catching this!

dawaffleman123 commented 5 months ago

I am having this same error but the sentence is a full one The command I am using is: .local/bin/epub2tts-edge --cover Timeline.png Timeline.txt and it errors out with Attempt 1/3 failed with '“With the Abbot gone, I sought him out.' in run_edgespeak with error: local variable 'e' referenced before assignment Attempt 2/3 failed with '“With the Abbot gone, I sought him out.' in run_edgespeak with error: local variable 'e' referenced before assignment Attempt 3/3 failed with '“With the Abbot gone, I sought him out.' in run_edgespeak with error: local variable 'e' referenced before assignment Giving up on sentence '“With the Abbot gone, I sought him out.' after 3 attempts in run_edgespeak.

aedocw commented 5 months ago

That's odd, it could be transient (like a temporary network issue)? Could you try running the command again (it should pick up where it left off) and let me know if it still fails? If so, maybe you can share Timeline.txt with me (doc@aedo.net) so I can try to reproduce this and see what's going on.

aedocw commented 5 months ago

Thanks for sharing your source material, I see at least one problem, and it will probably expose some other issues. On big one is that there are multiple chapters with no title (in the text file it's a line with just "#"). These SHOULD have been exported with "Part 6" or "Part 7" I think, so something is wrong with the export function.

Also during the book reading phase, there's no logic to handle a blank chapter name gracefully, so instead it just tries to speak ''.

However, that doesn't explain why you're seeing an error where it is trying multiple times to say a sentence that actually exists... So haha lots of things to look into here!

aedocw commented 5 months ago

I think the poorly named branch "skip-empty-sentences" has the fix. I'm running a full book right now to confirm. I'll merge to main when it finishes.

The only thing I could reproduce here is chapter breaks with no title, ie

# 

This is a chapter.

# 

This is the next chapter

Now if the source txt has chapter breaks with no text in them, that chapter is titled "blank". I'll keep thinking about it in the back of my mind and probably come up with a more elegant approach to handling blank chapters like this but for now, it's the best I've got. Part of the reason is that I insert that as a sentence at the beginning of each chapter, and there are some things that just expect that "sntnc0.mp3" to exist... Also the metadata creation might choke on blank chapters too.

aedocw commented 5 months ago

Believe this is fixed with the latest release, but @dawaffleman123 please test when you can and let me know if you're still having the same issue.

DemonicQuasar commented 5 months ago

I'm getting a similar error here:

DemonicQuasar commented 5 months ago

Attempt 1/3 failed with 'As it changes, so too does the definition of crime.' in run_edgespeak with error: local variable 'e' referenced before assignment

DemonicQuasar commented 5 months ago

I removed the space after the period and so far the script runs normally

dawaffleman123 commented 5 months ago

Believe this is fixed with the latest release, but @dawaffleman123 please test when you can and let me know if you're still having the same issue.

Ill run it through a couple of books in a couple hours and ill let you know how they come out.

dawaffleman123 commented 5 months ago

I went through and processed 2 books the first one worked just fine, but then I got the same error on Timeline at the sentence. With the Abbot gone, I sought him out. I also tried this book in the regular epub2tts and it also did not work. Let me know if you need more info, I am happy to help.

dawaffleman123 commented 5 months ago

I removed the space after the period and so far the script runs normally

I tried this too and it worked.