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