<jupyter_start><jupyter_text>a **PDF-to-Speech** Notebook  Importing Libraries  PyPDF2 is a Pure-Python Library built as a PDF toolkit. It is capable of:* extracting document information (title, author, …)* splitting documents page by page* merging documents page by page* cropping pages* merging multiple pages into a single page* encrypting and decrypting PDF files* and more!<jupyter_code>pip install PyPDF2<jupyter_output>Collecting PyPDF2
  Downloading PyPDF2-1.26.0.tar.gz (77 kB)
Building wheels for collected packages: PyPDF2
  Building wheel for PyPDF2 (setup.py): started
  Building wheel for PyPDF2 (setup.py): finished with status 'done'
  Created wheel for PyPDF2: filename=PyPDF2-1.26.0-py3-none-any.whl size=61087 sha256=c2d82a025416ed798a2787e72648014c186a67f6b2ae92f1930c940ad7920f28
  Stored in directory: c:\users\ecsan\appdata\local\pip\cache\wheels\b1\1a\8f\a4c34be976825a2f7948d0fa40907598d69834f8ab5889de11
Successfully built PyPDF2
Installing collected packages: PyPDF2
Successfully installed PyPDF2-1.26.0
Note: you may need to restart the kernel to use updated packages.<jupyter_text>pyttsx3 is a Text-to-Speech conversion Library in Python that, unlike alternative Libraries, works offline and is compatible with both Python 2 and 3.  Importing Libraries<jupyter_code>import PyPDF2
import pyttsx3<jupyter_output><empty_output><jupyter_text>Defining the target PDF (local machine only, it doesn't appear - at least to me - to work on GColab)<jupyter_code>path = open('glossário-do-trade-marketing.pdf', 'rb')<jupyter_output><empty_output><jupyter_text>Configuring the Reader<jupyter_code>pdfReader = PyPDF2.PdfFileReader(path)
# Defining the Page to be read. As per StackOverflow, if you need the whole Document, you need to run a "For" Loop.
from_page = pdfReader.getPage(4)
text = from_page.extractText()<jupyter_output><empty_output><jupyter_text>Initializing the Speech-to-Text Engine<jupyter_code>speak = pyttsx3.init()
speak.say(text)
# A Female - very - robotic voice reads the Text.
speak.runAndWait()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08135593220338982, 'fraction_numerical': 0.061501210653753025, 'mean_word_length': 6.378571428571429, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '606668', 'license': 'MIT', 'n_tokens_mistral': 771, 'n_tokens_neox': 696, 'n_words': 201, 'path': 'PDF_to_Speech.ipynb', 'repo_name': 'ecsantana76/PDF-to-Speech', 'size': '2065'}