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

Method add_dur

modules/fastspeech/fs2.py:151–174  ·  view source on GitHub ↗

:param dur_input: [B, T_txt, H] :param mel2ph: [B, T_mel] :param txt_tokens: [B, T_txt] :param ret: :return:

(self, dur_input, mel2ph, txt_tokens, ret)

Source from the content-addressed store, hash-verified

149 return ret
150
151 def add_dur(self, dur_input, mel2ph, txt_tokens, ret):
152 """
153
154 :param dur_input: [B, T_txt, H]
155 :param mel2ph: [B, T_mel]
156 :param txt_tokens: [B, T_txt]
157 :param ret:
158 :return:
159 """
160 src_padding = txt_tokens == 0
161 dur_input = dur_input.detach() + hparams['predictor_grad'] * (dur_input - dur_input.detach())
162 if mel2ph is None:
163 dur, xs = self.dur_predictor.inference(dur_input, src_padding)
164 ret['dur'] = xs
165 ret['dur_choice'] = dur
166 mel2ph = self.length_regulator(dur, src_padding).detach()
167 # from modules.fastspeech.fake_modules import FakeLengthRegulator
168 # fake_lr = FakeLengthRegulator()
169 # fake_mel2ph = fake_lr(dur, (1 - src_padding.long()).sum(-1))[..., 0].detach()
170 # print(mel2ph == fake_mel2ph)
171 else:
172 ret['dur'] = self.dur_predictor(dur_input, src_padding)
173 ret['mel2ph'] = mel2ph
174 return mel2ph
175
176 def add_energy(self, decoder_inp, energy, ret):
177 decoder_inp = decoder_inp.detach() + hparams['predictor_grad'] * (decoder_inp - decoder_inp.detach())

Callers 1

forwardMethod · 0.95

Calls 1

inferenceMethod · 0.80

Tested by

no test coverage detected