MCPcopy Create free account
hub / github.com/MYZY-AI/Muyan-TTS / get_sovits_weights

Method get_sovits_weights

sovits/process.py:143–168  ·  view source on GitHub ↗
(self, sovits_path, device="cpu")

Source from the content-addressed store, hash-verified

141 return audio_token
142
143 def get_sovits_weights(self, sovits_path, device="cpu"):
144 dict_s2 = torch.load(sovits_path, map_location=device)
145 hps = dict_s2["config"]
146 hps = DictToAttrRecursive(hps)
147 hps.model.semantic_frame_rate = "25hz"
148 if dict_s2['weight']['enc_p.text_embedding.weight'].shape[0] == 322:
149 hps.model.version = "v1"
150 else:
151 hps.model.version = "v2"
152 model_params_dict = vars(hps.model)
153 vq_model = SynthesizerTrn(
154 hps.data.filter_length // 2 + 1,
155 hps.train.segment_size // hps.data.hop_length,
156 n_speakers=hps.data.n_speakers,
157 **model_params_dict
158 )
159 if ("pretrained" not in sovits_path):
160 del vq_model.enc_q
161 if self.is_half == True:
162 vq_model = vq_model.half().to(self.device)
163 else:
164 vq_model = vq_model.to(self.device)
165 vq_model.eval()
166 vq_model.load_state_dict(dict_s2["weight"], strict=False)
167 sovits = Sovits(vq_model, hps)
168 return sovits
169
170 def get_tts_wav(self, predict, vits_wav_path, prompt_text, prompt_language, text, text_language, speed=1, inp_refs=[], spk="default", scaling_factor=1.0):
171 infer_sovits = self.speaker_list[spk].sovits

Callers 1

__init__Method · 0.95

Calls 3

SynthesizerTrnClass · 0.90
DictToAttrRecursiveClass · 0.85
SovitsClass · 0.85

Tested by

no test coverage detected