Skip to content

在语音合成和自然语言控制中重新使用保存的3秒急速复刻音色。expand to reuse the saved zero_shot_spk_id in sft, instruct2 #1475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cosyvoice/cli/cosyvoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def add_zero_shot_spk(self, prompt_text, prompt_speech_16k, zero_shot_spk_id):
model_input = self.frontend.frontend_zero_shot('', prompt_text, prompt_speech_16k, self.sample_rate, '')
del model_input['text']
del model_input['text_len']
model_input['embedding'] = model_input['llm_embedding']
self.frontend.spk2info[zero_shot_spk_id] = model_input
return True

Expand Down
11 changes: 9 additions & 2 deletions cosyvoice/cli/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,15 @@ def frontend_instruct(self, tts_text, spk_id, instruct_text):

def frontend_instruct2(self, tts_text, instruct_text, prompt_speech_16k, resample_rate, zero_shot_spk_id):
model_input = self.frontend_zero_shot(tts_text, instruct_text + '<|endofprompt|>', prompt_speech_16k, resample_rate, zero_shot_spk_id)
del model_input['llm_prompt_speech_token']
del model_input['llm_prompt_speech_token_len']
if bool(zero_shot_spk_id):
prompt_text_token, prompt_text_token_len = self._extract_text_token(instruct_text + '<|endofprompt|>')
model_input['prompt_text'] = prompt_text_token
model_input['prompt_text_len'] = prompt_text_token_len
if 'llm_prompt_speech_token' in model_input.keys():
del model_input['llm_prompt_speech_token']
if 'llm_prompt_speech_token_len' in model_input.keys():
del model_input['llm_prompt_speech_token_len']

return model_input

def frontend_vc(self, source_speech_16k, prompt_speech_16k, resample_rate):
Expand Down