| 4 | # saytext = input("What should I say? ") |
| 5 | |
| 6 | class GUI: |
| 7 | def __init__(self): |
| 8 | self.root = tk.Tk() |
| 9 | |
| 10 | self.root.title("Text To Speech") |
| 11 | self.root.geometry("500x500") |
| 12 | |
| 13 | self.label = tk.Label(self.root, text="Type what you want me to say!", font=('Arial', 16)) |
| 14 | self.label.pack(padx=10, pady=10) |
| 15 | |
| 16 | self.textbox = tk.Entry(font=('Arial', 16)) |
| 17 | self.textbox.pack(padx=10, pady=10) |
| 18 | |
| 19 | self.button = tk.Button(text="CLICK ME!", font=('Arial', 16), command=self.button_click) |
| 20 | self.button.pack(padx=10, pady=10) |
| 21 | |
| 22 | self.root.mainloop() |
| 23 | |
| 24 | def button_click(self): |
| 25 | engine = pyttsx3.init() |
| 26 | engine.say(self.textbox.get()) |
| 27 | engine.runAndWait() |
| 28 | |
| 29 | GUI() |