-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAudio Book.py
More file actions
43 lines (25 loc) · 696 Bytes
/
Audio Book.py
File metadata and controls
43 lines (25 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
pip install pyttsx3 pdfplumber PyPDF2
# In[ ]:
pip install googletrans
# In[ ]:
import pyttsx3
import pdfplumber
import PyPDF2
from googletrans import Translator
# In[ ]:
readbook = open('Spain.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(readbook)
pages = pdfReader.numPages
readloud = pyttsx3.init()
for num in range(pages):
page = pdfReader.getPage(num)
text = page.extractText()
translator=Translator()
translation = translator.translate(text, dest="en")
translated = str(translation.text)
print(translated)
readloud.say(translated)
readloud.runAndWait()