MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / __init__

Method __init__

tasks/tts/fs2_utils.py:24–51  ·  view source on GitHub ↗
(self, prefix, shuffle=False)

Source from the content-addressed store, hash-verified

22
23class 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:

Callers

nothing calls this directly

Calls 2

load_test_inputsMethod · 0.95
get_lf0_cwtFunction · 0.90

Tested by

no test coverage detected