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

Method test_step

tasks/tts/fs2.py:340–363  ·  view source on GitHub ↗
(self, sample, batch_idx)

Source from the content-addressed store, hash-verified

338 # infer
339 ############
340 def test_step(self, sample, batch_idx):
341 spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids')
342 txt_tokens = sample['txt_tokens']
343 mel2ph, uv, f0 = None, None, None
344 ref_mels = None
345 if hparams['profile_infer']:
346 pass
347 else:
348 if hparams['use_gt_dur']:
349 mel2ph = sample['mel2ph']
350 if hparams['use_gt_f0']:
351 f0 = sample['f0']
352 uv = sample['uv']
353 outputs = self.model(
354 txt_tokens, spk_embed=spk_embed, mel2ph=mel2ph, f0=f0, uv=uv, ref_mels=ref_mels, infer=True)
355 sample['outputs'] = self.model.out2mel(outputs['mel_out'])
356 sample['mel2ph_pred'] = outputs['mel2ph']
357 if hparams.get('pe_enable') is not None and hparams['pe_enable']:
358 sample['f0'] = self.pe(sample['mels'])['f0_denorm_pred'] # pe predict from GT mel
359 sample['f0_pred'] = self.pe(sample['outputs'])['f0_denorm_pred'] # pe predict from Pred mel
360 else:
361 sample['f0'] = denorm_f0(sample['f0'], sample['uv'], hparams)
362 sample['f0_pred'] = outputs.get('f0_denorm')
363 return self.after_infer(sample)
364
365 def after_infer(self, predictions):
366 if self.saving_result_pool is None and not hparams['profile_infer']:

Callers

nothing calls this directly

Calls 3

after_inferMethod · 0.95
denorm_f0Function · 0.90
out2melMethod · 0.45

Tested by

no test coverage detected