from cosyvoice.cli.cosyvoice import CosyVoice
from cosyvoice.utils.file_utils import load_wav
import torchaudio
cosyvoice = CosyVoice(r'D:\AI\download\CosyVoice-300M', load_jit=True, load_onnx=False, fp16=True)
print(cosyvoice.list_avaliable_spks())
prompt_speech_16k = load_wav('example_audio.wav', 16000)
for i, j in enumerate(cosyvoice.inference_zero_shot('你好，我是通义生成式语音大模型，请问有什么可以帮您的吗？', '对，这就是我，万人敬仰的太乙真人', prompt_speech_16k, stream=False)):
    torchaudio.save('zero_shot_{}.wav'.format(i), j['tts_speech'], 22050)