how to make a audiobook in python

Solutions on MaxInterview for how to make a audiobook in python by the best coders in the world

showing results for - "how to make a audiobook in python"
Tobias
23 Jan 2020
1#pip pyttsx3 and PyPDF2
2#import the pdf you want to read
3import pyttsx3
4import PyPDF2
5book = open('Pdf Name', 'rb')
6pdfReader = PyPDF2.PdfFileReader(book)
7pages = pdfReader.numPages
8print(pages)
9speaker = pyttsx3.init()
10#0 the first page and pages about all pages so if you change 0 in both page and for loop it will work
11for num in range(0, pages):
12    page = pdfReader.getPage(0)
13    text = page.extractText()
14    speaker.say(text)
15    print(text)
16    speaker.runAndWait()