TakwayDisplayPlatform/test.py

13 lines
777 B
Python
Raw Normal View History

2024-06-23 20:39:44 +08:00
from utils.bert_vits2_utils import TextToSpeech
import soundfile as sf
tts = TextToSpeech()
tts.print_speakers_info()
audio, sample_rate= tts.synthesize("你好,我好开心", # 文本
0, # 说话人 id
style_text="我很难过!!!!呜呜呜!!!", # 情绪prompt当language=="ZH" 才有效
style_weight=0.9, # 情绪prompt权重
language="mix", # 语言类型,包括 "ZH" "EN" "mix"
en_ratio=1.) # mix语言类型下英文文本速度越大速度越慢
save_path = "./tmp2.wav"
sf.write(save_path, audio, sample_rate)