concept transcript in category machine learning

appears as: trscripts, trscript
Machine Learning with TensorFlow, Second Edition

This is an excerpt from Manning's book Machine Learning with TensorFlow, Second Edition.

Listing 17.4 Aggregate audio and transcripts and clean up
def move_files(from_path, to_path):
    if not os.path.exists(to_path):
        print("Creating dir %s" % (to_path)) #A
        os.makedirs(to_path)
    for root, _, files in os.walk(from_path):
        for file in files: #B
            path_to_file = os.path.join(root, file)
            base_file_path = os.path.dirname(file)
            to_path_file = to_path + '/' + file
            print("Moving file from %s to %s " % (path_to_file, to_path_file))
            shutil.move(path_to_file, to_path_file) #B
 
def remove_files_with_ext(directory, ext):
    for root, _, files in os.walk(directory): #C
        for file in files:
            if file.endswith(ext): #C
                path_to_file = os.path.join(root, file)
                print("Removing file %s " % (path_to_file))               
                os.remove(path_to_file) #C
 
remove_files_with_ext(train_path, "flac") #D
remove_files_with_ext(dev_path, "flac") #D
remove_files_with_ext(test_path, "flac") #D
 
move_files(train_path, all_train_path) #E
move_files(dev_path, all_dev_path) #E
move_files(test_path, all_test_path) #E
 
remove_files_with_ext(all_train_path, "trans.txt") #F
remove_files_with_ext(all_dev_path, "trans.txt") #F
remove_files_with_ext(all_test_path, "trans.txt") #F