文本转语音程序在讲话后关闭

发布于 2025-01-16 19:51:58 字数 623 浏览 5 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文