I am trying to make a personal assistant for python named "Sansa". I am a noob and I want my code to execute my initial_request variable only if users raw_input is yes. If it is no I want the code to execute the last engine.say command. I tried to achieve this using a dictionary. Thanks and sorry for the messy code.
import webbrowser
import pyttsx
#adding voice (i will change)
engine = pyttsx.init()
engine = pyttsx.init()
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id)
#Introducing Sansa and trying to navigate through the codes.
#serviceP =input
first_answer = {'pos' : 'Yes', 'neg' : 'No'}
response = engine.say("Hello my Lord. My name is Sansa and I am your personal assistant. I am here to serve you. Can I be of service?")
engine.runAndWait()
st = raw_input("Hello my Lord. My name is Sansa and I am your personal assistant. I am here to serve you. Can I be of service?")
initial_Request =('What would you like to do? I can visit various websites, perform a google or youtube search, and so much more.')
#evaluate yes or no to execute initial_Request
if st == first_answer['pos']:
engine.say(initial_Request)
engine.runAndWait()
elif st == first_answer['neg']:
engine.say("Ok. I'm here if you need me.")
engine.runAndWait()
Aucun commentaire:
Enregistrer un commentaire