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

Method collater

tasks/tts/pe.py:70–98  ·  view source on GitHub ↗
(self, samples)

Source from the content-addressed store, hash-verified

68 return sample
69
70 def collater(self, samples):
71 if len(samples) == 0:
72 return {}
73 id = torch.LongTensor([s['id'] for s in samples])
74 item_names = [s['item_name'] for s in samples]
75 text = [s['text'] for s in samples]
76 f0 = utils.collate_1d([s['f0'] for s in samples], 0.0)
77 pitch = utils.collate_1d([s['pitch'] for s in samples])
78 uv = utils.collate_1d([s['uv'] for s in samples])
79 mels = utils.collate_2d([s['mel'] for s in samples], 0.0)
80 mel_lengths = torch.LongTensor([s['mel'].shape[0] for s in samples])
81 # mel2ph = utils.collate_1d([s['mel2ph'] for s in samples], 0.0) \
82 # if samples[0]['mel2ph'] is not None else None
83 # mel_nonpaddings = utils.collate_1d([s['mel_nonpadding'].float() for s in samples], 0.0)
84
85 batch = {
86 'id': id,
87 'item_name': item_names,
88 'nsamples': len(samples),
89 'text': text,
90 'mels': mels,
91 'mel_lengths': mel_lengths,
92 'pitch': pitch,
93 # 'mel2ph': mel2ph,
94 # 'mel_nonpaddings': mel_nonpaddings,
95 'f0': f0,
96 'uv': uv,
97 }
98 return batch
99
100
101class PitchExtractionTask(FastSpeech2Task):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected