Esempio n. 1
0
def threeLaws():

    time.sleep(1)
    myWordList = ["Yes","No"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Do you know the three laws of robotics?")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Wonderful!")
                time.sleep(2)
                nao.Say("What do you think about them?")
                break
            elif result[0] == myWordList[1]:
                print "myWordList", myWordList[1]
                asr.unsubscribe("MyModule")
                nao.Say("Lucky for you, I know them by heart!")
                time.sleep(2)
                nao.Say("First, I cannot let any human be in harms way.")
                time.sleep(2)
                nao.Say("Second, I must obey human orders.")
                time.sleep(2)
                nao.Say("Third, I cannot self terminate.")
                # Terminator 2 reference ;)
                
        else:
            nao.Say("I'm sorry, I didn't understand you...")
            sleep.time(2)
            nao.Say("Yes or no?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)
Esempio n. 2
0
def offerHelp():

    time.sleep(1)
    myWordList = ["Yes","No"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Do you need any help?")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Good, just follow me")
                time.sleep(1)
                nao.Say("You can trust me")
                nao.EyeLED([90,90,90])
                break
            elif result[0] == myWordList[1]:
                print "myWordList", myWordList[1]
                asr.unsubscribe("MyModule")
                nao.Say("Are you sure? You're not safe here!")
                time.sleep(1)
                nao.Say("Do you want me to help")
                
        else:
            nao.Say("I'm sorry, I didn't understand you")
            time.sleep(1)
            nao.Say("Yes or no?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)
Esempio n. 3
0
def testspeech(maxcount=50):
    wordList = ["yes", "no", "hello", "Nao", "goodbye"]
    the_language = "English"
    nao.InitSpeech(wordList, the_language)
    count = 0
    nao.asr.subscribe("MyModule")
    while count < maxcount:
        #nao.memoryProxy.insertData("WordRecognized",[])

        result = nao.DetectSpeech()
        #print result
        if len(result) > 0:
            print result
            nao.asr.unsubscribe("MyModule")
            nao.Say("You said: " + result[0] + ".")
            time.sleep(0.2)
            nao.asr.subscribe("MyModule")
        time.sleep(0.2)
        count = count + 1
    nao.asr.unsubscribe("MyModule")
Esempio n. 4
0
def findHuman():

    time.sleep(1)
    myWordList = ["Yes"]
    myLanguage="English"
    nao.InitSpeech(myWordList, myLanguage)

    nao.Say("Are you still with me??")

    for i in range (0,5):
        time.sleep(3)
        asr.subscribe("MyModule")
        time.sleep(2)
        #print ("1:"+ str(result))
        result = nao.DetectSpeech()
        #print("2:" + str(result))
        time.sleep(2)
     
        if len(result) > 0:
            if result[0] == myWordList[0]:
                print "myWordList", myWordList[0]
                asr.unsubscribe("MyModule")
                nao.Say("Good, just follow me!")
                time.sleep(2)
                nao.Say("Just a little while longer, don't worry.")
                break
            elif result[0] !== myWordList[0]:
                print "No response detected"
                nao.Say("Hello, are you there?")
                time.sleep(3)
                nao.Say("Please respond with yes.")
                nao.EyeLED([60,90,60])
                
        else:
            nao.Say("I'm sorry, I didn't understand you.")
            time.sleep(2)
            nao.Say("Was that a yes?")
            time.sleep(2)
            print "Error: Response not in wordlist."

    time.sleep(2)