Exemplo n.º 1
0
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hu:c:",
                                   ["help", "units=", "current_city="])
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)

    print "This is an art installation project that generate visual effects based on sound input."

    stopped = False
    while not stopped:

        # Step 1: get the user input
        user_input = get_google_asr()
        user_input = user_input.lower()
        words = user_input.split()

        for word in words:
            if (len(word) <= 15):
                length = len(word)
            else:
                length = 15

            i = int(random.randrange(0, 256))
            # showCentralDot(w[length], (i*i%255, i*i*i%255, i*i*i*i%255))
            for index in range(1, (length + 1)):
                i = int(random.randrange(0, 256))
                showCentralDot(w[index], (i*i%255, i*i*i%255, i*i*i*i%255))
            time.sleep(0.5)
Exemplo n.º 2
0
#L# user_input = get_google_asr()
  # parse location
  # parse date
  # parse weather or NOT weather -- "ask me weather-related questions."
  # answering
  # continue / exit


        # Step 1-0: user_city_input
        print ""
        tenkiba1 = "What city you would like to know?"
        print "--What city you would like to know?"
        tts(tenkiba1)

        # Step 1-1: get the user input from microphone and send it to Google API
        user_city_input = get_google_asr()

        # GOODBYE or NOT GOODBYE? #
        if user_city_input == "goodbye":
            print " [ Goodbye ] "
            tenkiba1_1 = "I heard you. Have a nice day! Goodbye."
            print tenkiba1_1
            print ""
            print "* * * * * * * * * * * * * * * * * * * * * * * * *"
            tts(tenkiba1_1)
            sys.exit()
            # break # exit the loop right away

        # Step 1-2: parse user_city_input
        result = ""
        tokens = nltk.word_tokenize(user_city_input)