Created
May 15, 2023 06:23
-
-
Save shiveshabhishek/d50bf6d35c63097ac560d6eed8b593b2 to your computer and use it in GitHub Desktop.
python text to speech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--- 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