def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Training monitor (check every {0} secs):'.format(args.sleep)
    while True:
        response, _ = hutoma.current_status(aiid)
        print '\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format(**response)
        print '\tScore: {score:s}'.format(**response)
        print '\tAIid: {0}'.format(aiid)
        if response.get('trainingStatus ', -1) < 3:
            print 'Training ended...'
            break
        time.sleep(args.sleep)

    print 'API calls: {0}'.format(hutoma.api_calls_count())
Beispiel #2
0
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Training monitor (check every {0} secs):'.format(args.sleep)
    while True:
        response, _ = hutoma.current_status(aiid)
        print '\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format(
            **response)
        print '\tScore: {score:s}'.format(**response)
        print '\tAIid: {0}'.format(aiid)
        if response.get('trainingStatus ', -1) < 3:
            print 'Training ended...'
            break
        time.sleep(args.sleep)

    print 'API calls: {0}'.format(hutoma.api_calls_count())
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    input = raw_input('Attention! this will delete all existing AIs (type "quit" to exit): ')
    if "quit" in input:
        return

    # get the list of available AIs
    ais = hutoma.list_ai()
    print "AIs list: {0}".format(ais)
    for ai in ais:
        print "deleting {0}...".format(ai)
        hutoma.delete_ai(ai)

    ais = hutoma.create_ai()
    print "New AI created: {0}".format(ais)

    aiid = ais[0]
    print "AI id: {0}".format(aiid)

    print "Upload data files..."
    hutoma.training_upload_files(aiid, args.source_file, args.target_file)

    print "Training monitor (check every {0} secs):".format(args.sleep)

    print "Start training..."
    start_time = time.time()
    response, _ = hutoma.training_start(aiid)
    print "\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}".format(**response)
    print "\tScore: {score:s}".format(**response)
    print "\tAIid: {0}".format(aiid)

    while response.get("trainingStatus ", -1) < 3:
        time.sleep(args.sleep)
        response, _ = hutoma.current_status(aiid)
        print
        print "\n\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}".format(**response)
        print "\tScore: {score:s}".format(**response)
        print "\tAIid: {0}".format(aiid)
    print "{0} secs to train".format(int(time.time() - start_time))

    print "API calls: {0}".format(hutoma.api_calls_count())
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Hit Ctrl+C to quit...'

    while True:
        q = raw_input('Human: ')
        q = ''.join(ch for ch in q if ch not in set(string.punctuation)).strip()
        print '   AI: {0}'.format(hutoma.chat(aiid, 12345, q))
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Hit Ctrl+C to quit...'

    while True:
        q = raw_input('Human: ')
        q = ''.join(ch for ch in q
                    if ch not in set(string.punctuation)).strip()
        print '   AI: {0}'.format(hutoma.chat(aiid, 12345, q))
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Hit Ctrl+C to quit...'

    record = RecordAudio()
    play = PlayAudio()

    while True:
        path = '../data/{0}.wav'.format(generate_filename('human'))
        print 'Human: recording in progress... ',
        record.record_to_file(path)
        print 'Done'

        print 'AI thinking... '
        response = hutoma.speak(aiid, 12345, path)
        print 'AI: {0}'.format(response['output'])
        path = '../data/{0}.wav'.format(generate_filename('human'))
        with open(path, 'wb') as fin:
            fin.write(response['tts'])
        fin.close()
        print 'AI: speaking...',
        play.play_wav_file(path)
        print 'Done'
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    aiid = args.aiid
    if not aiid:
        # get the list of available AIs
        ais = hutoma.list_ai()
        print 'AIs list: {0}'.format(ais)
        if len(ais) == 0:
            print 'No AIs is available...'
            return
        aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Hit Ctrl+C to quit...'

    record = RecordAudio()
    play = PlayAudio()

    while True:
        path = '../data/{0}.wav'.format(generate_filename('human'))
        print 'Human: recording in progress... ',
        record.record_to_file(path)
        print 'Done'

        print 'AI thinking... '
        response = hutoma.speak(aiid, 12345, path)
        print 'AI: {0}'.format(response['output'])
        path = '../data/{0}.wav'.format(generate_filename('human'))
        with open(path, 'wb') as fin:
            fin.write(response['tts'])
        fin.close()
        print 'AI: speaking...',
        play.play_wav_file(path)
        print 'Done'
    def test(self):
        hutoma = EasyHutoma(USER_KEY)

        try:
            # get the list of AIs
            ais = hutoma.list_ai()
            self.assertTrue(isinstance(ais, list))

            # if no AIs create one
            if len(ais) == 0:
                ais = hutoma.create_ai()
            self.assertTrue(len(ais) > 0)

            # test deletion
            old_len = len(ais)
            ais = hutoma.delete_ai(ais[0])
            self.assertEqual(len(ais), old_len - 1)

            # ensure at least 1 AI
            if len(ais) == 0:
                ais = hutoma.create_ai()

        except HutomaException as e:
            logging.warn(e.message)
def main():
    args = add_args()

    hutoma = EasyHutoma(args.user_key)

    input = raw_input(
        'Attention! this will delete all existing AIs (type "quit" to exit): ')
    if 'quit' in input:
        return

    # get the list of available AIs
    ais = hutoma.list_ai()
    print 'AIs list: {0}'.format(ais)
    for ai in ais:
        print 'deleting {0}...'.format(ai)
        hutoma.delete_ai(ai)

    ais = hutoma.create_ai()
    print 'New AI created: {0}'.format(ais)

    aiid = ais[0]
    print 'AI id: {0}'.format(aiid)

    print 'Upload data files...'
    hutoma.training_upload_files(aiid, args.source_file, args.target_file)

    print 'Training monitor (check every {0} secs):'.format(args.sleep)

    print 'Start training...'
    start_time = time.time()
    response, _ = hutoma.training_start(aiid)
    print '\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format(
        **response)
    print '\tScore: {score:s}'.format(**response)
    print '\tAIid: {0}'.format(aiid)

    while response.get('trainingStatus ', -1) < 3:
        time.sleep(args.sleep)
        response, _ = hutoma.current_status(aiid)
        print
        print '\n\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format(
            **response)
        print '\tScore: {score:s}'.format(**response)
        print '\tAIid: {0}'.format(aiid)
    print '{0} secs to train'.format(int(time.time() - start_time))

    print 'API calls: {0}'.format(hutoma.api_calls_count())