Loading tests/create_short_testvectors.py +34 −7 Original line number Diff line number Diff line Loading @@ -95,18 +95,22 @@ def collect_files(use_ltv: bool = False, ltv_dir: Path = None): return files def create_short_testvectors(cut_len=5.0, use_ltv: bool = False, ltv_dir: Path = None): def create_short_testvectors( cut_len=5.0, use_ltv: bool = False, ltv_dir: Path = None, inplace: bool = False ): files = collect_files(use_ltv, ltv_dir) for f in files: suffix = "" if use_ltv else "_cut" suffix = "" if use_ltv or inplace else "_cut" out_file = TEST_VECTOR_DIR.joinpath(f.stem + suffix + f.suffix) num_channels = audiofile.get_wav_file_info(f)["channels"] cut_samples(f, out_file, num_channels, CUT_FROM, f"{cut_len}", GAIN) if __name__ == "__main__": parser = argparse.ArgumentParser() parser = argparse.ArgumentParser( description="Cut all stv/ltv signals to a given shorter length" ) def positive_float(x: str) -> float: x = float(x) Loading @@ -114,8 +118,31 @@ if __name__ == "__main__": raise ValueError("Value for cut_len needs to be positive!") return x parser.add_argument("--cut_len", type=positive_float, default=5.0) parser.add_argument("--use_ltv", action="store_true", default=False) parser.add_argument("--ltv_dir", type=Path) parser.add_argument( "--cut_len", type=positive_float, default=5.0, help="Length to cut files to" ) parser.add_argument( "--use_ltv", action="store_true", default=False, help="Operate on LTV files instead of the shorter ones. This implicitly also sets INPLACE (to be backwards-compatible).", ) parser.add_argument( "--ltv_dir", type=Path, default=None, help="Path to the LTV file directory. Needed when using USE_LTV.", ) parser.add_argument( "--inplace", action="store_true", default=False, help="Set this to operate inplace (i.e. overwrite the signals, instead of creating new ones with _cut suffix)", ) args = parser.parse_args() sys.exit(create_short_testvectors(args.cut_len, args.use_ltv, args.ltv_dir)) assert not (args.use_ltv and args.ltv_dir is None) sys.exit( create_short_testvectors(args.cut_len, args.use_ltv, args.ltv_dir, args.inplace) ) Loading
tests/create_short_testvectors.py +34 −7 Original line number Diff line number Diff line Loading @@ -95,18 +95,22 @@ def collect_files(use_ltv: bool = False, ltv_dir: Path = None): return files def create_short_testvectors(cut_len=5.0, use_ltv: bool = False, ltv_dir: Path = None): def create_short_testvectors( cut_len=5.0, use_ltv: bool = False, ltv_dir: Path = None, inplace: bool = False ): files = collect_files(use_ltv, ltv_dir) for f in files: suffix = "" if use_ltv else "_cut" suffix = "" if use_ltv or inplace else "_cut" out_file = TEST_VECTOR_DIR.joinpath(f.stem + suffix + f.suffix) num_channels = audiofile.get_wav_file_info(f)["channels"] cut_samples(f, out_file, num_channels, CUT_FROM, f"{cut_len}", GAIN) if __name__ == "__main__": parser = argparse.ArgumentParser() parser = argparse.ArgumentParser( description="Cut all stv/ltv signals to a given shorter length" ) def positive_float(x: str) -> float: x = float(x) Loading @@ -114,8 +118,31 @@ if __name__ == "__main__": raise ValueError("Value for cut_len needs to be positive!") return x parser.add_argument("--cut_len", type=positive_float, default=5.0) parser.add_argument("--use_ltv", action="store_true", default=False) parser.add_argument("--ltv_dir", type=Path) parser.add_argument( "--cut_len", type=positive_float, default=5.0, help="Length to cut files to" ) parser.add_argument( "--use_ltv", action="store_true", default=False, help="Operate on LTV files instead of the shorter ones. This implicitly also sets INPLACE (to be backwards-compatible).", ) parser.add_argument( "--ltv_dir", type=Path, default=None, help="Path to the LTV file directory. Needed when using USE_LTV.", ) parser.add_argument( "--inplace", action="store_true", default=False, help="Set this to operate inplace (i.e. overwrite the signals, instead of creating new ones with _cut suffix)", ) args = parser.parse_args() sys.exit(create_short_testvectors(args.cut_len, args.use_ltv, args.ltv_dir)) assert not (args.use_ltv and args.ltv_dir is None) sys.exit( create_short_testvectors(args.cut_len, args.use_ltv, args.ltv_dir, args.inplace) )