Skip to content

Commit

Permalink
abnet3-features to generate features easily
Browse files Browse the repository at this point in the history
  • Loading branch information
cdancette committed Jun 3, 2018
1 parent c984552 commit e345bfd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
44 changes: 43 additions & 1 deletion abnet3/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os
import h5py
import shutil
import tempfile
import argparse

from abnet3.utils import read_vad_file, read_feats, Features_Accessor

Expand Down Expand Up @@ -397,3 +397,45 @@ def generate(self):
shutil.copy(h5_temp2, self.output_path)
finally:
shutil.rmtree(tempdir)


def main():
parser = argparse.ArgumentParser()

parser.add_argument("wav_dir", help="Path to wav directory")
parser.add_argument("output_path", help="Path to output h5f file")
parser.add_argument("method", choices=["mfcc", "fbanks"],
help="which features to generate")
parser.add_argument("--vad", help="Path to vad file "
"(CSV, seconds with header)")
parser.add_argument("--normalization", "-n", action="store_true")
parser.add_argument("--norm-per-file", action="store_true",
help="Independent normalization for each file")
parser.add_argument("--norm-per-channel", action="store_true",
help="Normalize each channel independently")
parser.add_argument("--n-filters", type=int, default=40)
parser.add_argument("--save-mean-var", type=str,
help="Path to emplacement where mean / var"
"will be saved")
parser.add_argument("--load-mean-var", type=str,
help="Path to emplacement where mean / var"
"are saved. Will be used to compute test features")

args = parser.parse_args()
features_generator = FeaturesGenerator(
files=args.wav_dir,
output_path=args.output_path,
method=args.method,
n_filters=args.n_filters,
save_mean_variance_path=args.save_mean_var,
load_mean_variance_path=args.load_mean_var,
vad_file=args.vad,
normalization=args.normalization,
norm_per_file=args.norm_per_file,
norm_per_channel=args.norm_per_channel,
)

features_generator.generate()

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ def run(self):
entry_points={'console_scripts': [
'abnet3-gridsearch = abnet3.gridsearch:main',
'abnet3-embed = abnet3.tools.embed_cli:main',
'abnet3-features = abnet3.features:main',
]}
)

0 comments on commit e345bfd

Please sign in to comment.