Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions PDF_to_audio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Readme
## Use this code
First you'll need to type those lines :
```
pip install pyttsx3

pip install PyPDF2
```

## Improving the code
- Add the possiblity to save to .MP3
- Select the pages we would like to read
- Find a better TTS Voice

## Known issues
- 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.
-
Binary file added PDF_to_audio/pdf-test.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions PDF_to_audio/pdf_to_audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 11 19:50:06 2020

@author: quent
"""
import PyPDF2
import pyttsx3
from tkinter import Tk
from tkinter.filedialog import askopenfilename


Tk().withdraw() # We could make our own GUI but let's use the default one
FILE_PATH = askopenfilename() # open the dialog GUI

with open(FILE_PATH, "rb") as f: # open the file in reading (rb) mode and call it f
pdf = PyPDF2.PdfFileReader(f)
#parse every page
for page in pdf.pages:
text = page.extractText()
## speaking part ####
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()