import ONNXVITS_models import utils from text.symbols import symbols from text import text_to_sequence import torch import commons def get_text(text, hps): text_norm = text_to_sequence(text, symbols, hps.data.text_cleaners) if hps.data.add_blank: text_norm = commons.intersperse(text_norm, 0) text_norm = torch.LongTensor(text_norm) return text_norm def get_label(text, label): if f'[{label}]' in text: return True, text.replace(f'[{label}]', '') else: return False, text hps_ms = utils.get_hparams_from_file("/content/drive/MyDrive/moe/config.json") net_g_ms = ONNXVITS_models.SynthesizerTrn( len(symbols), hps_ms.data.filter_length // 2 + 1, hps_ms.train.segment_size // hps_ms.data.hop_length, n_speakers=hps_ms.data.n_speakers, **hps_ms.model) _ = net_g_ms.eval() _ = utils.load_checkpoint("/content/drive/MyDrive/moe/G_909000.pth", net_g_ms) text1 = get_text("[JA]ありがとうございます。[JA]", hps_ms) stn_tst = text1 with torch.no_grad(): x_tst = stn_tst.unsqueeze(0) x_tst_lengths = torch.LongTensor([stn_tst.size(0)]) sid = torch.tensor([0]) o = net_g_ms(x_tst, x_tst_lengths, sid=sid, noise_scale=.667, noise_scale_w=0.8, length_scale=1)