How to Change Voice in pyttsx3 in Python
by Abdul Rawoof A R Updated: Feb 3, 2023
Solution Kit
To convert 'text-to-speech' we're using the pyttsx3 library in this kit. We can also change the voice of the computer to another voice. This module provides two different types of voices one is male and another one is female.
In our pyttsx3-dependent library, we're getting the voices by running a python file. The 'voiceChange()' function is invoked and an instance is initialized of the module. In this voice library, using the 'setProperty()' method and we get the available voices and we can change the user's voice ID accordingly to bring a male or female voice. If we set the speed rate of pyttsx3 below 200, the voice will speak slowly and if we set it above 200, it will increase the rate of the engine.
To change the voice of the pyttsx3 computer,
- we'll have to get the list of objects of voices.
- In the pyttsx3 package, we used 'getProperty()' to take a string as a parameter and return an object matching.
There are some APIs available to convert text to speech in python. Python Text to Speech API commonly known as the pyttsx3 API is one of them. pyttsx3 is a very easy-to-use tool that is used to convert the text entered into audio. We can also change the default language to your favorite language. For that, you should need to install additional languages to change the default language of your choice. After installing the languages, you can get the list of available voices from voices properties on your computer and then you can choose your language from the list.
Here is an example of how you can change the voice in pyttsx3 in Python,