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 @   一石数字欠我15w!!!  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
点击右上角即可分享
微信分享提示