A Python script that uses Google’s Gemini-1.5-Flash model to fix basic typesetting and formatting issues in public domain eBooks from Project Gutenberg.
Learn more about GemPress by reading the accompanying blog post.
- Clone the repository, and
cd
into it:git clone https://github.com/amanvirparhar/gempress cd gempress
- Create a .env file in this directory with the following contents:
GEMINI_API_KEY=your_api_key_here
- Install
uv
.
- Put the raw text file of the book you want to reformat in the same directory as
main.py
. - Change the path to the text file in
main.py
to the name of the file you want to reformat. - Run the script:
uv run --with-requirements requirements.txt --python 3.13 main.py
- You should find an ePub file in the same directory as
main.py
with the same name as the input file (except with the.epub
file extension). - Feel free to play around with
prompt.txt
.