python 文字转语音
pip3 install pywin32
pip install pyttsx3
import pyttsx3
def text_to_vocie(sentence,filename):
"""
# 文字转语音
:param sentence:文字(字符串)
:param filename:音频文件路径
:return:
"""
engine = pyttsx3.init()
engine.setProperty('rate', 150)
engine.say(sentence)
engine.save_to_file(sentence, filename, name=None)
engine.runAndWait()
if __name__ == '__main__':
sentence = 'python 文字转语音'
text_to_vocie(sentence,'1.wav')
pip3 install pywin32
#利用pywin32模块,来实现微软的语音接口调用
import win32com.client
#微软这个服务器
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("你好,小姐姐,能加个微信吗?")