@@ -19,10 +19,26 @@ def main(args):
1919 # List files in that dir
2020 sound_paths = glob .glob (os .path .join (subdir , '**/*.wav' ),
2121 recursive = True )
22- print (f'Augmenting { subdir } files' )
23- # Transform audio speed
24- augment_noise (sound_paths , 0.8 )
25- augment_noise (sound_paths , 1.2 )
22+ # Avoid running this script if it already have been run
23+ if len (sound_paths ) == 60000 :
24+ print ("It appears that augmented files have already been generated.\n "
25+ "Skipping data augmentation." )
26+ return
27+ elif len (sound_paths ) != 20000 :
28+ print ("It appears that augmented files have not been generated properly\n "
29+ "Resuming augmentation." )
30+ originals = [x for x in sound_paths if 'sp' not in x ]
31+ to_be_removed_08 = [x .replace ('sp08' ,'' ) for x in sound_paths if 'sp08' in x ]
32+ to_be_removed_12 = [x .replace ('sp12' ,'' ) for x in sound_paths if 'sp12' in x ]
33+ sound_paths_08 = list (set (originals ) - set (to_be_removed_08 ))
34+ sound_paths_12 = list (set (originals ) - set (to_be_removed_12 ))
35+ augment_noise (sound_paths_08 , 0.8 )
36+ augment_noise (sound_paths_12 , 1.2 )
37+ else :
38+ print (f'Augmenting { subdir } files' )
39+ # Transform audio speed
40+ augment_noise (sound_paths , 0.8 )
41+ augment_noise (sound_paths , 1.2 )
2642
2743
2844def augment_noise (sound_paths , speed ):
0 commit comments