<jupyter_start><jupyter_text>Load metadata and get label list<jupyter_code>metadatafile = '/home/t-anmend/UrbanSound8K/metadata/UrbanSound8K.csv'
metadata = pd.read_csv(metadatafile)
label_list = sorted(metadata['class'].unique())
print(label_list)<jupyter_output>['air_conditioner', 'car_horn', 'children_playing', 'dog_bark', 'drilling', 'engine_idling', 'gun_shot', 'jackhammer', 'siren', 'street_music']<jupyter_text>Create soundbank for TRAIN 1 (folds 1-9)<jupyter_code>folds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
splitname = 'train_1'

soundbankfolder = '/home/t-anmend/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/home/t-anmend/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            print(destfolder)

            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>4%|▍         | 37/873 [00:00<00:02, 358.54it/s]<jupyter_text>Create soundbank for TEST 1 (folds 10)<jupyter_code>folds = [10]
splitname = 'test_1'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>1%|          | 8/765 [00:00<00:09, 77.56it/s]<jupyter_text>Create soundbank for TRAIN_2 (folds 1-8, 10)<jupyter_code>folds = [1, 2, 3, 4, 5, 6, 7, 8, 10]
splitname = 'train_2'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>3%|▎         | 22/766 [00:00<00:03, 211.94it/s]<jupyter_text>Create soundbank for TEST 2 (folds 9)<jupyter_code>folds = [9]
splitname = 'test_2'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 13/779 [00:00<00:06, 124.46it/s]<jupyter_text>Create soundbank for TRAIN_3 (folds 1-7, 9-10)<jupyter_code>folds = [1, 2, 3, 4, 5, 6, 7, 9, 10]
splitname = 'train_3'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 15/766 [00:00<00:05, 149.81it/s]<jupyter_text>Create soundbank for TEST 3 (folds 8)<jupyter_code>folds = [8]
splitname = 'test_3'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>3%|▎         | 19/732 [00:00<00:03, 181.03it/s]<jupyter_text>Create soundbank for TRAIN_4 (folds 1-6, 8-10)<jupyter_code>folds = [1, 2, 3, 4, 5, 6, 8, 9, 10]
splitname = 'train_4'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 17/766 [00:00<00:04, 165.25it/s]<jupyter_text>Create soundbank for TEST 2 (folds 7)<jupyter_code>folds = [7]
splitname = 'test_4'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>1%|          | 8/807 [00:00<00:11, 70.59it/s]<jupyter_text>Create soundbank for TRAIN_5 (folds 1-5, 7-10)<jupyter_code>folds = [1, 2, 3, 4, 5, 7, 8, 9, 10]
splitname = 'train_5'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 16/766 [00:00<00:04, 157.31it/s]<jupyter_text>Create soundbank for TEST 5 (folds 6)<jupyter_code>folds = [6]
splitname = 'test_5'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 17/807 [00:00<00:04, 167.00it/s]<jupyter_text>Create soundbank for TRAIN_6 (folds 1-4, 6-10)<jupyter_code>folds = [1, 2, 3, 4, 6, 7, 8, 9, 10]
splitname = 'train_6'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>1%|▏         | 10/766 [00:00<00:08, 91.39it/s]<jupyter_text>Create soundbank for TEST_6 (folds 5)<jupyter_code>folds = [5]
splitname = 'test_6'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 20/902 [00:00<00:04, 194.97it/s]<jupyter_text>Create soundbank for TRAIN_7 (folds 1-3, 5-10)<jupyter_code>folds = [1, 2, 3, 5, 6, 7, 8, 9, 10]
splitname = 'train_7'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>3%|▎         | 22/766 [00:00<00:03, 214.46it/s]<jupyter_text>Create soundbank for TEST_7 (folds 4)<jupyter_code>folds = [4]
splitname = 'test_7'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 22/961 [00:00<00:04, 216.08it/s]<jupyter_text>Create soundbank for TRAIN_8 (folds 1-2, 4-10)<jupyter_code>folds = [1, 2, 4, 5, 6, 7, 8, 9, 10]
splitname = 'train_8'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>2%|▏         | 16/766 [00:00<00:05, 149.34it/s]<jupyter_text>Create soundbank for TEST_8 (folds 3)<jupyter_code>folds = [3]
splitname = 'test_8'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>0%|          | 0/918 [00:00<?, ?it/s][A
  1%|▏         | 13/918 [00:00<00:06, 129.32it/s][A<jupyter_text>Create soundbank for TRAIN_9 (folds 1, 3-10)<jupyter_code>folds = [1, 3, 4, 5, 6, 7, 8, 9, 10]
splitname = 'train_9'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>0%|          | 0/766 [00:00<?, ?it/s][A
  2%|▏         | 14/766 [00:00<00:05, 135.94it/s][A<jupyter_text>Create soundbank for TEST_9 (folds 2)<jupyter_code>folds = [2]
splitname = 'test_9'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>0%|          | 0/870 [00:00<?, ?it/s][A
  2%|▏         | 16/870 [00:00<00:05, 149.35it/s][A<jupyter_text>Create soundbank for TRAIN_10 (folds 2-10)<jupyter_code>folds = [2, 3, 4, 5, 6, 7, 8, 9, 10]
splitname = 'train_10'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))<jupyter_output>0%|          | 0/870 [00:00<?, ?it/s][A
  2%|▏         | 19/870 [00:00<00:04, 181.28it/s][A<jupyter_text>Create soundbank for TEST_10 (folds 1)<jupyter_code>folds = [1]
splitname = 'test_10'

soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'
soundbankfolder = os.path.join(soundbankfolder, splitname)

label_count = {}
for label in label_list:
    label_count[label] = 0

for fold in folds:
    
    print('FOLD {:d}'.format(fold))
    audiofolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/audio/fold{:d}/'.format(fold)
    audiofiles = glob.glob(os.path.join(audiofolder, '*.wav'))
    
    fold_label_count = {}
    for label in label_list:
        fold_label_count[label] = 0
    
    for af in tqdm(audiofiles):
        # print(os.path.basename(af))
        label = metadata.loc[metadata.slice_file_name == os.path.basename(af), 'class'].values[0]
        label_count[label] += 1
        fold_label_count[label] += 1
        destfolder = os.path.join(soundbankfolder, 'foreground', label)
        if not os.path.isdir(destfolder):
            os.mkdir(destfolder)
        destfile = os.path.join(destfolder, os.path.basename(af))
        shutil.copyfile(af, destfile)
        
    # Print fold report
    print('   Fold {:d} labels:'.format(fold))
    for label in label_list:
        print('   {:s}:\t{:d}'.format(label, fold_label_count[label]))
        
# Print overall report
print('\n\nOVERALL labels:')
for label in label_list:
    print('{:s}:\t{:d}'.format(label, label_count[label]))
noisefile = '/Users/anaemendezmendez/Downloads/3941__noisecollector__brown-noise.wav'
soundbankfolder = '/Users/anaemendezmendez/Documents/NYU_PHD/UrbanSound8K/soundbanks/'

for split in ['train', 'validate', 'test']:
    
    destfolder = os.path.join(soundbankfolder, split, 'background', 'noise')
    if not os.path.isdir(destfolder):
        os.mkdir(destfolder)
        
    destfile = os.path.join(destfolder, os.path.basename(noisefile))
    shutil.copyfile(noisefile, destfile)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14886578449905483, 'fraction_numerical': 0.023597983616887207, 'mean_word_length': 3.369029593943565, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '466663', 'license': 'MIT', 'n_tokens_mistral': 12237, 'n_tokens_neox': 11491, 'n_words': 1994, 'path': 'AudioLabeling/generate_soundbanks.ipynb', 'repo_name': 'Bhaskers-Blu-Org2/multilabel-clustering-audio', 'size': '31740'}