You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project converts the text from a PDF file into speech using Python. It reads the PDF, extracts the text from a specific page, and uses the `pyttsx3` library to convert the text into audible speech.
4
+
5
+
## Requirements
6
+
7
+
Before running the script, ensure you have the following Python libraries installed:
8
+
9
+
-**pyttsx3**: A text-to-speech library for Python.
10
+
-**PyPDF2**: A library for reading and extracting text from PDF files.
11
+
12
+
You can install these libraries using `pip`:
13
+
14
+
```bash
15
+
pip install pyttsx3 PyPDF2
16
+
```
17
+
18
+
## Setup
19
+
20
+
1.**Clone this repository** (or download the files):
2.**Add your PDF file**: Place the PDF file (e.g., `DMS.pdf`) in the project directory.
27
+
28
+
## How It Works
29
+
30
+
1. The script opens a PDF file (`DMS.pdf` in this case).
31
+
2. It uses the `PyPDF2` library to read the PDF and extract text from a specific page (default is the 4th page, i.e., index 3).
32
+
3. It then uses the `pyttsx3` library to convert the extracted text into speech and reads it aloud.
33
+
34
+
## Running the Script
35
+
36
+
To run the script, execute the following command in the terminal:
37
+
38
+
```bash
39
+
python audio_book.py
40
+
```
41
+
42
+
Make sure the PDF file (`DMS.pdf`) is located in the same directory as the script or update the script to point to the correct path.
43
+
44
+
## Example Output
45
+
46
+
If the 4th page of the PDF contains text, you should hear the text being read aloud by the `pyttsx3` engine.
47
+
48
+
## Notes
49
+
50
+
- You can modify the script to extract text from different pages by changing the `pdfReader.pages[3]` index to the page you want.
51
+
- The text extraction depends on the PDF content. If the PDF contains images or scanned text (like an image of text), `PyPDF2` might not extract it properly.
0 commit comments