Fun-CosyVoice3-0.5B的效果简直就是噩梦
鼓捣半宿重新在本地部署了Fun-CosyVoice3-0.5B,0样本克隆出来的TTS内容效果一塌糊涂,动不动就把某些句子重复一遍,完全没有CosyVoice2-0.5B稳定
求怎么部署呢
鼓捣半宿重新在本地部署了Fun-CosyVoice3-0.5B,0样本克隆出来的TTS内容效果一塌糊涂,动不动就把某些句子重复一遍,完全没有CosyVoice2-0.5B稳定
重复的话是不是因为 prompt 格式不对?比如这样写:You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。 试试呢?
提示词与2不一样哦 ,需要'You are a helpful assistant.<|endofprompt|>’
鼓捣半宿重新在本地部署了Fun-CosyVoice3-0.5B,0样本克隆出来的TTS内容效果一塌糊涂,动不动就把某些句子重复一遍,完全没有CosyVoice2-0.5B稳定
重复的话是不是因为 prompt 格式不对?比如这样写:You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。 试试呢?
这个不是万能的,还是会重复
鼓捣半宿重新在本地部署了Fun-CosyVoice3-0.5B,0样本克隆出来的TTS内容效果一塌糊涂,动不动就把某些句子重复一遍,完全没有CosyVoice2-0.5B稳定
重复的话是不是因为 prompt 格式不对?比如这样写:You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。 试试呢?
---------我是用同样的应用脚本(提示词也一样),测试同样的Text内容。Seeds值都用的一样的。感觉3比2差很多。无奈又退回使用CosyVoice2-0.5B了。
鼓捣半宿重新在本地部署了Fun-CosyVoice3-0.5B,0样本克隆出来的TTS内容效果一塌糊涂,动不动就把某些句子重复一遍,完全没有CosyVoice2-0.5B稳定
重复的话是不是因为 prompt 格式不对?比如这样写:You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。 试试呢?
---------我是用同样的应用脚本(提示词也一样),测试同样的Text内容。Seeds值都用的一样的。感觉3比2差很多。无奈又退回使用CosyVoice2-0.5B了。
+1
求怎么部署呢
把项目readme下载下来给AI,让AI一步一步告诉你怎么部署。拿出几个小时时间最好周末。
是不是推理脚本的问题
+1 有的时候会重复参考音频文本里面的话 整句或者部分重复。
是不是推理脚本的问题
我说的是,用完全相同的脚本和text内容,分别使用cosyvoice2和cosyvoice3, 结果是3的表现非常差。凭啥怪脚本?
我就知道我不是一个人,昨天试了一下午,简直就是一坨!!!!!!!!!!!!!
cosyvoice3 我也是出现重复合成2次
为啥我测试3比2好很多,发音也更加准确了
为啥我测试3比2好很多,发音也更加准确了
您改动哪里了,求指点,我昨天弄一下午,效果很糟糕
为啥我测试3比2好很多,发音也更加准确了
您改动哪里了,求指点,我昨天弄一下午,效果很糟糕
#!/usr/bin/env python3
-- coding: utf-8 --
""" CosyVoice3 全面测试脚本 测试 Fun-CosyVoice3-0.5B-2512 模型的各种推理模式 """
import sys import os import time
添加 Matcha-TTS 路径
sys.path.append('third_party/Matcha-TTS')
import torch import torchaudio from cosyvoice.cli.cosyvoice import AutoModel
设置模型路径
MODEL_DIR = '/opt/data2/CosyVoice_models/Fun-CosyVoice3-0.5B' OUTPUT_DIR = '/opt/data2/CosyVoice_models/output'
创建输出目录
os.makedirs(OUTPUT_DIR, exist_ok=True)
def print_separator(title): print("\n" + "="*60) print(f" {title}") print("="*60)
def test_zero_shot(): """零样本语音克隆测试""" print_separator("测试1: 零样本语音克隆 (Zero-Shot)")
cosyvoice = AutoModel(model_dir=MODEL_DIR)
print(f"✓ 模型加载成功, 采样率: {cosyvoice.sample_rate}Hz")
# 测试文本
test_text = '八百标兵奔北坡,北坡炮兵并排跑,炮兵怕把标兵碰,标兵怕碰炮兵炮。'
prompt_text = 'You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本: {test_text}")
print(f" 提示文本: {prompt_text}")
print(f" 提示音频: {prompt_wav}")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_zero_shot(test_text, prompt_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/zero_shot_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成音频 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
return cosyvoice
def test_fine_grained_control(cosyvoice): """细粒度控制测试 (带呼吸音等)""" print_separator("测试2: 细粒度控制 (Fine-Grained Control)")
# 带呼吸标记的文本
test_text = 'You are a helpful assistant.<|endofprompt|>[breath]因为他们那一辈人[breath]在乡里面住的要习惯一点,[breath]邻居都很活络,[breath]嗯,都很熟悉。[breath]'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本 (含呼吸标记): {test_text[:100]}...")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_cross_lingual(test_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/fine_grained_control_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成音频 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def test_dialect_instruct(cosyvoice): """方言指令测试""" print_separator("测试3: 方言指令控制 (Dialect Instruction)")
# 广东话测试
test_text = '好少咯,一般系放嗰啲国庆啊,中秋嗰啲可能会咯。'
instruct_text = 'You are a helpful assistant. 请用广东话表达。<|endofprompt|>'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本: {test_text}")
print(f" 指令: {instruct_text}")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_instruct2(test_text, instruct_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/dialect_cantonese_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成广东话音频 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def test_speed_control(cosyvoice): """语速控制测试""" print_separator("测试4: 语速控制 (Speed Control)")
test_text = '收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐,笑容如花儿般绽放。'
instruct_text = 'You are a helpful assistant. 请用尽可能快地语速说一句话。<|endofprompt|>'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本: {test_text}")
print(f" 指令: {instruct_text}")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_instruct2(test_text, instruct_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/speed_fast_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成快速语音 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def test_hotfix(cosyvoice): """发音修复测试 (Hotfix)""" print_separator("测试5: 发音修复 (Pronunciation Hotfix)")
# 使用拼音标注修正发音
test_text = '高管也通过电话、短信、微信等方式对报道[j][ǐ]予好评。'
prompt_text = 'You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本 (含拼音修复): {test_text}")
print(" 注: [j][ǐ] 用于修正 '予' 的发音为 'jǐ'")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_zero_shot(test_text, prompt_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/hotfix_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成修复后音频 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def test_cross_lingual(cosyvoice): """跨语言合成测试""" print_separator("测试6: 跨语言合成 (Cross-Lingual)")
test_text = 'You are a helpful assistant.<|endofprompt|>Hello! This is a cross-lingual test. 你好,这是一个跨语言测试。'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本: {test_text}")
start_time = time.time()
for i, result in enumerate(cosyvoice.inference_cross_lingual(test_text, prompt_wav, stream=False)):
output_path = f'{OUTPUT_DIR}/cross_lingual_{i}.wav'
torchaudio.save(output_path, result['tts_speech'], cosyvoice.sample_rate)
duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" ✓ 生成跨语言音频 [{i}]: {output_path} (时长: {duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def test_streaming(cosyvoice): """流式推理测试""" print_separator("测试7: 流式推理 (Streaming)")
test_text = '收到好友从远方寄来的生日礼物,那份意外的惊喜与深深的祝福让我心中充满了甜蜜的快乐。'
prompt_text = 'You are a helpful assistant.<|endofprompt|>希望你以后能够做的比我还好呦。'
prompt_wav = './asset/zero_shot_prompt.wav'
print(f" 合成文本: {test_text}")
print(" 模式: 流式推理 (stream=True)")
start_time = time.time()
all_speech = []
first_chunk_time = None
for i, result in enumerate(cosyvoice.inference_zero_shot(test_text, prompt_text, prompt_wav, stream=True)):
if first_chunk_time is None:
first_chunk_time = time.time() - start_time
print(f" 首个音频块延迟: {first_chunk_time*1000:.0f}ms")
all_speech.append(result['tts_speech'])
chunk_duration = result['tts_speech'].shape[1] / cosyvoice.sample_rate
print(f" → 音频块 [{i}]: {chunk_duration:.2f}s")
# 拼接所有音频块
if all_speech:
combined = torch.cat(all_speech, dim=1)
output_path = f'{OUTPUT_DIR}/streaming_combined.wav'
torchaudio.save(output_path, combined, cosyvoice.sample_rate)
total_duration = combined.shape[1] / cosyvoice.sample_rate
print(f" ✓ 合并音频: {output_path} (总时长: {total_duration:.2f}s)")
elapsed = time.time() - start_time
print(f" 总耗时: {elapsed:.2f}s")
def main(): print("\n" + "="*60) print(" CosyVoice3 全面功能测试") print(" 模型: Fun-CosyVoice3-0.5B-2512") print("="*60)
# 检查 GPU
if torch.cuda.is_available():
print(f"\n✓ GPU 可用: {torch.cuda.get_device_name(0)}")
print(f" 显存: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB")
else:
print("\n⚠ GPU 不可用,将使用 CPU (较慢)")
try:
# 测试1: 零样本克隆
cosyvoice = test_zero_shot()
# 测试2: 细粒度控制
test_fine_grained_control(cosyvoice)
# 测试3: 方言指令
test_dialect_instruct(cosyvoice)
# 测试4: 语速控制
test_speed_control(cosyvoice)
# 测试5: 发音修复
test_hotfix(cosyvoice)
# 测试6: 跨语言
test_cross_lingual(cosyvoice)
# 测试7: 流式推理
test_streaming(cosyvoice)
print_separator("测试完成!")
print(f"\n所有生成的音频文件保存在: {OUTPUT_DIR}")
print("\n生成的文件列表:")
for f in sorted(os.listdir(OUTPUT_DIR)):
if f.endswith('.wav'):
fpath = os.path.join(OUTPUT_DIR, f)
size = os.path.getsize(fpath) / 1024
print(f" - {f} ({size:.1f} KB)")
except Exception as e:
print(f"\n❌ 测试失败: {e}")
import traceback
traceback.print_exc()
return 1
return 0
if name == 'main': sys.exit(main())
我也是,老是在生成的音频 里面插入了提示词里面的内容。无语了。后面发现输入的参考提示词要加个 “You are a helpful assistant.<|endofprompt|>”在真正的提示词前头,设置后就好了。
so bad!!!!
看来重复的问题大家都有. prompt text 要加"You are a helpful assistant.<|endofprompt|>"这是什么魔法操作?😂 还是让子弹飞一会儿吧, 我还是保留v2.
我的问题是我在You are a helpful assistant.<|endofprompt|>后面错误使用了“希望你以后能够做的比我还好呦。”这个提示词,但prompt音频是我自己的,导致重复和乱说,换成You are a helpful assistant.<|endofprompt|>+prompt音频的识别结果后就正常了
各位,inference_sft这类没有提示词的应该在cosyvoice3中进行修改呢,现在微调出来结果完全没有2好,是不是和这个提示词有呢?
大家做音色克隆的时候,这部分代码没改么
我也是,老是在生成的音频 里面插入了提示词里面的内容。无语了。后面发现输入的参考提示词要加个 “You are a helpful assistant.<|endofprompt|>”在真正的提示词前头,设置后就好了。
是的,我也发现这个问题了
加了“You are a helpful assistant.<|endofprompt|>”之后效果会比没加好一些,但是也会出现重复或者不合适的长停顿的问题。而且还会存在注音不生效的问题