Skip to content

Instantly share code, notes, and snippets.

@mrm8488
Created January 14, 2020 13:48
Show Gist options
  • Select an option

  • Save mrm8488/f166cfc79013474c5dcdd64fbaec41b9 to your computer and use it in GitHub Desktop.

Select an option

Save mrm8488/f166cfc79013474c5dcdd64fbaec41b9 to your computer and use it in GitHub Desktop.
Convert PDF file to text and then to audio
import pdftotext
from gtts import gTTS
from sys import argv
with open(argv[1], "rb") as f:
pdf = pdftotext.PDF(f)
document= "\n\n".join(pdf)
tts = gTTS(document)
print("Saving Audio file")
tts.save(argv[1]+".mp3")
@mrm8488
Copy link
Author

mrm8488 commented Jan 14, 2020

Usage:

python pdf-test.py test.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment