This project provides a Python script that generates a chapter-by-chapter summary of an EPUB file using either OpenAI's GPT-4 or Anthropic's Claude 3.5 Sonnet model. The summarizer runs in a Docker container for easy setup and execution.
- Docker installed on your system
- An OpenAI API key (for GPT-4)
- An Anthropic API key (for Claude 3.5 Sonnet)
-
Clone this repository:
git clone https://github.com/yourusername/epub-summarizer.git cd epub-summarizer
-
Create two files in the project root directory:
openai_key.txt
: Paste your OpenAI API key into this file.anthropic_key.txt
: Paste your Anthropic API key into this file.
-
Build the Docker image:
docker build -t epub_summarizer .
To summarize an EPUB file, use the following command:
./run_summarizer.sh <model> /path/to/your/book.epub
Replace <model>
with either gpt-4
or claude-3-sonnet
, and /path/to/your/book.epub
with the actual path to your EPUB file.
Example:
./run_summarizer.sh gpt-4 "My Book.epub"
The script will process the EPUB file chapter by chapter, providing summaries as they are generated. The final summary will be saved in the summarized
directory with a filename based on the original EPUB file name.
- The script will display chapter summaries in the console as they are processed.
- A progress bar will show the overall progress of the summarization.
- The final summary will be saved as a Markdown file in the
summarized
directory.
- The summarization process may take some time depending on the size of the EPUB file and the number of chapters.
- Ensure that your OpenAI API key has sufficient credits for the summarization task.
- The script uses the GPT-3.5 Turbo model for summarization. You can modify the
summarize_text
function insummarize_epub.py
to use a different model if desired.
Example summaries generated by the script can be found in the example_summaries
directory. These summaries include both GPT-4 and Claude 3 Sonnet model outputs for comparison.
If you encounter any issues, please check the following:
- Ensure that the
openai_key.txt
file exists and contains a valid API key. - Make sure Docker is running on your system.
- Verify that the EPUB file path is correct and accessible.
For any other problems, please open an issue in the GitHub repository.