Days before @xmcp built a strange (and useless) program reporting the time with TTS, along with a “Beep” sound, in demonstration of the current time. We are now particularly in favour of this design and refer to this program occasionally.
I think I could call this program xmTime
, if he does not disencourage this format of naming programs.
The source code of the program is released as follows. If this violates the copyright of @xmcp, please contact me immediately for the takedown of this source code.
#coding=utf-8
from __future__ import division
import sys
import os
if sys.version[0]=='3':
os.system("start C:/Programs/Python2/pythonw.exe "+sys.argv[0])
from Tkinter import *
from ttk import *
import base64
import threading
import time
beep='UklGRigFAABXQVZFZm10IBAAAAABAAEAAAgAAAAQAAACABAAZGF0YQQFAACYOpg6mDqYOpbUvgX\
nIonGQTL+7vPmIjbVyJ4bPA5Iz/U51dog/W4pe8VLLWj3c9/WOFTMvRNsFgnLEjjh4ZL0EC+xxVknAACn\
2E868NBuCx8e7sf3NJTpQ+ysMyrHjSCYCLXShTqS1uACKyULxrgwxPFi5Cs33skNGQIRv813ORndQvpqK\
2jFaitC+hnddzm/zQIRDRneySs3YuTE8bgwC8YrJeACktaFOrXSmAiNICrHrDND7JTp9zTuxx8ebgvw0E\
86p9gAAFknscUQL5L04eESOAnLbBa9E1TM1jhz32j3Sy17xW4pIP3V2vU5SM88Dp4b1cgiNvPm/u5BMon\
G5yK+BZbUmDqW1L4F5yKJxkEy/u7z5iI21cieGzwOSM/1OdXaIP1uKXvFSy1o93Pf1jhUzL0TbBYJyxI4\
4eGS9BAvscVZJwAAp9hPOvDQbgsfHu7H9zSU6UPsrDMqx40gmAi10oU6ktbgAislC8a4MMTxYuQrN97JD\
RkCEb/NdzkZ3UL6aitoxWorQvoZ3Xc5v80CEQ0Z3skrN2LkxPG4MAvGKyXgApLWhTq10pgIjSAqx6wzQ+\
yU6fc07scfHm4L8NBPOqfYAABZJ7HFEC+S9OHhEjgJy2wWvRNUzNY4c99o90ste8VuKSD91dr1OUjPPA6\
eG9XIIjbz5v7uQTKJxucivgWW1Jg6ltS+BeciicZBMv7u8+YiNtXInhs8DkjP9TnV2iD9bil7xUstaPdz\
39Y4VMy9E2wWCcsSOOHhkvQQL7HFWScAAKfYTzrw0G4LHx7ux/c0lOlD7KwzKseNIJgItdKFOpLW4AIrJ\
QvGuDDE8WLkKzfeyQ0ZAhG/zXc5Gd1C+moraMVqK0L6Gd13Ob/NAhENGd7JKzdi5MTxuDALxisl4AKS1o\
U6tdKYCI0gKsesM0PslOn3NO7HHx5uC/DQTzqn2AAAWSexxRAvkvTh4RI4CctsFr0TVMzWOHPfaPdLLXv\
Fbikg/dXa9TlIzzwOnhvVyCI28+b+7kEyicbnIr4FltSYOpbUvgXnIonGQTL+7vPmIjbVyJ4bPA5Iz/U5\
1dog/W4pe8VLLWj3c9/WOFTMvRNsFgnLEjjh4ZL0EC+xxVknAACn2E868NBuCx8e7sf3NJTpQ+ysMyrHj\
SCYCLXShTqS1uACKyULxrgwxPFi5Cs33skNGQIRv813ORndQvpqK2jFaitC+hnddzm/zQIRDRneySs3Yu\
TE8bgwC8YrJeACktaFOrXSmAiNICrHrDND7JTp9zTuxx8ebgvw0E86p9gAAFknscUQL5L04eESOAnLbBa\
9E1TM1jhz32j3Sy17xW4pIP3V2vU5SM88Dp4b1cgiNvPm/u5BMonG5yK+BZbUmDqW1L4F5yKJxkEy/u7z\
5iI21cieGzwOSM/1OdXaIP1uKXvFSy1o93Pf1jhUzL0TbBYJyxI44eGS9BAvscVZJwAAp9hPOvDQbgsfH\
u7H9zSU6UPsrDMqx40gmAi10oU6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOp\
g6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg\
6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDqYOpg6mDo='
bmem=base64.b64decode(beep)
def sayit():
from win32com import client as w32
voice=w32.Dispatch("SAPI.SpVoice")
def waitfor10s():
sec=time.localtime().tm_sec%30
if sec<29:
time.sleep(29-sec)
while time.localtime().tm_sec%30:
time.sleep(0.05)
def baoshi():
def proctime(timeobj):
h=timeobj.tm_hour
m=timeobj.tm_min
s=timeobj.tm_sec
if s: s = ' plus %d seconds' % s
else: s = ''
return (h,m,s)
# voice.Speak(u'下面阴响、是北京时间、%s点、%s分、%s秒'%proctime(tnow))
voice.Speak(u'The time at next beep is %d %d %s'%proctime(tnow))
from winsound import PlaySound,SND_MEMORY,SND_PURGE
waitfor10s()
while True:
tnow=time.localtime(time.time()+30)
time.sleep(20)
baoshi()
waitfor10s()
PlaySound(bmem,SND_MEMORY|SND_PURGE)
time.sleep(.5)
def disp():
while True:
timenow.set(time.strftime("%H:%M:%S", time.localtime()))
t=time.time()
if t%1<0.85:
time.sleep(.9-t%1)
while t%1==time.time()%1:
time.sleep(.05)
tk=Tk()
tk.title('Time Reporter')
tk.resizable(False,False)
tk.attributes('-topmost', True)
tk.attributes('-toolwindow', True)
timenow=StringVar()
Label(tk,textvariable=timenow,font='Consolas -50',width=8).grid(row=0,column=0,padx=10,pady=5)
t=threading.Thread(target=disp,args=())
t.setDaemon(True)
t.start()
t=threading.Thread(target=sayit,args=())
t.setDaemon(True)
t.start()
mainloop()