Audio Book using python
we can convert any pdf to an audiobook using python. Only two Python libraries are required. 1. pyttsx3 2. PyPDF2 and you need to import your pdf document under this project folder too. let's start 💻 step 1: import both libraries using import keyword, import pyttsx3 import PyPDF2 💻 step 2: we need to open our pdf document using the open function. open syntax book = open(“ filename ”, “mode”) where book is the variable to add the file object. filename is your pdf file name. book = open ( 'event.pdf' , 'rb' ) 💻 step 3: call pdf reader function to read your pdf document. pdfReader = PyPDF2.PdfFileReader(book) 💻 step 4: Get pdf pages details for example 200 page pdf or 1000 page pdf document print(page) command is just optional. page = pdfReader.numPages print (page)// optional 💻 step 5: initialize speaker and save it into speaker variable speaker = pyttsx3.init() 💻 step 6: define which page you gonna read, using the get page function...




Comments
Post a Comment