Tkinter和pyttsx

2024-04-29 07:25:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在我的程序中被这个问题困住了。我要做的是在python3中使用Tkinter实现一个简单的接口,在程序开始时,感谢pyttsx,应该说:“大家好”。问题是:当我运行程序时,界面出现了,但没有声音。然后,当我关上窗户时,声音开始说话。在

代码如下:

from tkinter import *
import pyttsx3

engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
    engine.setProperty('voice',voice.id)

def Say_the_message():
    root = Tk()
    root.title("Say the message")
    root.geometry("300x300")
    root.resizable(height=FALSE,width=FALSE)
    label1 = Label(root,text="Hello everyone")
    label1.grid()
    root.mainloop()
    engine.say("Hello everyone")
    engine.runAndWait()


Say_the_message()

我希望我做的不是太难,也希望是可行的。 也请原谅我英语不好。在


Tags: theimport程序false声音messagehelloroot