Skip to content

Instantly share code, notes, and snippets.

@ilyas-shah
Last active March 23, 2019 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyas-shah/5e8d2658ff2203cc4cc68cfed0567300 to your computer and use it in GitHub Desktop.
Save ilyas-shah/5e8d2658ff2203cc4cc68cfed0567300 to your computer and use it in GitHub Desktop.
Text to speech in Python using pyttsx3
# Install python, 3.xx recommended
# Run the following commands:
# pip install pyttsx3
# save below code in a file and name as whatever you want.
# To run this code, type "python <your filename.py>"
# the above command will prompt to write something, once you write, press Enter
# and it will say the text you wrote.
# import library into code
# know about this library at: https://pyttsx.readthedocs.io/en/latest/
import pyttsx3
# Intialize library
engine = pyttsx3.init()
# raw_input is used to prompt user to write something on command line
text = raw_input("write something and I will say it -> \n")
engine.say(text)
engine.runAndWait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment