Python文本转语音并播放

阅读 27

2024-06-18

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


精彩评论(0)

0 0 举报