A small Flask web app that extracts text from a selected range of PDF pages and reads the text aloud in the browser.
- Upload a PDF from the browser.
- Choose a start page and end page.
- Extract text from those pages with PyPDF2.
- Display the extracted text in a retro-styled reader.
- Read the text aloud with the browser Web Speech API.
- Change reading speed and volume before starting playback.
- Python
- Flask
- PyPDF2
- HTML
- CSS
- JavaScript
- Browser Web Speech API
audio_book/
main.py
requirements.txt
templates/
index.html
static/
style.css
script.js
fonts/
images/
Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activateInstall the dependencies:
pip install -r requirements.txtStart the Flask app:
python main.pyOpen the local site:
http://127.0.0.1:5000/
Flask receives the uploaded PDF and page numbers from the form in templates/index.html.
main.py uses PyPDF2 to extract text from the selected pages, then sends that text back into the page as extracted_text.
static/script.js handles the browser controls. It reads the displayed text aloud, stops playback, and applies the selected speed and volume.
static/style.css contains the retro window design, custom font, toolbar, reader box, and control styling.
The browser speech controls apply speed and volume when a new reading starts. Changing speed or volume while speech is already playing may not affect the current reading until playback is restarted.