12
12
import os
13
13
import h5py
14
14
import shutil
15
- import tempfile
15
+ import argparse
16
16
17
17
from abnet3 .utils import read_vad_file , read_feats , Features_Accessor
18
18
@@ -397,3 +397,45 @@ def generate(self):
397
397
shutil .copy (h5_temp2 , self .output_path )
398
398
finally :
399
399
shutil .rmtree (tempdir )
400
+
401
+
402
+ def main ():
403
+ parser = argparse .ArgumentParser ()
404
+
405
+ parser .add_argument ("wav_dir" , help = "Path to wav directory" )
406
+ parser .add_argument ("output_path" , help = "Path to output h5f file" )
407
+ parser .add_argument ("method" , choices = ["mfcc" , "fbanks" ],
408
+ help = "which features to generate" )
409
+ parser .add_argument ("--vad" , help = "Path to vad file "
410
+ "(CSV, seconds with header)" )
411
+ parser .add_argument ("--normalization" , "-n" , action = "store_true" )
412
+ parser .add_argument ("--norm-per-file" , action = "store_true" ,
413
+ help = "Independent normalization for each file" )
414
+ parser .add_argument ("--norm-per-channel" , action = "store_true" ,
415
+ help = "Normalize each channel independently" )
416
+ parser .add_argument ("--n-filters" , type = int , default = 40 )
417
+ parser .add_argument ("--save-mean-var" , type = str ,
418
+ help = "Path to emplacement where mean / var"
419
+ "will be saved" )
420
+ parser .add_argument ("--load-mean-var" , type = str ,
421
+ help = "Path to emplacement where mean / var"
422
+ "are saved. Will be used to compute test features" )
423
+
424
+ args = parser .parse_args ()
425
+ features_generator = FeaturesGenerator (
426
+ files = args .wav_dir ,
427
+ output_path = args .output_path ,
428
+ method = args .method ,
429
+ n_filters = args .n_filters ,
430
+ save_mean_variance_path = args .save_mean_var ,
431
+ load_mean_variance_path = args .load_mean_var ,
432
+ vad_file = args .vad ,
433
+ normalization = args .normalization ,
434
+ norm_per_file = args .norm_per_file ,
435
+ norm_per_channel = args .norm_per_channel ,
436
+ )
437
+
438
+ features_generator .generate ()
439
+
440
+ if __name__ == '__main__' :
441
+ main ()
0 commit comments