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

Class HighGAN

usr/singingvocoder/highgan.py:37–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 return model, config
36
37class HighGAN(BaseVocoder):
38 def __init__(self):
39 vocoder_ckpt = hparams['vocoder_ckpt']
40 checkpoint_path = "highgan/" + vocoder_ckpt
41 config_path = os.path.dirname(checkpoint_path) + "/config.yml"
42 model, self.config = load_model_config(checkpoint_path, config_path)
43 self.model = model.eval().to('cuda')
44
45 def spec2wav(self, mel, **kwargs):
46 f0 = kwargs['f0']
47 mel = normalize(20 * mel) * 2
48 mel = torch.FloatTensor(mel).transpose(0, 1)[None, ...]
49 f0 = torch.FloatTensor(f0)[None, ...]
50 pad_fn = torch.nn.ReplicationPad1d(
51 self.config["generator_params"].get("aux_context_window", 0))
52 device = next(self.model.parameters()).device
53
54 mels = pad_fn(mel).to(device)
55 f0 = f0.to(device)
56 x = (mels, f0)
57
58 with torch.no_grad():
59 y = self.model(*x)
60 y = y.view(-1).cpu().numpy()
61 return y
62
63 @staticmethod
64 def wav2spec(wav_fn, **kwargs):
65 return PWG.wav2spec(wav_fn, **kwargs)
66
67
68if __name__ == '__main__':

Callers 1

highgan.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected