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

Method run_model

tasks/tts/fs2.py:111–138  ·  view source on GitHub ↗
(self, model, sample, return_output=False)

Source from the content-addressed store, hash-verified

109 return {k: round(v.avg, 4) for k, v in all_losses_meter.items()}
110
111 def run_model(self, model, sample, return_output=False):
112 txt_tokens = sample['txt_tokens'] # [B, T_t]
113 target = sample['mels'] # [B, T_s, 80]
114 mel2ph = sample['mel2ph'] # [B, T_s]
115 f0 = sample['f0']
116 uv = sample['uv']
117 energy = sample['energy']
118 spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids')
119 if hparams['pitch_type'] == 'cwt':
120 cwt_spec = sample[f'cwt_spec']
121 f0_mean = sample['f0_mean']
122 f0_std = sample['f0_std']
123 sample['f0_cwt'] = f0 = model.cwt2f0_norm(cwt_spec, f0_mean, f0_std, mel2ph)
124
125 output = model(txt_tokens, mel2ph=mel2ph, spk_embed=spk_embed,
126 ref_mels=target, f0=f0, uv=uv, energy=energy, infer=False)
127
128 losses = {}
129 self.add_mel_loss(output['mel_out'], target, losses)
130 self.add_dur_loss(output['dur'], mel2ph, txt_tokens, losses=losses)
131 if hparams['use_pitch_embed']:
132 self.add_pitch_loss(output, sample, losses)
133 if hparams['use_energy_embed']:
134 self.add_energy_loss(output['energy_pred'], energy, losses)
135 if not return_output:
136 return losses
137 else:
138 return losses, output
139
140 ############
141 # losses

Callers 2

_training_stepMethod · 0.95
validation_stepMethod · 0.95

Calls 5

add_mel_lossMethod · 0.95
add_dur_lossMethod · 0.95
add_pitch_lossMethod · 0.95
add_energy_lossMethod · 0.95
cwt2f0_normMethod · 0.45

Tested by

no test coverage detected