update vc code

This commit is contained in:
lyuxiang.lx
2024-09-26 14:46:24 +08:00
parent d52358f6c5
commit 06934c38c7
4 changed files with 11 additions and 16 deletions

View File

@@ -25,7 +25,6 @@ class CosyVoice:
def __init__(self, model_dir, load_jit=True, load_onnx=False):
instruct = True if '-Instruct' in model_dir else False
vc = True if '-VC' in model_dir else False
self.model_dir = model_dir
if not os.path.exists(model_dir):
model_dir = snapshot_download(model_dir)
@@ -37,7 +36,6 @@ class CosyVoice:
'{}/speech_tokenizer_v1.onnx'.format(model_dir),
'{}/spk2info.pt'.format(model_dir),
instruct,
vc,
configs['allowed_special'])
self.model = CosyVoiceModel(configs['llm'], configs['flow'], configs['hift'])
self.model.load('{}/llm.pt'.format(model_dir),

View File

@@ -42,7 +42,6 @@ class CosyVoiceFrontEnd:
speech_tokenizer_model: str,
spk2info: str = '',
instruct: bool = False,
vc: bool = False,
allowed_special: str = 'all'):
self.tokenizer = get_tokenizer()
self.feat_extractor = feat_extractor
@@ -59,7 +58,6 @@ class CosyVoiceFrontEnd:
else:
self.spk2info = {}
self.instruct = instruct
self.vc = vc
self.allowed_special = allowed_special
self.inflect_parser = inflect.engine()
self.use_ttsfrd = use_ttsfrd

View File

@@ -54,10 +54,9 @@ class CosyVoiceModel:
self.hift_cache_dict = {}
def load(self, llm_model, flow_model, hift_model):
if self.llm is not None:
self.llm.load_state_dict(torch.load(llm_model, map_location=self.device))
self.llm.to(self.device).eval()
self.llm.half()
self.llm.load_state_dict(torch.load(llm_model, map_location=self.device))
self.llm.to(self.device).eval()
self.llm.half()
self.flow.load_state_dict(torch.load(flow_model, map_location=self.device))
self.flow.to(self.device).eval()
self.hift.load_state_dict(torch.load(hift_model, map_location=self.device))