所以,我正在尝试pyttsx
在 python3 中创建一个谈话引擎,当我第一次调用该函数说它工作正常时,如果我再次调用它,它只会说出句子的第一个单词而没有任何反应。
import pyttsx
class Speech(object):
def __init__(self):
self.engine = pyttsx.init()
self.engine.setProperty('rate', 150)
def say_song(self):
""" Tell user to choose song """
self.engine.say("Please choose song. ")
self.engine.runAndWait()
def say_alarm(self):
""" Tell user to set up the alarm """
self.engine.say("Please set up the alarm, after the beep.")
self.engine.runAndWait()
def beep(self):
self.engine.say("beep")
self.engine.runAndWait()
>>> from voices import Speech
>>> s = Speech()
>>> s.say_song()
>>> s.beep()
>>> s.say_alarm()