Skip to content

aparimeet/pdf-to-audiobook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF to Audiobook

A project to convert PDFs into audiobooks using text-to-speech technology.

System Requirements

  • CPU: Tested on 64-bit AMD64 CPU with 16GB RAM
  • Python: Version 3.12.1

Installation

1. Install PyTorch

Visit PyTorch official website for installation instructions.

2. Install Text-to-Speech Model

This project uses the Kokoro-82M TTS model from Hugging Face. Kokoro is an open-weight TTS model with 82 million parameters that delivers high-quality audio while being lightweight and cost-efficient.

3. Hugging Face Authentication

Before running the TTS script, you need to authenticate with Hugging Face:

python3
>>> from huggingface_hub import login
>>> login()
# Enter your Hugging Face token when prompted

Audio Processing

To stitch together the generated WAV files, install FFmpeg.

Usage

1. Create an Index File

Create a JSON file that defines the sections of your PDF with their corresponding page ranges. The file should follow this example format:

{
    "Prologue" : {
        "start" : 6,
        "end" : 8
    },
    "Chapter 1" : {
        "start" : 11,
        "end" : 56
    },
    "Chapter 2" : {
        "start" : 58,
        "end" : 148
    },
    "Chapter 3" : {
        "start" : 150,
        "end" : 185
    },
    "Chapter 4" : {
        "start" : 187,
        "end" : 255
    },
    "Chapter 5" : {
        "start" : 257,
        "end" : 353
    }
}

Each key represents a chapter or section name, with start and end values indicating the page numbers for that section.

2. Extract Text

Run the extract text script with your PDF and index file:

python3 extract_text.py --pdf <path to PDF file> --index <path to page index json>

3. Generate Audio

Run the TTS conversion:

python3 tts.py

About

Tool for converting a PDF document to an audiobook using free TTS models

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages