| | |
| | | import numpy as np |
| | | import torch.distributed as dist |
| | | import torchaudio |
| | | import soundfile |
| | | |
| | | |
| | | def filter_wav_text(data_dir, dataset): |
| | |
| | | |
| | | |
| | | def wav2num_frame(wav_path, frontend_conf): |
| | | waveform, sampling_rate = torchaudio.load(wav_path) |
| | | try: |
| | | waveform, sampling_rate = torchaudio.load(wav_path) |
| | | except: |
| | | waveform, sampling_rate = soundfile.read(wav_path) |
| | | waveform = np.expand_dims(waveform, axis=0) |
| | | n_frames = (waveform.shape[1] * 1000.0) / (sampling_rate * frontend_conf["frame_shift"] * frontend_conf["lfr_n"]) |
| | | feature_dim = frontend_conf["n_mels"] * frontend_conf["lfr_m"] |
| | | return n_frames, feature_dim |
| | |
| | | for i in range(nj): |
| | | path = "" |
| | | for file_name in file_names: |
| | | path = path + os.path.join(split_path, str(i + 1), file_name) |
| | | path = path + " " + os.path.join(split_path, str(i + 1), file_name) |
| | | f_data.write(path + "\n") |
| | | |
| | | |
| | |
| | | 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(",") |
| | | 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": |
| | | args.train_shape_file = [os.path.join(args.data_dir, args.train_set, "{}_shape".format(data_names[0]))] |
| | | args.valid_shape_file = [os.path.join(args.data_dir, args.valid_set, "{}}_shape".format(data_names[0]))] |
| | | args.valid_shape_file = [os.path.join(args.data_dir, args.valid_set, "{}_shape".format(data_names[0]))] |
| | | args.train_data_path_and_name_and_type, args.valid_data_path_and_name_and_type = [], [] |
| | | for file_name, data_name, data_type in zip(file_names, data_names, data_types): |
| | | args.train_data_path_and_name_and_type.append( |