edge tts 文字转语音

import edge_tts
import asyncio
from playsound import playsound

async def run_tts(text: str, output: str, voice: str ='zh-CN-XiaoxiaoNeural') -> None:
    communicate = edge_tts.Communicate(text, voice)
    await communicate.save(output)


if __name__ == '__main__':
    asyncio.run(run_tts('你好, 我是您的朋友,我叫晓晓', 'edge-tts-output.mp3'))
    playsound('edge-tts-output.mp3')

 

 
posted @ 2024-06-01 10:36  meetrice  阅读(45)  评论(0编辑  收藏  举报