0

I have written a simple code by using Tkinter and pyttsx3 which convert text to speech. but after converting to .exe file nothing is opening and showing error "the application could not be run." I have converted so many projects from .py to .exe, all are running well but this is the first time the error is coming.

import tkinter as tk
import pyttsx3

engine = pyttsx3.init()


class Widget():
    def __init__(self):
        self.root = tk.Tk()
        self.root.title('TTS')
        self.root.resizable(0, 0)
        self.label1 = tk.Label(self.root, text='What do you want me to speak?')
        self.label1.pack()
        self.entry = tk.Entry(self.root)
        self.entry.pack()
        self.button = tk.Button(self.root, text='Speak!', command=self.clicked)
        self.button.pack()
        self.root.mainloop()

    def speak(self, text):
        engine.say(text)
        engine.runAndWait()

    def clicked(self):
        text = self.entry.get()
        rate = engine.getProperty('rate')
        engine.setProperty('rate', 150)
        voices = engine.getProperty('voices') 
        engine.setProperty('voice', voices[1].id)
        self.speak(text)


if __name__ == '__main__':
    widget = Widget()
shimo
  • 2,156
  • 4
  • 17
  • 21

0 Answers0