Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
codeperfectplus committed Oct 22, 2020
1 parent ecb75f2 commit f0b57fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/

# C extensions
*.so
.vscode

# Distribution / packaging
.Python
Expand Down
24 changes: 4 additions & 20 deletions audiobook/init.py → audiobook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@
import PyPDF2


class PdfReader:
class Audiobook:
def __init__(self, book_path):
self.book_path = book_path

def get_pdf(self):
try:
book = open(book_path, 'rb')
pdfReader = PyPDF2.PdfFileReader(book)
return pdfReader
except Exception:
print("It doesnot look like a Pdf file. may be the path is wrong")

def text_to_speech(self):
pdfReader = self.get_pdf()
try:
with open(self.book_path, "rb") as book:
pdfReader = PyPDF2.PdfFileReader(book)
pages = pdfReader.numPages
print("The Book has total: " + str(pages) + " pages!")

Expand All @@ -34,12 +26,4 @@ def text_to_speech(self):
text = page.extractText()
engine.say(text)
engine.runAndWait()
engine.stop()
except Exception:
print("Double check the file type or the file path")


if __name__ == "__main__":
book_path = sys.argv[1]
reader = PdfReader(book_path)
reader.text_to_speech()
engine.stop()
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@
setuptools.setup(
#Here is the module name.
name="audiobook",

#version of the module
version="0.0.1",

version="1.0.0",
#Name of Author
author="CodePerfectPlus",

#your Email address
author_email="[email protected]",

#Small Description about module
description="listen your favourite audiobook",

long_description=long_description,

#Specifying that we are using markdown file for description
long_description_content_type="text/markdown",

#Any link to reach this module, if you have any webpage or github profile
url="https://github.com/codePerfectPlus/audiobook",
packages=setuptools.find_packages(),

#classifiers like program is suitable for python3, just leave as it is.
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: Linux :: Linux',

],
)
4 changes: 4 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from audiobook import Audiobook

ab = Audiobook("/home/codeperfectplus/Documents/Books/learningopencv.pdf")
ab.text_to_speech()

0 comments on commit f0b57fe

Please sign in to comment.