import pyttsx3
#init function to get an engine instance for the speech synthesis
# SAPI5---->for Windows.
# nsss----->for mac.
# espeak--->for Linux.
engine = pyttsx3.init('espeak')
engine.setProperty('rate', 130)
engine.setProperty('volume', 0.9)
# -------------------->First Method.
#--------->getting details of current voice# voices = engine.getProperty('voices')
#---------------------------->changing index
# #engine.setProperty('voice', voices[0]. #changes voices. 0 for male
# engine.setProperty('voice', voices[1].id) #1 for female
# --------------------->Second Method.
#voices = engine.getProperty('voices')
# for voice in voices:
# # to get the info. about various voices in our PC
# print("Voice:")
# print("ID: %s" %voice.id)
# print("Name: %s" %voice.name)
# print("Age: %s" %voice.age)
# print("Gender: %s" %voice.gender)
# print("Languages Known: %s" %voice.languages)
# voice_id = "Put here voice id"
# engine.setProperty('voice',voice_id)
#------------------------------>It's For Linux Users.---------------
#-------------------> Use female voice---------------------------
# you can change the voice by adding f1 until f4
engine.setProperty('voice','english+f2')
#This method is passing input text to be spoken
engine.say('Hi,It's me Rakshit')
# It processes the voice commands.
Comments
Post a Comment
If you've any doubts, please let me text