Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46ca7e3

Browse files
Merge pull request avinashkranjan#108 from quentin-vigne/pdf_to_audio
Answer to avinashkranjan#107 - PDF Book to Audiobook
2 parents 40e8e8d + be11065 commit 46ca7e3

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

‎PDF_to_audio/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
-

‎PDF_to_audio/pdf-test.pdf‎

20.1 KB
Binary file not shown.

‎PDF_to_audio/pdf_to_audio.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /