hey guys how are you all today in this post I am going to give kyou the sourcecode of my video called "Text to speech using python||Python practice Programs||codeandman" so let's begin:
Here's the complete sourcecode:
# text to speech using python
# speak
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
text = input("Enter the text you want to speak as a machine:")
voice = engine.setProperty(voices,[0])
engine.say(text)
engine.runAndWait()
The Logic
Steps :
- Go to your terminal and type pip install pyttsx3 and wait till the python module is installed
- after that once again type pip install wheel in the terminal.
- after this create a python file
- now import pyttsx3
- after that initialize it as the voice engine of windows called sapi5
- Now take a input as a string and add its value to variable text
- after this tell the python which voice do you want to use
- now run engine.say and inside this give the text as a argument
- now run engine.runAndWait with no arguments
- Now run the program and enter the text you want to be spoken by the machine.
- and now the machine will speak the text.
I hope that you liked this post.
Thank You.
Comments
Post a Comment