Computer Programming tricks Tricks

Convert Your Windows Clock into a Speaking Clock

We all know there are many application available for speaking clock. But you also know I am a crazy guy who always try to do something out of nothing. So I thought, how to turn your default windows clock to a speaking clock and finally I found a way to it. This technique may not be very useful for checking the time but still a best article for learning purpose.

Steps to do this
  • Copy and paste the following code and save it in .vbs extension. For example, you can store it as SpeakingClock.vbs 
Dim sapi,h,ampm,wish
Set sapi = CreateObject("sapi.spvoice")
end if
end if
end if
if(hour(now)>12) then
end if
select case hour(now)
case 0: h="12"
case 1: h="1"
case 2: h="2"
case 3: h="3"
case 4: h="4"
case 5: h="5"
case 6: h="6"
case 7: h="7"
case 8: h="8"
case 9: h="9"
case 10: h="10"
case 11: h="11"
case 12: h="12"
case 13: h="1"
case 14: h="2"
case 15: h="3"
case 16: h="4"
case 17: h="5"
case 18: h="6"
case 19: h="7"
case 20: h="8"
case 21: h="9"
case 22: h="10"
case 23: h="11"
end select

if(hour(now)>=0 and hour(now)<12) then
wish="Good Morning"
end if
if(hour(now)>=12 and hour(now)<=17) then
wish="Good Afternoon"
end if
if(hour(now)>17 and hour(now)<=23) then
wish="Good Evening"
end if
sapi.Speak wish+". The time is "+ h+" "+ampm
  • Now go to start menu and type “Task” without the quotes. Then click on Task Scheduler which will come in the search result.
    (If you could not find Task Scheduler then you can manually go to Start–>All Programs–>Accessories–>System Tools–>Task Scheduler)
  • In the task scheduler window go to Action tab present on top left and then click on Create Task...(Don’t click on Create a Basic Task…) 
  • A window will open where you can find 5 tabs. In the General tab give a name. Then go to  Trigger tab and click on New… and provide the following settings.
    (For the Start date, you give today’s date and for Start time you give any future time but it should be round figure. For Example if present time is 10:19:30 AM, you can set the time as 11:00:00 AM)
Speaking Clock Settings
  • Now go to Action tab and click on New… Then click on Browse… and give the path to the .vbs file which you had saved in step-1 
  • Now you are done. Click OK 
  • You will see every 1hour it will wish you as Good Morning/Good Afternoon/Good Evening and tell you the time.