import pyttsx3
# 创建一个引擎实例
 engine = pyttsx3.init()
# 获取所有可用的语音列表
 voices = engine.getProperty('voices')
# 打印出所有可用的语音名称和属性
 for voice in voices:
     print("Voice:")
     print(" - 名称: %s" % voice.name)
     print(" - ID: %s" % voice.id)
     print(" - 语言: %s" % voice.languages)
     print(" - 性别: %s" % voice.gender)
     print(" - 年龄: %s" % voice.age)
# 设置所选的语音
 engine.setProperty('voice', voices[0].id)
# 设置语音的参数
 engine.setProperty('rate', 150)  # 速度
 engine.setProperty('volume', 0.8)  # 音量
# 将文本转换为语音
 text = "这是一个TTS分析的Python脚本的例子"
 engine.say(text)
# 播放语音
 engine.runAndWait()