pdf to audio book

 import pyttsx3

from pyttsx3 import Engine
import PyPDF2

book = open('2-states.pdf','rb')
pdfreader = PyPDF2.PdfFileReader(book)
pages = pdfreader.numPages
print(pages)
speaker: Engine = pyttsx3.init()
for num in range(10,322) :
page = pdfreader.getPage(10)
text = page.extractText()
speaker.say(text)
speaker.runAndWait()

Comments