From ec995a1081107f5ef4a4083106990bf6949cd3d5 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:13:24 +0500 Subject: [PATCH 1/5] Added Files --- PdfToAudio/pdf_to_audiobook.py | 26 ++++++++++++++++++++++++++ PdfToAudio/requirements.txt.txt | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 PdfToAudio/pdf_to_audiobook.py create mode 100644 PdfToAudio/requirements.txt.txt diff --git a/PdfToAudio/pdf_to_audiobook.py b/PdfToAudio/pdf_to_audiobook.py new file mode 100644 index 0000000..4882909 --- /dev/null +++ b/PdfToAudio/pdf_to_audiobook.py @@ -0,0 +1,26 @@ +# Importing the required packages. +import PyPDF2 +import pyttsx3 + +text = None + +# Reading a PDF file from your computer by specifying the path and setting the read mode to binary. +pdf_reader = PyPDF2.PdfFileReader(open(r"D:\MyPdf.pdf", "rb")) + +# Getting the handle to speaker i.e. creating a reference to pyttsx3.Engine instance. +speaker = pyttsx3.init() + +# Splitting the PDF file into pages and reading one at a time. +for page_number in range(pdf_reader.numPages): + text = pdf_reader.getPage(page_number).extractText() + # Generating speech. + speaker.say(text) + speaker.runAndWait() + +# Stopping the speaker after the complete audio has been created. +speaker.stop() + +# Saving the audiobook to your computer. +engine = pyttsx3.init() +engine.save_to_file(text, r"D:\MyAudio.mp3") +engine.runAndWait() diff --git a/PdfToAudio/requirements.txt.txt b/PdfToAudio/requirements.txt.txt new file mode 100644 index 0000000..3b1e4ed --- /dev/null +++ b/PdfToAudio/requirements.txt.txt @@ -0,0 +1,2 @@ +PyPDF2 +pyttsx3 \ No newline at end of file From 1ca77567c79f01ea28b0f3c88da5589405f9efef Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:15:57 +0500 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2027e1b..f6b075b 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| +| [Pdf to AudioBook](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | ## How to use : From 790c2b578a04d3abadecde1a2de7b7f1b4f9ed04 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:16:49 +0500 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6b075b..34d49eb 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| -| [Pdf to AudioBook](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | +| [Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | ## How to use : From a1637a18200e105c063d548084be641531e330e0 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:52:09 +0500 Subject: [PATCH 4/5] Added Files --- PdfToAudio/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 PdfToAudio/README.md diff --git a/PdfToAudio/README.md b/PdfToAudio/README.md new file mode 100644 index 0000000..ee32722 --- /dev/null +++ b/PdfToAudio/README.md @@ -0,0 +1,6 @@ +# Pdf to Audiobook Converter +This python script generates audio for given pdf files. + +## Dependencies / Requirements +- PyPDF2. Install it by typing this command in your terminal `pip install PyPDF2` +- pyttsx3. Install it by `pip install pyttsx3` From 03ef44b67cb3fd94693267f7e7eed45eb06f872e Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:53:50 +0500 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34d49eb..5d46c54 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| -| [Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | +|[Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio)|[Ayesha Gull](https://github.com/ayeshag7/)| ## How to use :