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

(question) All chapters end up being 2kb large #56

Closed
f73 opened this issue Mar 16, 2024 · 7 comments
Closed

(question) All chapters end up being 2kb large #56

f73 opened this issue Mar 16, 2024 · 7 comments

Comments

@f73
Copy link

f73 commented Mar 16, 2024

Hello,

This is more of a question, then a bug report as I am not sure if this is due to me doing something wrong...

After chapter is converted to mp3 it end up with size of ~2kb, during conversion size is reported correctly (while refreshing directory). This was in wsl on both Ubuntu and Arch distros as well as on regular Linux Arch distro, using python virtual env with edge as tts provider with following command:
python main.py book_name.epub book_dir --tts edge --language hr-HR --voice_name hr-HR-SreckoNeural

Had the same issue with english language book, not providing language switch, which, if I am correct use english language by default...

Using conversion with docker image works as expected.

Thanks

@fangar
Copy link

fangar commented Mar 16, 2024

Using conversion with docker image works as expected.

I had sent a message on reddit about this and included a link to a sample epub. I am having the same issues with all of my epubs that were originally azw3 and have been converted to epub with calibre. Thanks for the workaround using docker. I will try it next as an alternative.

@p0n1
Copy link
Owner

p0n1 commented Mar 18, 2024

Thanks for reporting. I'll look into this later.

@ryanboyd
Copy link

Same issue on my end, running on Windows. I find that if I keyboard interrupt during processing, a more "complete" filesize will appear. In looking at the 2kb files, they do have ID3 tags embedded in them, but it seems like nothing else.

It might be the case that the file is being overwritten with just the tag information at the very end of the write process.

@ryanboyd
Copy link

ryanboyd commented Mar 20, 2024

Follow-up: it appears that the issue is in this line:
https://github.com/p0n1/epub_to_audiobook/blob/main/audiobook_generator/tts_providers/edge_tts_provider.py#L111

If I comment out the audio.export(audio_fname) call, all works as expected. This line appears to be overwriting the data that is written during generation. After this, the file is still ID3 tagged correctly, leading to the results that I reported above.

@fangar
Copy link

fangar commented Mar 20, 2024

If I comment out the audio.export(audio_fname) call, all works as expected.

I can confirm that also does the trick for me; many thanks! I looked through the code, but nothing jumped out at me.

@p0n1
Copy link
Owner

p0n1 commented Mar 21, 2024

Looks like this issue was introduced by #45. I haven't make a release for the latest code so the docker version just worked fine.

Thanks everyone for trying and reporting this. Thanks @ryanboyd for your fix. I'll merge soon. But I still don't understand why I can't reproduce this issue. Will try more cases.

@devPDG
Copy link

devPDG commented Mar 22, 2024

My workaround for this on


is

    async def save(
        self,
        audio_fname: Union[str, bytes],
        metadata_fname: Optional[Union[str, bytes]] = None,
    ) -> None:
        # Save the audio and metadata to the specified files.
        await self.chunkify()
        await super().save(audio_fname, metadata_fname)

        audio: AudioSegment = AudioSegment.from_file(audio_fname)
        audio.export(audio_fname)

If you just comment out the audio export, the file size will be larger though, audio export somewhat compresses the audio.
though the problem is when you pick other formats like amr, ogg, silk, etc. It seems that its not giving the result as what we have expected, its still just an mp3 with another file extension format, the file spec will still be the same regardless.

A 15573 characters not yet converted by pydub audio.export is 4.92MB while 3.28MB when converted/exported.

@p0n1 p0n1 mentioned this issue Jun 27, 2024
@p0n1 p0n1 closed this as completed in 9ecd3d0 Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants