예제 #1
0
        print("Unknown error")
        mode = "error"

    if mode == "error":
        message = "Error downloading the image."
        text_to_speech(message)
    elif mode == "face_training":
        if fr.train_on_image(str(person_name), str(image_save_path), True):
            message = "Image saved !"        
            fr.save_to_file(loaded_dataset_path)
        else:
            message = "No face found :("        
        text_to_speech(message)
    else:
        try:
            res = fr.face_detection(image_save_path, True, 0.2, 0.4)
            message = res[0][1]
            print("result : " + str(res))
            for i in res:
                if i[0]: text_to_speech("Welcome " + str(i[1]))
            if len(res) == 1 and res[0][0] == False:
                text_to_speech(message)
        except:
            message = "Error, image corrupted"
            text_to_speech(message)
            print(message)
    
    s.sendto(message.encode(), addr)
    
    print(message)
    s.close()