So I have been testing pyttsx3 but when I try to bind it with a key such as below, It says works once then crashes the GUI. Any idea how to solve this ? I have tired it with PyQt5 and same result. your help is really appreciated, Thank you. This is the code I have tried -
from tkinter import *
import pyttsx3
import threading
def start_eng(txt):
engine = pyttsx3.init()
engine.say(txt)
engine.runAndWait()
def run_msg(key):
#engine = pyttsx3.init()
text=txt.get()
threading.Thread(target=start_eng, args=(text,)).start()
print("space clicked")
window = Tk()
window.title("Testing")
window.geometry('300x300')
lbl = Label(window, text="Hello")
txt = Entry(window,width=10)
lbl.grid(column=0, row=0)
txt.grid(column=1,row=1)
txt.bind('<space>', run_msg)
window.mainloop()