Nov-13-2020, 11:15 PM
I installed the pyttsx3 libary to convert text to speech. And it works really great, until I want to use it in combination with tkinter. What happens that the program just closes, without any errors or what so ever. Weird enough it goes through the codes after engine.runAndWait(). I checked that by putting a print command after every line which shows up in the terminal, but I it 'ignores' the widgets that are supposed to be built up in the window. Any ideas? I'm using MacOs Mojave 10.14.6. with Python 3.8.5.
Here is the partial code with the problem, you can obviously ignore the print commands in between. I just left it so it's visible that it goes through the code, but only executing the print commands and ignoring the rest. Again, it works fine without tkinter, and the program also works fine when I don't use the pyttsx3 library. Here's the whole code: https://www.codepile.net/pile/rezzJ7ex and the JSON file that goes with it: https://www.codepile.net/pile/ePlYvbZM
Here is the partial code with the problem, you can obviously ignore the print commands in between. I just left it so it's visible that it goes through the code, but only executing the print commands and ignoring the rest. Again, it works fine without tkinter, and the program also works fine when I don't use the pyttsx3 library. Here's the whole code: https://www.codepile.net/pile/rezzJ7ex and the JSON file that goes with it: https://www.codepile.net/pile/ePlYvbZM
else: random.shuffle(WORDS) for widget in window.winfo_children(): widget.destroy() WORD = WORDS[0] tk.Label (window, image=photo1, bg="black") .grid(row=0, column=0) word = tk.Label (window, text = WORD, bg="black", fg="white", font="none 20 bold") word.grid(row=1, column=0) window.update() engine = pyttsx3.init() nl_voice_id = "com.apple.speech.synthesis.voice.ellen" engine.setProperty('rate', 100) engine.setProperty('voice', nl_voice_id) engine.say(WORD) engine.runAndWait() #del engine <this did not work print("after runAndWait") window.after(3000) print("after after") word['text'] = '' print("after text") window.update() print("after update") ANSWER = tk.Entry(window, width=20, bg="white") print("after entry") ANSWER.grid(row=2, column=0) print("after ANSWER") tk.Button(window, text="Check", width=6, command=lambda: check(ANSWER,WORD)) .grid(row=3, column=0) print("after button") WORDS.remove(WORD) print("after remove")