Skip to content

Instantly share code, notes, and snippets.

@shiveshabhishek
Created May 15, 2023 06:23
Show Gist options
  • Save shiveshabhishek/d50bf6d35c63097ac560d6eed8b593b2 to your computer and use it in GitHub Desktop.
Save shiveshabhishek/d50bf6d35c63097ac560d6eed8b593b2 to your computer and use it in GitHub Desktop.
python text to speech
#--- Prereq to install:
#--- pip3 install pyttsx3
#--- sudo apt-get install espeak
import pyttsx3
# Create TTS engine
engine = pyttsx3.init()
# Set properties
engine.setProperty('rate', 150) # Speed of speech
engine.setProperty('volume', 0.8) # Volume (0.0 to 1.0)
# Get input from user
text = input("Enter the text you want to convert to speech: ")
# Convert text to speech
engine.say(text)
engine.runAndWait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment