FunAudioLLM / CosyVoice

Multi-lingual large voice generation model, providing inference, training and deployment full-stack ability.
https://funaudiollm.github.io/
Apache License 2.0
5.69k stars 600 forks source link

当用循环生成语音时超过三条文本就会出现错误 #397

Open Alex-DeepL opened 1 month ago

Alex-DeepL commented 1 month ago

Exception in thread Thread-4: Traceback (most recent call last): File "/root/anaconda3/envs/cosyvoice/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/root/anaconda3/envs/cosyvoice/lib/python3.8/threading.py", line 870, in run self._target(*self._args, self._kwargs) File "/model/workspace/lwl/CosyVoice/cosyvoice/cli/model.py", line 81, in llm_job for i in self.llm.inference(text=text.to(self.device), File "/root/anaconda3/envs/cosyvoice/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 35, in generator_context response = gen.send(None) File "/model/workspace/lwl/CosyVoice/cosyvoice/llm/llm.py", line 205, in inference top_ids = self.sampling_ids(logp.squeeze(dim=0), out_tokens, sampling, ignore_eos=True if i < min_len else False).item() File "/model/workspace/lwl/CosyVoice/cosyvoice/llm/llm.py", line 147, in sampling_ids top_ids = self.sampling(weighted_scores, decoded_tokens, sampling) File "/model/workspace/lwl/CosyVoice/cosyvoice/utils/common.py", line 108, in ras_sampling top_ids = nucleus_sampling(weighted_scores, top_p=top_p, top_k=top_k) File "/model/workspace/lwl/CosyVoice/cosyvoice/utils/common.py", line 129, in nucleus_sampling top_ids = indices[prob.multinomial(1, replacement=True)] RuntimeError: probability tensor contains either inf, nan or element < 0 0%| | 0/1 [00:01<?, ?it/s] Traceback (most recent call last): File "/model/workspace/lwl/CosyVoice/temp.py", line 28, in get_wav(message,index) File "/model/workspace/lwl/CosyVoice/temp.py", line 14, in get_wav for wav in cosyvoice.inference_cross_lingual(message, prompt_speech_16k, stream=False): File "/model/workspace/lwl/CosyVoice/cosyvoice/cli/cosyvoice.py", line 86, in inference_cross_lingual for model_output in self.model.inference(model_input, stream=stream): File "/model/workspace/lwl/CosyVoice/cosyvoice/cli/model.py", line 166, in inference this_tts_speech_token = torch.concat(self.tts_speech_token_dict[this_uuid], dim=1) RuntimeError: torch.cat(): expected a non-empty list of Tensors

代码

def get_wav(message,index): for wav in cosyvoice.inference_cross_lingual(message, prompt_speech_16k, stream=False): torchaudio.save('huashu{}.wav'.format(index), wav['tts_speech'], 22050)

数据

message_list = [
    "<|zh|>您已经逾期有段时间了,如果一直长期未处理,后续您的电话可能会停机。为了避免造成后续不必要的麻烦,请您尽快完成支付可以吗?",
    "<|zh|>截至当前,账单已经逾期10天了,为了确保您的服务不会受到影响,请您尽快处理一下这笔费用,好吗?",
    "<|zh|>我是广州电信智能语音客服,很抱歉,需要耽误您几秒钟时间。跟您核实一下,请问您确认您不是或者不认识小明吗?",

]
for index,message in enumerate(message_list):
    get_wav(message,index)
Alex-DeepL commented 1 month ago

前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题

aluminumbox commented 1 month ago

looks like ttsfrd related, try uninstall ttsfrd

XuebinWang-ai commented 1 month ago

前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题

你好,我也遇到了同样的问题,请问如何解决?

Alex-DeepL commented 1 month ago

其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题

------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397)

前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题

你好,我也遇到了同样的问题,请问如何解决?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

XuebinWang-ai commented 1 month ago

其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。

Alex-DeepL commented 1 month ago

一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码

------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397)

其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

XuebinWang-ai commented 1 month ago

一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码 ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

非常感谢解答,我明白了你的意思,代码我就不需要了,再次感谢。

likuangyu01 commented 4 weeks ago

一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码 ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

我启动了fastapi的server.py,但是用client.py去下载音频就报错,兄弟能看下你的fastapi的部署脚本吗 Traceback (most recent call last): File "client.py", line 98, in main() File "client.py", line 59, in main tts_speech = torch.from_numpy(np.array(np.frombuffer(tts_audio, dtype=np.int16))).unsqueeze(dim=0)

Alex-DeepL commented 4 weeks ago

ok @app.get("/tts") async def get_wav(query): output = cosyvoice.inference_cross_lingual(query, prompt_speech_16k, stream=False) start = time.time() for item in output: buffer = io.BytesIO() torchaudio.save(buffer, item['tts_speech'], 22050, format='wav') buffer.seek(0) return Response(content=buffer.read(), media_type='audio/wav') end = time.time() print(end - start)

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2024年9月23日(星期一) 下午4:21 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397)

一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

我启动了fastapi的server.py,但是用client.py去下载音频就报错,兄弟能看下你的fastapi的部署脚本吗 Traceback (most recent call last): File "client.py", line 98, in main() File "client.py", line 59, in main tts_speech = torch.from_numpy(np.array(np.frombuffer(tts_audio, dtype=np.int16))).unsqueeze(dim=0)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Alex-DeepL commented 4 weeks ago

query = "<|zh|>您好,我是广州电信智能语音客服,来电是和您沟通2020年2月,手机尾号为1757的电信账单。想和您核实一下,请问您是小明吗?" response = requests.get("http://localhost:8001/tts", params={"query": query}) audio_data = response.content with open("output.wav", "wb") as f: f.write(audio_data)

------------------ 原始邮件 ------------------ 发件人: "FunAudioLLM/CosyVoice" @.>; 发送时间: 2024年9月23日(星期一) 下午4:21 @.>; @.**@.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397)

一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

我启动了fastapi的server.py,但是用client.py去下载音频就报错,兄弟能看下你的fastapi的部署脚本吗 Traceback (most recent call last): File "client.py", line 98, in main() File "client.py", line 59, in main tts_speech = torch.from_numpy(np.array(np.frombuffer(tts_audio, dtype=np.int16))).unsqueeze(dim=0)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

likuangyu01 commented 4 weeks ago

query = "<|zh|>您好,我是广州电信智能语音客服,来电是和您沟通2020年2月,手机尾号为1757的电信账单。想和您核实一下,请问您是小明吗?" response = requests.get("http://localhost:8001/tts", params={"query": query}) audio_data = response.content with open("output.wav", "wb") as f: f.write(audio_data) ------------------ 原始邮件 ------------------ 发件人: "FunAudioLLM/CosyVoice" @.>; 发送时间: 2024年9月23日(星期一) 下午4:21 @.>; @.**@.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 一般在生产环境下你需要将这个模型部署为一个服务,这种情况下是没问题的,你可以使用flask或者fastapi等框架来实现,有需要的话我可以给你我写的代码 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:43 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 其实这个问题不需要考虑的,你把这个功能写成一个接口可以解决这个问题 … ------------------ 原始邮件 ------------------ 发件人: "Xuebin @.>; 发送时间: 2024年9月18日(星期三) 下午3:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FunAudioLLM/CosyVoice] 当用循环生成语音时超过三条文本就会出现错误 (Issue #397) 前两条数据没问题,到第三条数据出现问题,并且单条数据也没问题 你好,我也遇到了同样的问题,请问如何解决? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 不好意思,我没有懂你的意思,可以讲得具体一些吗?我把它写为函数仍然还是报同样的错。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> 我启动了fastapi的server.py,但是用client.py去下载音频就报错,兄弟能看下你的fastapi的部署脚本吗 Traceback (most recent call last): File "client.py", line 98, in main() File "client.py", line 59, in main tts_speech = torch.from_numpy(np.array(np.frombuffer(tts_audio, dtype=np.int16))).unsqueeze(dim=0) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

thanks