Next Step

Once the respective actions based on user speech are performed the control fall backs to to NextStep flow wherein Aryan asks users in case of any next set of actions that needs to be performed before going to sleep again.

Do you want to search for anything else?

PrintText(aifriend, "Do you want to search for anything else?")
SpeakText(aifriend,"Do you want to search for anything else?")

r = sr.Recognizer()

with sr.Microphone() as source:  
 
     audio = r.listen(source) 
     speech = r.recognize_google(audio)

On Basis of User response after text transformation, following actions are taken

If response is Yes, then Aryan asks Human on what else I can do and SpeechRecognization flow is triggered to listen to user and take the necessary steps.

if subStrCheck(transformedSpeech,"yes"):

    PrintText(aifriend, "What else i can do?")
    SpeakText(aifriend,"What else i can do?")
    SpeechRecognization(aifriend)

If response is No or Thank you, then the AI worker scripts exits, AI Master after this graceful exit falls back to Sleeping mode.

elif subStrCheck(transformedSpeech,"no") or subStrCheck(transformedSpeech, "thankyou") or subStrCheck(transformedSpeech, "thanks") or subStrCheck(transformedSpeech, "thank"):

    PrintText(aifriend, "Okay")
    SpeakText(aifriend,"Okay")
    exit()

If Human response is neither yes nor no, but some thing else, thereafter the transformed text is used to trigger the Speech Action flow to perform the set of actions per Human request.

elif len(transformedSpeech) > 0:   

detailFlag = "N"
    # DetailFlag is assigned a value of Y, in case detail keyword is mentioned in the Human command and thereafter Speech Action Function is triggered.
    if subStrCheck(transformedSpeech.lower(),"detail"):
        detailFlag = "Y"
        SpeechAction(speech,transformedSpeech,detailFlag,aifriend)

    SpeechAction(speech,transformedSpeech,detailFlag,aifriend)

Last updated