Created
August 26, 2024 17:09
-
-
Save alonsoir/e1ddf1766cee4e06a031299342c94fb2 to your computer and use it in GitHub Desktop.
It will use say native osx command to read and make a speach about the content.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyPDF2 | |
import subprocess | |
# Open the PDF file (Enter Path To Your PDF) | |
file = open('fullnotes_lagrangiano_modelo_estandar.pdf', 'rb') | |
readpdf = PyPDF2.PdfReader(file) | |
# Iterate over each page in the PDF | |
for pagenumber in range(len(readpdf.pages)): | |
# Extract text from the page | |
page = readpdf.pages[pagenumber] | |
text = page.extract_text() | |
# Use the 'say' command to read the text | |
subprocess.run(['say', '--progress', '-v', 'Flo', '-r', '140', text]) | |
# Close the PDF file | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment