| | |
| | | |
| | | import kaldiio |
| | | import numpy as np |
| | | import soundfile |
| | | import torch.distributed as dist |
| | | import torchaudio |
| | | import soundfile |
| | | |
| | | |
| | | def filter_wav_text(data_dir, dataset): |
| | |
| | | sample_name, feature_path = line.strip().split() |
| | | feature = kaldiio.load_mat(feature_path) |
| | | n_frames, feature_dim = feature.shape |
| | | write_flag = True |
| | | if n_frames > 0 and length_min > 0: |
| | | write_flag = n_frames >= length_min |
| | | if n_frames > 0 and length_max > 0: |
| | |
| | | data_names = args.dataset_conf.get("data_names", "speech,text").split(",") |
| | | data_types = args.dataset_conf.get("data_types", "sound,text").split(",") |
| | | file_names = args.data_file_names.split(",") |
| | | batch_type = args.dataset_conf["batch_conf"]["batch_type"] |
| | | print("data_names: {}, data_types: {}, file_names: {}".format(data_names, data_types, file_names)) |
| | | assert len(data_names) == len(data_types) == len(file_names) |
| | | if args.dataset_type == "small": |
| | |
| | | filter_wav_text(args.data_dir, args.train_set) |
| | | filter_wav_text(args.data_dir, args.valid_set) |
| | | |
| | | if args.dataset_type == "small": |
| | | if args.dataset_type == "small" and batch_type != "unsorted": |
| | | calc_shape(args, args.train_set) |
| | | calc_shape(args, args.valid_set) |
| | | |