inference_instruct2 missing 1 required positional argument: 'zero_shot_spk_id'
import sys sys.path.append('third_party/Matcha-TTS') from cosyvoice.cli.cosyvoice import CosyVoice, CosyVoice2 from cosyvoice.utils.file_utils import load_wav import torchaudio
cosyvoice = CosyVoice2('pretrained_models/CosyVoice2-0.5B', load_jit=False, load_trt=False, fp16=False)
tts_text = '四十岁后才知道,朋友就像柜子里的"老茶饼。'
instruct_text = '用情感电台的主持人的语气有感情的说'
prompttext = '但是刘备先生的坚持和热情打动了我,他的三次拜访让我决定出山,与他共谋天下大计,这就是我传奇一生的开始。'
prompt_speech_16k = load_wav('asset/xiaoyu.wav', 16000)
assert cosyvoice.add_zero_shot_spk(prompttext, prompt_speech_16k, 'my_zero_shot_spk') is True for i, j in enumerate(cosyvoice.inference_zero_shot(tts_text, '', '', zero_shot_spk_id='my_zero_shot_spk', stream=False)): torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate) cosyvoice.save_spkinfo()
for i, j in enumerate(cosyvoice.inference_instruct2(tts_text, instruct_text, prompt_speech_16k, stream=False)): torchaudio.save('instruct_{}.wav'.format(i), j['tts_speech'], cosyvoice.sample_rate)
第一个音频可以正常生成,第二个报错:
Traceback (most recent call last):
File "E:\AiProgram\cosyvoice\CosyVoice\test.py", line 20, in
遇到了相同的问题 CosyVoiceFrontEnd.frontend_zero_shot() missing 1 required positional argument: 'zero_shot_spk_id'
我也遇到了,在frontend.py里面的frontend instruct2函数加个空字符串参数临时解决了。 def frontend_instruct2(self, tts_text, instruct_text, prompt_speech_16k, resample_rate): model_input = self.frontend_zero_shot(tts_text, instruct_text + '<|endofprompt|>', prompt_speech_16k, resample_rate,"")#结尾加了个空的字符串参数 del model_input['llm_prompt_speech_token'] del model_input['llm_prompt_speech_token_len'] return model_input
我也遇到了,在frontend.py里面的frontend instruct2函数加个空字符串参数临时解决了。 def frontend_instruct2(self, tts_text, instruct_text, prompt_speech_16k, resample_rate): model_input = self.frontend_zero_shot(tts_text, instruct_text + '<|endofprompt|>', prompt_speech_16k, resample_rate,"")#结尾加了个空的字符串参数 del model_input['llm_prompt_speech_token'] del model_input['llm_prompt_speech_token_len'] return model_input
有用,感谢~~~~~~~~~~~~~~
This issue is stale because it has been open for 30 days with no activity.