From 74061bc955ac008a2c5b083bd641efd42c3673be Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Sat, 11 Sep 2021 15:22:46 +0530 Subject: [PATCH 1/2] this is my 1st commit --- README.md | 1 + audiobook | 1 + main.py | 26 ++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 160000 audiobook diff --git a/README.md b/README.md index 41010d3..a1b9176 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ To Read text (Text to speech) ` ` pip install pyttsx3 ` +Go to https://pypi.org/project/pyttsx3/ documentation and try to change the other properties of Speaker like Changing Voice from male to female, Rate and Volume #### Note: This code can read all the printable text from a PDF file/ Book diff --git a/audiobook b/audiobook new file mode 160000 index 0000000..bc824e3 --- /dev/null +++ b/audiobook @@ -0,0 +1 @@ +Subproject commit bc824e30785893f28707672bcb7eeccfe645cd83 diff --git a/main.py b/main.py index fdb41dd..7f9c17b 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,33 @@ +# To read PDF file using Python pip install pypdf2 To Read text (Text to speech) pip install pyaudio pip install pyttsx3 + import pyttsx3 import PyPDF2 -book = open('oop.pdf', 'rb') + +book = open("C:/Users/bhask\Desktop/tweet_summarization/DE1.pdf","rb") pdfReader = PyPDF2.PdfFileReader(book) pages = pdfReader.numPages +print("total number of pages is:" ,pages) speaker = pyttsx3.init() -for num in range(7, pages): +""" RATE""" +rate = speaker.getProperty('rate') # getting details of current speaking rate +print ("current voice rate is: ",rate) #printing current voice rate +speaker.setProperty('rate',170) # setting up new voice rate +speaker.runAndWait() + +"""VOLUME""" +volume = speaker.getProperty('volume') #getting to know current volume level (min=0 and max=1) +print ("volume level is at : ",volume) #printing current volume level +speaker.setProperty('volume',1.0) # setting up volume level between 0 and 1 + +"""VOICE""" +voices = speaker.getProperty('voices') #getting details of current voice +#speaker.setProperty('voice', voices[0].id) #changing index, changes voices. o for male +speaker.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female +speaker.say("HII BHASKAR!, NICE to see you here............") +print("the reading of book is started!............") +speaker.say("the reading of book is started!!!!!!!!") +for num in range(1,pages): page = pdfReader.getPage(num) text = page.extractText() speaker.say(text) From 9fdbabf365e9a4d36b15d8b2387cfe020ac44b52 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Sat, 11 Sep 2021 15:23:50 +0530 Subject: [PATCH 2/2] this is my 1st commit --- README.md | 2 +- main.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1b9176..2052527 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To Read text (Text to speech) ` ` pip install pyttsx3 ` -Go to https://pypi.org/project/pyttsx3/ documentation and try to change the other properties of Speaker like Changing Voice from male to female, Rate and Volume +Go to https://pypi.org/project/pyttsx3/ documentation and try to change the other properties of Speaker as of your choice like Changing Voice from male to female, Rate and Volume #### Note: This code can read all the printable text from a PDF file/ Book diff --git a/main.py b/main.py index 7f9c17b..04bfb43 100644 --- a/main.py +++ b/main.py @@ -8,18 +8,22 @@ pages = pdfReader.numPages print("total number of pages is:" ,pages) -speaker = pyttsx3.init() +speaker = pyttsx3.init() + + """ RATE""" rate = speaker.getProperty('rate') # getting details of current speaking rate print ("current voice rate is: ",rate) #printing current voice rate speaker.setProperty('rate',170) # setting up new voice rate speaker.runAndWait() + """VOLUME""" volume = speaker.getProperty('volume') #getting to know current volume level (min=0 and max=1) print ("volume level is at : ",volume) #printing current volume level speaker.setProperty('volume',1.0) # setting up volume level between 0 and 1 + """VOICE""" voices = speaker.getProperty('voices') #getting details of current voice #speaker.setProperty('voice', voices[0].id) #changing index, changes voices. o for male @@ -27,6 +31,8 @@ speaker.say("HII BHASKAR!, NICE to see you here............") print("the reading of book is started!............") speaker.say("the reading of book is started!!!!!!!!") + + for num in range(1,pages): page = pdfReader.getPage(num) text = page.extractText()