Spaces:
Sleeping
Sleeping
File size: 532 Bytes
4451360 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import torch
def load_hifigan(state_dict_path, config_file):
import json
from vocoder.hifigan.env import AttrDict
from vocoder.hifigan.models import Generator
with open(config_file) as f:
data = f.read()
json_config = json.loads(data)
h = AttrDict(json_config)
generator = Generator(h)
state_dict_g = torch.load(state_dict_path, map_location='cpu')
generator.load_state_dict(state_dict_g['generator'])
generator.eval()
generator.remove_weight_norm()
return generator
|