CosyVoice icon indicating copy to clipboard operation
CosyVoice copied to clipboard

流式推理效果 疑问

Open wafer9 opened this issue 8 months ago • 7 comments

Image 在cosyvoice2论文中,llm流式和非流式差距很小, 但我测试test-zh时发现,流式要比非流式差。推理过程中有随机性存在,所以我推理的十次,平均后,非流式cer=1.399%,流式cer=3.227%。 流式和非流式推理代码如下

def text_generator(txt):
    yield txt

if is_stream:
    input_text = text_generator(text)
else:
    input_text = text
for i, j in enumerate(cosyvoice.inference_zero_shot(input_text, prompt_text, prompt_speech_16k, stream=True)):
    audios.append(j['tts_speech'])

同时llm.py 流式推理,代码有个bug, https://github.com/FunAudioLLM/CosyVoice/blob/587604b2b433bc350c344b4b181b47249b54faf2/cosyvoice/llm/llm.py#L502, 做了如下修改

# 3. final decode
if prompt_speech_token_emb.size(1) == 0:
    lm_input = torch.concat([lm_input, text_cache, task_id_emb], dim=1)
else:
    lm_input = torch.concat([lm_input, text_cache, task_id_emb, prompt_speech_token_emb], dim=1)

我的推理有什么问题吗?还是说cosyvoice2 论文中结果有问题?

wafer9 avatar Apr 23 '25 10:04 wafer9

我在生产环境上了新版,被客户吐槽惨了……现在退回cosyvoice2在1月份的代码和模型了

lovewater avatar Apr 27 '25 11:04 lovewater

我在生产环境上了新版,被客户吐槽惨了……现在退回cosyvoice2在1月份的代码和模型了

1月份的版本更好吗?

jetsonearth avatar May 07 '25 01:05 jetsonearth

这个问题解决了吗?我复现的结果和你一样

tofusss avatar May 30 '25 02:05 tofusss

@tofusss 复现,你是指流式和非流式差距吗?

wafer9 avatar Jun 10 '25 09:06 wafer9

嗯 我流式条件下中文的错误率也是3%左右,英文的更高

tofusss avatar Jun 10 '25 11:06 tofusss

我在生产环境上了新版,被客户吐槽惨了……现在退回cosyvoice2在1月份的代码和模型了

原因是什么呢

lq0104 avatar Aug 08 '25 07:08 lq0104

你们流式推理后的音频频谱会有断裂吗?听起来像是丢包的感觉

wen0320 avatar Oct 20 '25 06:10 wen0320