MCPcopy Create free account
hub / github.com/evilsocket/cake / convert_vocoder

Function convert_vocoder

scripts/convert_luxtts.py:118–133  ·  view source on GitHub ↗

Convert vocoder weights.

(vocoder_path: Path, output_path: Path)

Source from the content-addressed store, hash-verified

116
117
118def convert_vocoder(vocoder_path: Path, output_path: Path):
119 """Convert vocoder weights."""
120 print(f"\nLoading vocoder from {vocoder_path}")
121 state_dict = torch.load(vocoder_path, map_location='cpu', weights_only=False)
122
123 remapped = {}
124 for key, tensor in sorted(state_dict.items()):
125 if tensor.dim() == 0:
126 tensor = tensor.unsqueeze(0)
127 if tensor.dtype == torch.float32:
128 tensor = tensor.half()
129 remapped[key] = tensor
130
131 print(f"Saving {len(remapped)} vocoder tensors to {output_path}")
132 save_file(remapped, str(output_path))
133 print(f" Size: {output_path.stat().st_size / 1e6:.1f} MB")
134
135
136def main():

Callers 1

mainFunction · 0.85

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected