(self, model, sample, return_output=False, infer=False)
| 121 | # self.model.fs2.decoder = None |
| 122 | |
| 123 | def run_model(self, model, sample, return_output=False, infer=False): |
| 124 | txt_tokens = sample['txt_tokens'] # [B, T_t] |
| 125 | target = sample['mels'] # [B, T_s, 80] |
| 126 | mel2ph = sample['mel2ph'] # [B, T_s] |
| 127 | f0 = sample['f0'] |
| 128 | uv = sample['uv'] |
| 129 | energy = sample['energy'] |
| 130 | fs2_mel = None #sample['fs2_mels'] |
| 131 | spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids') |
| 132 | if hparams['pitch_type'] == 'cwt': |
| 133 | cwt_spec = sample[f'cwt_spec'] |
| 134 | f0_mean = sample['f0_mean'] |
| 135 | f0_std = sample['f0_std'] |
| 136 | sample['f0_cwt'] = f0 = model.cwt2f0_norm(cwt_spec, f0_mean, f0_std, mel2ph) |
| 137 | |
| 138 | output = model(txt_tokens, mel2ph=mel2ph, spk_embed=spk_embed, |
| 139 | ref_mels=[target, fs2_mel], f0=f0, uv=uv, energy=energy, infer=infer) |
| 140 | |
| 141 | losses = {} |
| 142 | if 'diff_loss' in output: |
| 143 | losses['mel'] = output['diff_loss'] |
| 144 | # self.add_dur_loss(output['dur'], mel2ph, txt_tokens, losses=losses) |
| 145 | # if hparams['use_pitch_embed']: |
| 146 | # self.add_pitch_loss(output, sample, losses) |
| 147 | if hparams['use_energy_embed']: |
| 148 | self.add_energy_loss(output['energy_pred'], energy, losses) |
| 149 | |
| 150 | if not return_output: |
| 151 | return losses |
| 152 | else: |
| 153 | return losses, output |
| 154 | |
| 155 | def validation_step(self, sample, batch_idx): |
| 156 | outputs = {} |
no test coverage detected