1 year ago
#333607
pythonbetter
Text To Speech Program Closes After Speaking
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
python
tkinter
speech
pyttsx3
0 Answers
Your Answer