import
asyncio
import
edge_tts
import
playsound
DEFAULT_VOICE
=
{
'Yunyang-云扬'
:
'zh-CN-YunyangNeural'
,
'Xiaoxiao-晓晓'
:
'zh-CN-XiaoxiaoNeural'
,
'Xiaoyi-晓伊'
:
'zh-CN-XiaoyiNeural'
,
'Yunjian-云健'
:
'zh-CN-YunjianNeural'
,
'Yunxi-云希'
:
'zh-CN-YunxiNeural'
,
'Yunxia-云夏'
:
'zh-CN-YunxiaNeural'
,
'liaoning-Xiaobei-晓北辽宁'
:
'zh-CN-liaoning-XiaobeiNeural'
,
'shaanxi-Xiaoni-陕西晓妮'
:
'zh-CN-shaanxi-XiaoniNeural'
}
file
=
"E:\\WorkCode\\tmp\\a.mp3"
text
=
"早上好"
voice
=
"zh-CN-YunjianNeural"
rate
=
"+0%"
volume
=
"+100%"
async
def
ttsWork(
file
,text):
print
(text)
tts
=
edge_tts.Communicate(text
=
text,voice
=
voice,rate
=
rate,volume
=
volume)
await tts.save(
file
)
def
getVoice(
file
,text):
asyncio.run(ttsWork(
file
,text))
if
__name__
=
=
'__main__'
:
getVoice(
file
,text)