官网
step1
可以选择指定模型,对于多情感的模型,还可以通过标签实现语气情感
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
text = '<speak><emotion category="happy" intensity="2.0">德玛西亚万岁,恕瑞玛的皇帝又回来了</emotion></speak>'
# text = '<speak><emotion category="angry" intensity="1.0">安装成功后,即可使用对应领域模型进行推理,训练等操作。这里我们以NLP领域为例。安装后,可执行如下命令,运行中文分词任务,来验证安装是否正确</emotion></speak>'
model_id = 'damo/speech_sambert-hifigan_tts_zh-cn_16k'
sambert_hifigan_tts = pipeline(task=Tasks.text_to_speech, model=model_id)
output = sambert_hifigan_tts(input=text, voice='zhitian_emo')
wav = output[OutputKeys.OUTPUT_WAV]
with open('output_happy.wav', 'wb') as f:
f.write(wav)