Created
September 2, 2023 17:56
-
-
Save bug-author/4b42655f29195548310bd0cec9879457 to your computer and use it in GitHub Desktop.
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 pdfplumber | |
from gtts import gTTS | |
def pdf_to_text(pdf_path): | |
pdf_text = "" | |
with pdfplumber.open(pdf_path) as pdf: | |
for page in pdf.pages: | |
pdf_text += page.extract_text() | |
return pdf_text | |
if __name__ == "__main__": | |
pdf_path = "sample.pdf" | |
extracted_text = pdf_to_text(pdf_path) | |
if extracted_text: | |
tts = gTTS(text=extracted_text, lang='en') | |
tts.save("sample_audiobook.mp3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment