

Voice = eng.getProperty('voices') #get the available voices Illustration of how to convert one form of voice to another with explanations import pyttsx3 #import the library espeak – provides the male and female voice in every other environmentĬhange voice from male to female in pyttsx3.nsss – provides the male and female voice in MAC-OS.sapi5 – provides the male and female voice in Windows.It includes three TTS(Text-to-Speech) engines: This module supports two voices: a female voice, and a male voice. Pyttsx3 is a very easy-to-use module in python which converts the text into speech. The eng then converts it from text to speech and the compiler tells it on the call of runAndWait() method. Inside the function, an instance is initialized in the variable “eng”. We need to import the pyttsx3 library first. On the run of the python file, the textToVoice() function is triggered. import pyttsx3 #import the libraryĮng = pyttsx3.init() #initialize an instanceĮng.say("This is a demonstration of how to convert text to voice using pyttsx3 library in python.") #say method for passing text to be spokenĮng.runAndWait() #run and process the voice command pip install pyttsx3īelow given is an illustration of how to use this library with explanations. Using command prompt in your system, install the pyttsx3 library using the following command. This library works for both Python 2 and Python 3. This library works offline which makes it advantageous over others. The library pyttsx3 is a text-to-speech conversion library in Python. Hello programmers, we will see how to change voice to text using pyttsx3 in Python in this tutorial.
