diff --git a/README.md b/README.md index 41010d3..2052527 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 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/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..04bfb43 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,39 @@ +# 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() + + +""" 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!!!!!!!!") + -speaker = pyttsx3.init() -for num in range(7, pages): +for num in range(1,pages): page = pdfReader.getPage(num) text = page.extractText() speaker.say(text)