文本转语音程序在讲话后关闭
我正在使用 PYTTSX3 和 Tkinter 制作文本到语音程序。除了一件事之外,一切都很好。每当我按下“说出来!”时按钮一次,它会显示文本并退出。有办法阻止这种情况吗? (请来这里帮助我的问题,而不仅仅是编辑我的问题)我在运行 python 3.10.2 的 Mac 上
import pyttsx3 as py3
import tkinter
root = tkinter.Tk()
root.title("Say It!")
root.geometry("200x100")
def speak():
engine = py3.init()
engine.say(user_input.get())
engine.runAndWait()
label_inst = tkinter.Label(root,text="Enter what you want to say:")
label_inst.pack()
user_input = tkinter.Entry(root)
user_input.pack()
button_say = tkinter.Button(root,text="Say it!",command=speak)
button_say.pack()
root.mainloop()
#Chris L 2022
I am making a text to speech program using PYTTSX3 and Tkinter. Everything works great, except for one thing. Whenever I press the "Say It!" button once, it says the text and quits. Is there a way to stop this? (please come here to help my problem, not just to edit my question) I am on a Mac running python 3.10.2
import pyttsx3 as py3
import tkinter
root = tkinter.Tk()
root.title("Say It!")
root.geometry("200x100")
def speak():
engine = py3.init()
engine.say(user_input.get())
engine.runAndWait()
label_inst = tkinter.Label(root,text="Enter what you want to say:")
label_inst.pack()
user_input = tkinter.Entry(root)
user_input.pack()
button_say = tkinter.Button(root,text="Say it!",command=speak)
button_say.pack()
root.mainloop()
#Chris L 2022
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论