This short article explores the text to speech Python library pyttxs3, reads the PDF files and converts the text to audio, and adjusts the listening speed and volume.

My daughter wanted a program that she can use to listen to a PDF file, an HTML file, or a word document. She wanted to adjust the speed and the volume of the audio and this was my quick solution for her problem using a python text to speech library.

Install pyttsx3 library

pip install pyttsx3

Listen to a text

Import the python text to the speech library: pyttsx3, initialize the library, then pass the text to say(), and finally, flush the say() queue to play the text as audio.

import pyttsx3

## Initialize the library
engine = pyttsx3.init()
## specify the text you want to listen
text="Wear mask, sanitize, social distance and be safe. Happy Thanksgiving!"
engine.say(text)
## Flush the say() queue to play the audio
engine.runAndWait()

#programming #python #pdf #audio

Listen to PDF File using Python Text to Speech Library
2.05 GEEK