Python文本转语音并播放

async def text_audio(text, audio_name):
    tts = edge_tts.Communicate(
        text=text,
        voice="zh-CN-XiaoxiaoNeural")
    await tts.save(audio_name)
audio_name = "xxx.mp3"
pygame.mixer.Sound.play(audio_name)
while pygame.mixer.get_busy():
    pygame.time.Clock().tick()

edge_tts: 文本转语音

pygame:播放

 

https://github.com/rany2/edge-tts

posted @ 2024-06-13 11:32  一石数字欠我15w!!!  阅读(29)  评论(0编辑  收藏  举报