Программа say.py:
from tkinter import *
import pyttsx3
def speak():
engine = pyttsx3.init()
engine.say(message.get())
engine.runAndWait()
root = Tk()
root.title("Воспроизведение текста...")
root.geometry("250x150")
message = StringVar()
message_text = Label(text="Введи текст в поле ниже")
message_text.place(relx=.5, rely=.1, anchor="c")
message_entry = Entry(textvariable=message)
message_entry.place(relx=.5, rely=.3, anchor="c")
message_button = Button(text="Click Me", command=speak)
message_button.place(relx=.5, rely=.5, anchor="c")
root.mainloop()
Код setup.py:
from cx_Freeze import setup, Executable
base = None
executables = [Executable("say.py", base=base)]
packages = ["tkinter", "pyttsx3"]
options = {
'build_exe': {
'packages':packages,
},
}
setup(
name = "Тукстовый воспроизволитель",
options = options,
version = "0.1",
description = 'Прогамма воспроизводит текст написаный вами!',
executables = executables
)
Скомпилированная программа в .exe Выдает ошибку:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "say.py", line 6, in speak
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\driver.py", line 52, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 23, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 33, in __init__
SAPI5DriverEventSink)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\__init__.py", line 336, in WithEvents
instance = result_class(disp) # This only calls the first base class __init__.
File "C:\Users\Admin\AppData\Local\Temp\gen_py\3.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 3272, in __init__
import win32com.server.util
ModuleNotFoundError: No module named 'win32com.server.util'