From 21eeabf145c38dddfaf97d8e83efdf4272c6f6bd Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 9 Mar 2025 20:01:35 -0700 Subject: [PATCH 1/5] added pdf flattener --- ebook2audiobook.egg-info/requires.txt | 3 ++- lib/functions.py | 15 +++++++++++++-- pyproject.toml | 1 + requirements.txt | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ebook2audiobook.egg-info/requires.txt b/ebook2audiobook.egg-info/requires.txt index d44dc133..731dcab0 100644 --- a/ebook2audiobook.egg-info/requires.txt +++ b/ebook2audiobook.egg-info/requires.txt @@ -22,11 +22,12 @@ pypinyin ray regex sentencepiece -torchvggish transformers translate tqdm unidic +torchvggish +pymupdf4llm torch==2.4.1 torchaudio==2.4.1 torchvision==0.19.1 diff --git a/lib/functions.py b/lib/functions.py index fbfd9e8f..1a71c1d7 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -18,6 +18,7 @@ import os import platform import psutil +import pymupdf4llm import random import regex as re import requests @@ -451,10 +452,20 @@ def convert_to_epub(session): error = "The 'ebook-convert' utility is not installed or not found." print(error) return False - print(f"Running command: {util_app} {session['ebook']} {session['epub_path']}") + file_input = session['ebook'] + file_ext = os.path.splitext(session['ebook'])[1].lower() + if file_ext == '.pdf': + msg = 'File input is a PDF. flatten it in MD format...' + print(msg) + file_input = f"{os.path.splitext(session['epub_path'])[0]}.md" + markdown_text = pymupdf4llm.to_markdown(session['ebook']) + with open(file_input, "w", encoding="utf-8") as md_file: + md_file.write(markdown_text) + msg = f"Running command: {util_app} {file_input} {session['epub_path']}" + print(msg) result = subprocess.run( [ - util_app, session['ebook'], session['epub_path'], + util_app, file_input, session['epub_path'], '--input-encoding=utf-8', '--output-profile=generic_eink', '--epub-version=3', diff --git a/pyproject.toml b/pyproject.toml index 3cc3a830..fd2d5525 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ dependencies = [ "tqdm", "unidic", "torchvggish", + "pymupdf4llm", "torch==2.4.1", "torchaudio==2.4.1", "torchvision==0.19.1", diff --git a/requirements.txt b/requirements.txt index 0ac9b499..731dcab0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,6 +27,7 @@ translate tqdm unidic torchvggish +pymupdf4llm torch==2.4.1 torchaudio==2.4.1 torchvision==0.19.1 From f28870bd0f419fe2b7cb7a6d3ac30bb4bce94210 Mon Sep 17 00:00:00 2001 From: Drew Thomasson <126999465+DrewThomasson@users.noreply.github.com> Date: Sun, 9 Mar 2025 23:12:37 -0400 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5a6c55d4..2967dd26 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Use this tool responsibly and in accordance with all applicable laws. Thanks to support ebook2audiobook developers!
[![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/athomasson2) +[![Ubuntu Build+Test](https://github.com/DrewThomasson/ebook2audiobook/actions/workflows/ubuntu-build+test-docker.yml/badge.svg)](https://github.com/DrewThomasson/ebook2audiobook/actions/workflows/ubuntu-build+test-docker.yml) #### GUI Interface ![demo_web_gui](assets/demo_web_gui.gif) From 5a4ca6992fc1b96667f4035899f90dde67e628b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 9 Mar 2025 20:31:58 -0700 Subject: [PATCH 3/5] ... --- lib/functions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/functions.py b/lib/functions.py index 1a71c1d7..cebaf58c 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -354,7 +354,7 @@ def recursive_copy(source, visited): return str(source) # Convert non-serializable types to strings return recursive_copy(proxy_obj, set()) -def maths_to_words(text, lang, lang_iso1, tts_engine): +def math2word(text, lang, lang_iso1, tts_engine): def check_compat(): try: num2words(1, lang=lang_iso1) @@ -401,7 +401,8 @@ def replace_ambiguous(match): if ambiguous_replacements: text = re.sub(ambiguous_pattern, replace_ambiguous, text) # Regex pattern for detecting numbers (handles negatives, commas, decimals, scientific notation) - number_pattern = r'(? Date: Mon, 10 Mar 2025 14:52:58 -0400 Subject: [PATCH 4/5] Removed release trigger from Dev test Cause that's for the main Build+Test to do This is redundancy for no reason if I have this also run lol --- .github/workflows/dev-docker-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dev-docker-test.yml b/.github/workflows/dev-docker-test.yml index 94b622ff..dca61f25 100644 --- a/.github/workflows/dev-docker-test.yml +++ b/.github/workflows/dev-docker-test.yml @@ -2,9 +2,6 @@ name: Full Dev Docker Test on: workflow_dispatch: {} - release: - types: - - published push: branches: - v25 @@ -16,6 +13,7 @@ on: - dockerfiles/** - Notebooks/** + jobs: build: runs-on: [self-hosted, Linux, ARM64] From b12c3313d23b0962e21bf38bcd015cbc3ade6c55 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Mar 2025 13:12:14 -0700 Subject: [PATCH 5/5] update coqui-tts version --- VERSION.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index ef10b0ce..5106a0ce 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -25.3.9 \ No newline at end of file +25.3.10 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 731dcab0..c1296a02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,4 +31,4 @@ pymupdf4llm torch==2.4.1 torchaudio==2.4.1 torchvision==0.19.1 -coqui-tts==0.25.3 \ No newline at end of file +coqui-tts==0.26.0 \ No newline at end of file