Install using pypi
pip install audiobook
The audiobook is a python module for listening to your favourite PDF (and not only) book.
Basic usage is exposed via CLI, type python audiobook -h
for help.
More advanced features are exposed via the API:
usage: audiobook [-h] [-p [PATH]] [-l | -c | -s | -r]
AudioBook - listen to any PDF book
optional arguments:
-h, --help show this help message and exit
-p [PATH], --path [PATH]
book file path
-l, --library get all books in library
-c, --create-json create json file from input file
-s, --save-audio save audio files from input file
-r, --read-book read the book from input file
# to read the book
audiobook -p "C:\Users\user\Documents\book.pdf" -r
# to create json file
audiobook -p "C:\Users\user\Documents\book.pdf" -c
# to save audio files
audiobook -p "C:\Users\user\Documents\book.pdf" -s
# to get all books in library
audiobook -l
from audiobook import AudioBook
# argument: Speech-Speed="slow/normal/fast", volume = 0.0 to 1.0
ab = AudioBook(speed="normal", volume=1.0)
# if file is password protected, pass password as argument
# save_page_wise audio/whole book in one mp3 file
ab.save_audio(self, input_book_path, password=None, save_page_wise=False):
- input_book_path: path to pdf file
- password: password to pdf file
- save_page_wise: if True, saves each page as a separate mp3 file
- extraction_engine: "pypdf2/pdfminor" for extracting text from pdf file
ab.read_book(file_path) # listen to the book
ab.create_json_book(file_path) # create json file of the book
ab.get_library() # get all the books in your library
File Format | Supported | Engine |
---|---|---|
β | pypdf2/pdfminor | |
TXT | β | not required |
EPUB | β | not required |
MOBI | β | not required |
HTML | β | not required |
DOCX | β | not required |
ODT | β | not required |
Run tests:
pip install -r requirements.txt
python -m unittest tests
Read Detailed Documentation here
- If you are using a Linux system and the voice output is not working, then : Install espeak , ffmpeg and libespeak1 as shown below:
sudo apt update && sudo apt install espeak ffmpeg libespeak1
- Speech-Speed Control
- Support more extensions
- Save the audiobook for future
This project is currently in development. Any contributions are welcome.
V2.0.2
- Docs files support added
- Pdfminor as engine added
- ODT file support added
V2.0.1
- Mobi file support
- Epub file support
- User can now save the audiobook for future
- User can now listen to the book from the library
V2.0.0
- Save Audio Book locally
- Listen to the book
- Speech-speed control
- Read password-protected PDF
- Create JSON file for the book
** Upcoming changes**
- Change the voice of the narrator
- Support more extensions
- Module : AudioBook
- Author : py-contributors
- Language : Python