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

Method __getitem__

tasks/tts/pe.py:48–68  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

46 return self.indexed_ds[index]
47
48 def __getitem__(self, index):
49 hparams = self.hparams
50 item = self._get_item(index)
51 max_frames = hparams['max_frames']
52 spec = torch.Tensor(item['mel'])[:max_frames]
53 # mel2ph = torch.LongTensor(item['mel2ph'])[:max_frames] if 'mel2ph' in item else None
54 f0, uv = norm_interp_f0(item["f0"][:max_frames], hparams)
55 pitch = torch.LongTensor(item.get("pitch"))[:max_frames]
56 # print(item.keys(), item['mel'].shape, spec.shape)
57 sample = {
58 "id": index,
59 "item_name": item['item_name'],
60 "text": item['txt'],
61 "mel": spec,
62 "pitch": pitch,
63 "f0": f0,
64 "uv": uv,
65 # "mel2ph": mel2ph,
66 # "mel_nonpadding": spec.abs().sum(-1) > 0,
67 }
68 return sample
69
70 def collater(self, samples):
71 if len(samples) == 0:

Callers

nothing calls this directly

Calls 2

_get_itemMethod · 0.95
norm_interp_f0Function · 0.90

Tested by

no test coverage detected