From a7899038d7cbdba101f13aa57d765fee3c70a229 Mon Sep 17 00:00:00 2001 From: Hershil Piplani <54028832+herkura@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:00:51 +0530 Subject: [PATCH 1/2] Create convPDFtoAudio.py --- Convert pdf file to audio file/convPDFtoAudio.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Convert pdf file to audio file/convPDFtoAudio.py diff --git a/Convert pdf file to audio file/convPDFtoAudio.py b/Convert pdf file to audio file/convPDFtoAudio.py new file mode 100644 index 0000000..fe65788 --- /dev/null +++ b/Convert pdf file to audio file/convPDFtoAudio.py @@ -0,0 +1,15 @@ + + + + +import pyttsx3,PyPDF2 +pdfreader = PyPDF2.PdfFileReader(open('story.pdf','rb')) +speaker = pyttsx3.init() +for page_num in range(pdfreader.numPages): + text = pdfreader.getPage(page_num).extractText() ## extracting text from the PDF + cleaned_text = text.strip().replace('\n',' ') ## Removes unnecessary spaces and break lines + print(cleaned_text) ## Print the text from PDF + #speaker.say(cleaned_text) ## Let The Speaker Speak The Text + speaker.save_to_file(cleaned_text,'story.mp3') ## Saving Text In a audio file 'story.mp3' + speaker.runAndWait() +speaker.stop() From 2aa47924d998afed900b66735200757773861f89 Mon Sep 17 00:00:00 2001 From: Hershil Piplani <54028832+herkura@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:03:20 +0530 Subject: [PATCH 2/2] Update convPDFtoAudio.py --- Convert pdf file to audio file/convPDFtoAudio.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Convert pdf file to audio file/convPDFtoAudio.py b/Convert pdf file to audio file/convPDFtoAudio.py index fe65788..dbfa7d9 100644 --- a/Convert pdf file to audio file/convPDFtoAudio.py +++ b/Convert pdf file to audio file/convPDFtoAudio.py @@ -1,4 +1,9 @@ - +''' +Convert pdf to audio file +- script that can convert pdfs into audio files +Author : Hershil Piplani +Date : 4/10/22 +'''