Ram commited on
Commit
3f406ba
·
1 Parent(s): 6d65ae9

Remove flow_cache arg to match CosyVoice3 flow.inference

Browse files
Files changed (1) hide show
  1. cosyvoice/cli/model.py +5 -5
cosyvoice/cli/model.py CHANGED
@@ -58,7 +58,7 @@ class CosyVoiceModel:
58
  self.tts_speech_token_dict = {}
59
  self.llm_end_dict = {}
60
  self.mel_overlap_dict = {}
61
- self.flow_cache_dict = {}
62
  self.hift_cache_dict = {}
63
  self.silent_tokens = []
64
 
@@ -134,14 +134,14 @@ class CosyVoiceModel:
134
 
135
  def token2wav(self, token, prompt_token, prompt_feat, embedding, uuid, finalize=False, speed=1.0):
136
  with torch.cuda.amp.autocast(self.fp16):
137
- tts_mel, self.flow_cache_dict[uuid] = self.flow.inference(token=token.to(self.device, dtype=torch.int32),
138
  token_len=torch.tensor([token.shape[1]], dtype=torch.int32).to(self.device),
139
  prompt_token=prompt_token.to(self.device),
140
  prompt_token_len=torch.tensor([prompt_token.shape[1]], dtype=torch.int32).to(self.device),
141
  prompt_feat=prompt_feat.to(self.device),
142
  prompt_feat_len=torch.tensor([prompt_feat.shape[1]], dtype=torch.int32).to(self.device),
143
  embedding=embedding.to(self.device),
144
- flow_cache=self.flow_cache_dict[uuid])
145
 
146
  # mel overlap fade in out
147
  if self.mel_overlap_dict[uuid].shape[2] != 0:
@@ -183,7 +183,7 @@ class CosyVoiceModel:
183
  self.tts_speech_token_dict[this_uuid], self.llm_end_dict[this_uuid] = [], False
184
  self.hift_cache_dict[this_uuid] = None
185
  self.mel_overlap_dict[this_uuid] = torch.zeros(1, 80, 0)
186
- self.flow_cache_dict[this_uuid] = torch.zeros(1, 80, 0, 2)
187
  if source_speech_token.shape[1] == 0:
188
  p = threading.Thread(target=self.llm_job, args=(text, prompt_text, llm_prompt_speech_token, llm_embedding, this_uuid))
189
  else:
@@ -236,7 +236,7 @@ class CosyVoiceModel:
236
  self.llm_end_dict.pop(this_uuid)
237
  self.mel_overlap_dict.pop(this_uuid)
238
  self.hift_cache_dict.pop(this_uuid)
239
- self.flow_cache_dict.pop(this_uuid)
240
  if torch.cuda.is_available():
241
  torch.cuda.empty_cache()
242
  torch.cuda.current_stream().synchronize()
 
58
  self.tts_speech_token_dict = {}
59
  self.llm_end_dict = {}
60
  self.mel_overlap_dict = {}
61
+ # self.flow_cache_dict = {}
62
  self.hift_cache_dict = {}
63
  self.silent_tokens = []
64
 
 
134
 
135
  def token2wav(self, token, prompt_token, prompt_feat, embedding, uuid, finalize=False, speed=1.0):
136
  with torch.cuda.amp.autocast(self.fp16):
137
+ tts_mel, _ = self.flow.inference(token=token.to(self.device, dtype=torch.int32),
138
  token_len=torch.tensor([token.shape[1]], dtype=torch.int32).to(self.device),
139
  prompt_token=prompt_token.to(self.device),
140
  prompt_token_len=torch.tensor([prompt_token.shape[1]], dtype=torch.int32).to(self.device),
141
  prompt_feat=prompt_feat.to(self.device),
142
  prompt_feat_len=torch.tensor([prompt_feat.shape[1]], dtype=torch.int32).to(self.device),
143
  embedding=embedding.to(self.device),
144
+ )
145
 
146
  # mel overlap fade in out
147
  if self.mel_overlap_dict[uuid].shape[2] != 0:
 
183
  self.tts_speech_token_dict[this_uuid], self.llm_end_dict[this_uuid] = [], False
184
  self.hift_cache_dict[this_uuid] = None
185
  self.mel_overlap_dict[this_uuid] = torch.zeros(1, 80, 0)
186
+ # self.flow_cache_dict[this_uuid] = torch.zeros(1, 80, 0, 2)
187
  if source_speech_token.shape[1] == 0:
188
  p = threading.Thread(target=self.llm_job, args=(text, prompt_text, llm_prompt_speech_token, llm_embedding, this_uuid))
189
  else:
 
236
  self.llm_end_dict.pop(this_uuid)
237
  self.mel_overlap_dict.pop(this_uuid)
238
  self.hift_cache_dict.pop(this_uuid)
239
+ # self.flow_cache_dict.pop(this_uuid)
240
  if torch.cuda.is_available():
241
  torch.cuda.empty_cache()
242
  torch.cuda.current_stream().synchronize()