Pip install pypiwin32 # Windows only Convert text to speech # pip install pyttsx3 pypiwin32 If you are in Windows, you will need an additional package, pypiwin32 which it will need to access the native Windows speech API. If you are interested specifically and only in speak, you might be interested in my Python text-to-speech with espeak tutorial.
The pyttsx3 module supports native Windows and Mac speech APIs but also supports espeak, making it the best available text-to-speech package in my opinion. Check the official examples to see how this is done.Īlways refer to the official documentation for the most accurate, complete, and up-to-date information. The event hooks are not covered here but are worth a mention. You can inspect each word and cut it off if there are inappropriate words. You can use this to count how many words are said and cut it off if it has received input that is too long. You can hook in to the engine on certain events. There are some other cool features that are not covered here, like the event system. It uses native speech drivers when available and works completely offline. This package works in Windows, Mac, and Linux. This lets you synthesize text in to audio you can hear. This tutorials demonstrates how to use Python for text-to-speech using a cross-platform library, pyttsx3.