This Python script uses pyttsx3
and PyPDF2
to read the text content of a PDF file and convert it to speech using text-to-speech synthesis. It allows for playback of the PDF content and provides a hotkey ("q") to stop the playback at any time.
pyttsx3
: A text-to-speech conversion library in Python.PyPDF2
: A library to handle PDF files.keyboard
: A library to listen for keyboard events.
- Install the required libraries using pip:
pip install pyttsx3 PyPDF2 keyboard
- Run the script and provide the PDF file name when prompted:
python pdf_text_to_speech.py
- Press 'q' during playback to stop the text-to-speech playback.
The script takes a PDF file as input, extracts the text content from each page, and uses pyttsx3
to read it out loud. The playback can be stopped at any time by pressing the 'q' key.