Skip to content

Commit b61c169

Browse files
authored
Merge pull request HarshCasper#393 from simarpreetsingh-019/master
Text to speech / Story reader created.
2 parents a37cf86 + 137c7f2 commit b61c169

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

Story Reader/Readme.md

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

Story Reader/audiobook.png

3.81 KB
Loading

Story Reader/main.py

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

Story Reader/mybook.pdf

248 KB
Binary file not shown.

0 commit comments

Comments
 (0)