Skip to content

Advanced version #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions audiobook
Submodule audiobook added at bc824e
34 changes: 31 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down