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

Method __init__

sovits/process.py:67–105  ·  view source on GitHub ↗
(
        self,
        device="cuda" if torch.cuda.is_available() else "cpu",
        is_half=True,
        stream_mode="close",
        is_int32=False,
        sovits_path="pretrained_models/Muyan-TTS/sovits.pth",
        cnhubert_path="pretrained_models/chinese-hubert-base",
        default_cut_punc="",
    )

Source from the content-addressed store, hash-verified

65 return cls._instance
66
67 def __init__(
68 self,
69 device="cuda" if torch.cuda.is_available() else "cpu",
70 is_half=True,
71 stream_mode="close",
72 is_int32=False,
73 sovits_path="pretrained_models/Muyan-TTS/sovits.pth",
74 cnhubert_path="pretrained_models/chinese-hubert-base",
75 default_cut_punc="",
76 ):
77 if not Processor._initialized:
78 self.spec_cache = {}
79 self.speaker_list = {}
80 self.audio_token_cache = {}
81 self.is_int32 = is_int32
82 self.stream_mode = stream_mode
83 self.device = device
84 self.is_half = is_half
85 self.default_cut_punc = default_cut_punc
86
87 # set sovits path
88 if sovits_path is not None:
89 self.sovits_path = sovits_path
90 else:
91 raise FileNotFoundError("No valid sovits.pth found.")
92
93 # load sovits model
94 sovits = self.get_sovits_weights(self.sovits_path, self.device)
95 self.speaker_list["default"] = Speaker(name="default", sovits=sovits)
96
97 # load cnhubert model
98 cnhubert.cnhubert_base_path = cnhubert_path
99 ssl_model = cnhubert.get_model()
100 if self.is_half:
101 self.ssl_model = ssl_model.half().to(self.device)
102 else:
103 self.ssl_model = ssl_model.to(self.device)
104
105 Processor._initialized = True
106
107 def generate_audio_token(self, ref_wav_path, spk="default"):
108 if ref_wav_path in self.audio_token_cache:

Callers

nothing calls this directly

Calls 2

get_sovits_weightsMethod · 0.95
SpeakerClass · 0.85

Tested by

no test coverage detected