File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Readme
2
+ ## Use this code
3
+ First you'll need to type those lines :
4
+ ```
5
+ pip install pyttsx3
6
+
7
+ pip install PyPDF2
8
+ ```
9
+
10
+ ## Improving the code
11
+ - Add the possiblity to save to .MP3
12
+ - Select the pages we would like to read
13
+ - Find a better TTS Voice
14
+
15
+ ## Known issues
16
+ - Some PDF don't use spaces but positionning, at the moment I can't figure out how to take this into account other than using OCR.
17
+ -
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sun Oct 11 19:50:06 2020
4
+
5
+ @author: quent
6
+ """
7
+ import PyPDF2
8
+ import pyttsx3
9
+ from tkinter import Tk
10
+ from tkinter .filedialog import askopenfilename
11
+
12
+
13
+ Tk ().withdraw () # We could make our own GUI but let's use the default one
14
+ FILE_PATH = askopenfilename () # open the dialog GUI
15
+
16
+ with open (FILE_PATH , "rb" ) as f : # open the file in reading (rb) mode and call it f
17
+ pdf = PyPDF2 .PdfFileReader (f )
18
+ #parse every page
19
+ for page in pdf .pages :
20
+ text = page .extractText ()
21
+ ## speaking part ####
22
+ engine = pyttsx3 .init ()
23
+ engine .say (text )
24
+ engine .runAndWait ()
You can’t perform that action at this time.
0 commit comments