Build a TEXT TO SPEECH app under 3 min & 8 lines using PYTHON and PYTTSX !!
Text to speech converter in Python
Hey , in this article you will learn to build , a simple and handy Text to
Speech applet !!
- Hit windows key or search icon , and search for , cmd , and run it as administrator
- Type, pip install pyttsx3 , Link
- After installation , exit out of the cmd window !
- At first , we import pyTTsx3 library or the package!!
import pyttsx3
- This package contains , all the necessary drivers and tools required for us !!
- Then we set the engine to sapi5, for Windows , or leave blank if you don't know !!
engine = pyttsx3.init('sapi5')
- Now we will , get the properties of the voices using this code !!
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
- With the help of set property , we can set the voice parameters like , 0 for male and 1 for female !!
- Using a text variable , we can pass the required text to the engine for conversion !!
text = " Hey , welcome to my channel !!"
- Use say method to output , your text in a Speech mode !!Unlike gTTS , this module works in offline !!
engine.say(txt)
engine.runAndWait()
Download the code !!
Thank you guys , if you have any questions leave them in the comments
!!
Comments
Post a Comment