(self, prefix, shuffle=False)
| 22 | |
| 23 | class FastSpeechDataset(BaseDataset): |
| 24 | def __init__(self, prefix, shuffle=False): |
| 25 | super().__init__(shuffle) |
| 26 | self.data_dir = hparams['binary_data_dir'] |
| 27 | self.prefix = prefix |
| 28 | self.hparams = hparams |
| 29 | self.sizes = np.load(f'{self.data_dir}/{self.prefix}_lengths.npy') |
| 30 | self.indexed_ds = None |
| 31 | # self.name2spk_id={} |
| 32 | |
| 33 | # pitch stats |
| 34 | f0_stats_fn = f'{self.data_dir}/train_f0s_mean_std.npy' |
| 35 | if os.path.exists(f0_stats_fn): |
| 36 | hparams['f0_mean'], hparams['f0_std'] = self.f0_mean, self.f0_std = np.load(f0_stats_fn) |
| 37 | hparams['f0_mean'] = float(hparams['f0_mean']) |
| 38 | hparams['f0_std'] = float(hparams['f0_std']) |
| 39 | else: |
| 40 | hparams['f0_mean'], hparams['f0_std'] = self.f0_mean, self.f0_std = None, None |
| 41 | |
| 42 | if prefix == 'test': |
| 43 | if hparams['test_input_dir'] != '': |
| 44 | self.indexed_ds, self.sizes = self.load_test_inputs(hparams['test_input_dir']) |
| 45 | else: |
| 46 | if hparams['num_test_samples'] > 0: |
| 47 | self.avail_idxs = list(range(hparams['num_test_samples'])) + hparams['test_ids'] |
| 48 | self.sizes = [self.sizes[i] for i in self.avail_idxs] |
| 49 | |
| 50 | if hparams['pitch_type'] == 'cwt': |
| 51 | _, hparams['cwt_scales'] = get_lf0_cwt(np.ones(10)) |
| 52 | |
| 53 | def _get_item(self, index): |
| 54 | if hasattr(self, 'avail_idxs') and self.avail_idxs is not None: |
nothing calls this directly
no test coverage detected