BookBytes is a Python application that converts non-fiction books into chapter-wise audio summaries for faster and more convenient knowledge consumption. Transform a 200-page book into 15-20 digestible 5-minute audio bites!
- Problem: Long books, no time to read
- Solution: Short, condensed audio bytes for simpler consumption
- Value: 200-page book โ 15-20 chapters โ 5 mins audio bites each โ 1.5-2hrs total
- ISBN-based book lookup: Enter any book's ISBN to get started
- Automatic chapter detection: Uses LLM to identify book chapters
- AI-powered summaries: Generates concise, informative chapter summaries
- Text-to-speech conversion: Converts summaries to high-quality audio
- RESTful API: Easy-to-use API for integration
- Database storage: Persistent storage for books, chapters, and audio files
- Backend: Python, Flask
- Database: SQLite
- AI/LLM: OpenAI GPT-3.5-turbo
- Text-to-Speech: Google Text-to-Speech (gTTS)
- Book Data: Open Library API
- Python 3.8 or higher
- OpenAI API key
- Internet connection (for API calls)
-
Clone the repository:
git clone <repository-url> cd bookbytes
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
export OPENAI_API_KEY="your-openai-api-key-here"
Or create a
.envfile:OPENAI_API_KEY=your-openai-api-key-here
Alternatively, you can run BookBytes using Docker:
-
Clone the repository:
git clone <repository-url> cd bookbytes
-
Create a
.envfile with your OpenAI API key:echo "OPENAI_API_KEY=your-openai-api-key-here" > .env
-
Build and start the container:
docker-compose up -d
-
Access the application at http://localhost:5000
-
To stop the container:
docker-compose down
The application uses Docker volumes to persist data:
- The SQLite database and audio files are stored in a Docker volume named
bookbytes-data - This ensures your data is preserved even if the container is removed
python app.pyThe server will start on http://localhost:5000
POST /api/process
curl -X POST http://localhost:5000/api/process \
-H "Content-Type: application/json" \
-d '{"isbn": "9780307887894"}'Response:
{
"success": true,
"message": "Successfully processed 12 out of 12 chapters",
"book": {
"isbn": "9780307887894",
"title": "The Power of Habit",
"author": "Charles Duhigg"
},
"chapters_processed": 12
}GET /api/books
curl http://localhost:5000/api/booksResponse:
{
"books": [
{
"isbn": "9780307887894",
"title": "The Power of Habit",
"author": "Charles Duhigg",
"pages": 371,
"publish_date": "2012",
"chapter_count": 12
}
]
}GET /api/books/{isbn}/chapters
curl http://localhost:5000/api/books/9780307887894/chaptersResponse:
{
"chapters": [
{
"chapter_number": 1,
"title": "The Habit Loop",
"summary": "This chapter introduces the concept of the habit loop...",
"audio_file_path": "audio/9780307887894_chapter_01.mp3",
"word_count": 142
}
]
}GET /api/audio/{isbn}/{chapter_number}
curl http://localhost:5000/api/audio/9780307887894/1 --output chapter1.mp3GET /health
curl http://localhost:5000/healthbookbytes/
โโโ app.py # Main application file
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ .env # Environment variables (create this)
โโโ bookbytes.db # SQLite database (auto-created)
โโโ audio/ # Generated audio files (auto-created)
โ โโโ {isbn}_chapter_01.mp3
โ โโโ {isbn}_chapter_02.mp3
โ โโโ ...
โโโ knowledge/
โ โโโ docs.md # Project documentation
โโโ samples/ # Sample audio files
โโโ ...
- User Input: Provide book ISBN
- Book Lookup: Fetch book details from Open Library API
- Chapter Detection: Use LLM to identify book chapters
- Summary Generation: Generate concise summaries for each chapter
- Audio Conversion: Convert text summaries to audio using TTS
- Storage: Save book, chapters, and audio files to database
- API Access: Serve content through RESTful API
- Format: MP3
- Quality: Standard quality suitable for speech
- Duration: Typically 3-7 minutes per chapter
- Language: English (configurable)
- Fair Use: Generates transformative summaries for educational purposes
- Copyright Compliance: Does not reproduce substantial portions of original works
- Educational Purpose: Designed for knowledge consumption and learning
- LLM Knowledge: Limited to books in the training data
- Chapter Detection: May not work for all books
- Summary Quality: Depends on LLM's knowledge of the specific book
- API Costs: OpenAI API usage incurs costs
- Chapter-wise audio storage with metadata
- Timestamp tracking for audio navigation
- Support for book titles instead of ISBN
- Multiple TTS voice options
- Batch processing capabilities
- Web interface for easier interaction
-
"OpenAI API key not configured"
- Ensure
OPENAI_API_KEYenvironment variable is set - Check that the API key is valid and has sufficient credits
- Ensure
-
"Book not found for ISBN"
- Verify the ISBN is correct (10 or 13 digits)
- Try removing hyphens from the ISBN
- Check if the book exists in Open Library
-
"Could not retrieve chapters"
- The book might not be in the LLM's training data
- Try a more popular or well-known book
-
Audio generation fails
- Check internet connection (gTTS requires internet)
- Ensure the
audio/directory is writable
-
Container fails to start
- Check if the required ports are already in use
- Verify that the
.envfile exists with a valid OpenAI API key
-
Data persistence issues
- Ensure the Docker volume is properly created:
docker volume ls - Check container logs for permission issues:
docker-compose logs
- Ensure the Docker volume is properly created:
-
Performance issues
- Adjust container resources in docker-compose.yml if needed
- For production, consider setting
FLASK_DEBUG=0
Run the application in debug mode for more detailed logs:
FLASK_DEBUG=1 python app.pyFor Docker:
# View logs
docker-compose logs -f
# Restart with debug mode
docker-compose down
FLASK_DEBUG=1 docker-compose up -d- The Power of Habit - ISBN: 9780307887894
- Atomic Habits - ISBN: 9780735211292
- Thinking, Fast and Slow - ISBN: 9780374533557
- The 7 Habits of Highly Effective People - ISBN: 9780743269513
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Not licenced yet.
- Open Library for book metadata
- OpenAI for LLM capabilities
- Google for Text-to-Speech services
- Flask community for the web framework
Happy Learning! ๐๐