(self, batch_idx, sample, model_out)
| 303 | f'dur_{batch_idx}', dur_to_figure(dur_gt, dur_pred, txt), self.global_step) |
| 304 | |
| 305 | def plot_pitch(self, batch_idx, sample, model_out): |
| 306 | f0 = sample['f0'] |
| 307 | if hparams['pitch_type'] == 'ph': |
| 308 | mel2ph = sample['mel2ph'] |
| 309 | f0 = self.expand_f0_ph(f0, mel2ph) |
| 310 | f0_pred = self.expand_f0_ph(model_out['pitch_pred'][:, :, 0], mel2ph) |
| 311 | self.logger.experiment.add_figure( |
| 312 | f'f0_{batch_idx}', f0_to_figure(f0[0], None, f0_pred[0]), self.global_step) |
| 313 | return |
| 314 | f0 = denorm_f0(f0, sample['uv'], hparams) |
| 315 | if hparams['pitch_type'] == 'cwt': |
| 316 | # cwt |
| 317 | cwt_out = model_out['cwt'] |
| 318 | cwt_spec = cwt_out[:, :, :10] |
| 319 | cwt = torch.cat([cwt_spec, sample['cwt_spec']], -1) |
| 320 | self.logger.experiment.add_figure(f'cwt_{batch_idx}', spec_to_figure(cwt[0]), self.global_step) |
| 321 | # f0 |
| 322 | f0_pred = cwt2f0(cwt_spec, model_out['f0_mean'], model_out['f0_std'], hparams['cwt_scales']) |
| 323 | if hparams['use_uv']: |
| 324 | assert cwt_out.shape[-1] == 11 |
| 325 | uv_pred = cwt_out[:, :, -1] > 0 |
| 326 | f0_pred[uv_pred > 0] = 0 |
| 327 | f0_cwt = denorm_f0(sample['f0_cwt'], sample['uv'], hparams) |
| 328 | self.logger.experiment.add_figure( |
| 329 | f'f0_{batch_idx}', f0_to_figure(f0[0], f0_cwt[0], f0_pred[0]), self.global_step) |
| 330 | elif hparams['pitch_type'] == 'frame': |
| 331 | # f0 |
| 332 | uv_pred = model_out['pitch_pred'][:, :, 1] > 0 |
| 333 | pitch_pred = denorm_f0(model_out['pitch_pred'][:, :, 0], uv_pred, hparams) |
| 334 | self.logger.experiment.add_figure( |
| 335 | f'f0_{batch_idx}', f0_to_figure(f0[0], None, pitch_pred[0]), self.global_step) |
| 336 | |
| 337 | ############ |
| 338 | # infer |
no test coverage detected