File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ [ ![ forthebadge] ( https://forthebadge.com/images/badges/made-with-python.svg )] ( https://forthebadge.com )
2
+
3
+ <div align =" center " >
4
+ <img src =" audiobook.png " height =500 width =" 500 " >
5
+ </div >
6
+
7
+ # Audiobook
8
+
9
+ Read any audio book from pdf using python.
10
+ ### Modules used:
11
+ 1. PyPDF2
12
+ 2. Pyttsx3
Original file line number Diff line number Diff line change
1
+ from time import sleep
2
+
3
+ import pyttsx3 #pip install pyttsx3
4
+ import PyPDF2 #pip install PyPDF2
5
+
6
+ print ("Enter the pdf you want me to read for you. Remember to put it in same folder, or either give me location of it." )
7
+ story = input ("If you dont have one, Enter mybook.pdf to run it. : " )
8
+
9
+ #story = open('mybook.pdf', 'rb') #Name of your script make sure it's in pdf format
10
+ pdfReader = PyPDF2 .PdfFileReader (story )
11
+ pages = pdfReader .numPages
12
+ # pages = pdfReader.getPage(number) Replace nu,ber with any specific page number you want this to read
13
+ engine = pyttsx3 .init ()
14
+ voices = engine .getProperty ('voices' )
15
+ engine .setProperty ('voice' , voices [0 ].id ) #For male voice change the value to 1.
16
+
17
+ for num in range (0 , pages ):
18
+ page = pdfReader .getPage (num )
19
+ text = page .extractText ()
20
+ engine .say (text )
21
+ engine .runAndWait ()
22
+
You can’t perform that action at this time.
0 commit comments