Answers for "how to make a audiobook in python"

1

how to make a audiobook in python

#pip pyttsx3 and PyPDF2
#import the pdf you want to read
import pyttsx3
import PyPDF2
book = open('Pdf Name', 'rb')
pdfReader = PyPDF2.PdfFileReader(book)
pages = pdfReader.numPages
print(pages)
speaker = pyttsx3.init()
#0 the first page and pages about all pages so if you change 0 in both page and for loop it will work
for num in range(0, pages):
    page = pdfReader.getPage(0)
    text = page.extractText()
    speaker.say(text)
    print(text)
    speaker.runAndWait()
Posted by: Guest on June-23-2021

Code answers related to "how to make a audiobook in python"

Python Answers by Framework

Browse Popular Code Answers by Language