python -m pip install pypiwin32
#coding:utf-8
import win32com.client
spk = win32com.client.Dispatch("SAPI.SpVoice")
spk.Speak(u"你好呀,this is test tts by win32com")
#coding:utf-8
import win32com.client
import time
spk = win32com.client.Dispatch("SAPI.SpVoice")
while 1:
t = time.localtime() # 当前时间的纪元值
fmt = "%H %M"
now = time.strftime(fmt, t) # 将纪元值转化为包含时、分的字符串
now = now.split(' ') #以空格切割,将时、分放入名为now的列表中
hour = now[0]
minute = now[1]
print (hour,minute)
if hour == "10" and minute == "27":
spk.Speak(u"请注意,请注意,It's time for homework")
time.sleep(5)
time.sleep(5)