1
0
Fork 0
TakwayDisplayPlatform/test.py

13 lines
777 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)