Python 如何同时运行pyttsx3和tkinter

Python 如何同时运行pyttsx3和tkinter,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,我制作了一个聊天室,希望用户键入命令,计算机同时说出代码,但这不会发生!我可以使用哪个模块或函数使其同步 我已经用键绑定了一个函数,当它被点击时,该函数开始发挥作用。当电脑讲话时,tkinter窗口冻结,但我希望它们同时工作 engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voice', voices[len(voices) - 1].id) def speak(

我制作了一个聊天室,希望用户键入命令,计算机同时说出代码,但这不会发生!我可以使用哪个模块或函数使其同步

我已经用键绑定了一个函数,当它被点击时,该函数开始发挥作用。当电脑讲话时,tkinter窗口冻结,但我希望它们同时工作

engine = pyttsx3.init('sapi5')

voices = engine.getProperty('voices')
engine.setProperty('voice', voices[len(voices) - 1].id)

def speak(audio):
    chatbox.update()
    engine.say(audio)
    engine.runAndWait

def send_btn(event):
    msg = user_input.get('1.0', END)
    msg = str(msg).lower()
    user_input.delete('1.0', END)
    chatbox.insert(END, 'User: ' + msg)
    speak(msg)
我希望同时运行speak功能和tkinter窗口,tkinter窗口也不会冻结

它说您可以放置
引擎.connect(主题:string,cb:callable)
,尝试在语音的同时查看有关运行函数的文档。

它说您可以放置
引擎.connect(主题:string,cb:callable)
,试着在演讲的同时查看有关运行函数的文档