安装方法
pip install gTTS
代码
from gtts import gTTS
import os
# 替换为你的书信内容
text = """
Dear Jimmy,
I hope this email finds you well. I would like to provide you with an update on the progress of our embedded AI project.
Currently, I have successfully developed a functionality that analyzes the flow of people within a given scene. Specifically, the AI is capable of detecting when the number of people in a designated area exceeds 20, triggering an alert.
Please let me know if there are additional requirements or adjustments needed.
Best regards,
Bruce Wang
"""
# 转换为语音
tts = gTTS(text=text, lang='en')
tts.save("letter.mp3")
# 播放音频
os.system("start letter.mp3") # Windows
# os.system("mpg123 letter.mp3") # Linux
生成的效果贼好