MCPcopy Index your code
hub / github.com/MoonInTheRiver/DiffSinger / run_model

Method run_model

usr/diffspeech_task.py:48–78  ·  view source on GitHub ↗
(self, model, sample, return_output=False, infer=False)

Source from the content-addressed store, hash-verified

46 return optimizer
47
48 def run_model(self, model, sample, return_output=False, infer=False):
49 txt_tokens = sample['txt_tokens'] # [B, T_t]
50 target = sample['mels'] # [B, T_s, 80]
51 # mel2ph = sample['mel2ph'] if hparams['use_gt_dur'] else None # [B, T_s]
52 mel2ph = sample['mel2ph']
53 f0 = sample['f0']
54 uv = sample['uv']
55 energy = sample['energy']
56 # fs2_mel = sample['fs2_mels']
57 spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids')
58 if hparams['pitch_type'] == 'cwt':
59 cwt_spec = sample[f'cwt_spec']
60 f0_mean = sample['f0_mean']
61 f0_std = sample['f0_std']
62 sample['f0_cwt'] = f0 = model.cwt2f0_norm(cwt_spec, f0_mean, f0_std, mel2ph)
63
64 output = model(txt_tokens, mel2ph=mel2ph, spk_embed=spk_embed,
65 ref_mels=target, f0=f0, uv=uv, energy=energy, infer=infer)
66
67 losses = {}
68 if 'diff_loss' in output:
69 losses['mel'] = output['diff_loss']
70 self.add_dur_loss(output['dur'], mel2ph, txt_tokens, losses=losses)
71 if hparams['use_pitch_embed']:
72 self.add_pitch_loss(output, sample, losses)
73 if hparams['use_energy_embed']:
74 self.add_energy_loss(output['energy_pred'], energy, losses)
75 if not return_output:
76 return losses
77 else:
78 return losses, output
79
80 def validation_step(self, sample, batch_idx):
81 outputs = {}

Callers 1

validation_stepMethod · 0.95

Calls 4

add_dur_lossMethod · 0.80
add_energy_lossMethod · 0.80
cwt2f0_normMethod · 0.45
add_pitch_lossMethod · 0.45

Tested by

no test coverage detected