Skip to content

Instantly share code, notes, and snippets.

@nikolay-borzov
Created December 24, 2017 19:01
Show Gist options
  • Save nikolay-borzov/006ba21a8147c35c17af28f4671a1cd4 to your computer and use it in GitHub Desktop.
Save nikolay-borzov/006ba21a8147c35c17af28f4671a1cd4 to your computer and use it in GitHub Desktop.
Speak current time on WIndows
' Based on https://thecustomizewindows.com/2011/06/let-your-computer-speak-current-time-and-date-on-startup/
Dim sapi, cHour, cMinute, sentence
Set sapi = CreateObject("SAPI.SpVoice")
with sapi
' 0 - David, 1 - Zira, 2 - Mark
Set .voice = .getvoices.item(1)
end with
cHour = hour(time)
cMinute = minute(time)
sentence = "It's now "
if cHour > 12 then
sentence = sentence & (cHour - 12)
else
if cHour = 0 then
sentence = sentence & "12"
else
sentence = sentence & cHour
end if
end if
if cMinute < 10 then
sentence = sentence & " o'"
if cMinute < 1 then
sentence = sentence & "clock"
else
sentence = sentence & cMinute
end if
else
sentence = sentence & cMinute
end if
if cHour > 12 then
sentence = sentence & " P.M."
else
if cHour = 0 then
if cMinute = 0 then
sentence = sentence & " Midnight"
else
sentence = sentence & " A.M."
end if
else
if cHour = 12 then
if cMinute = 0 then
sentence = sentence & " Noon"
else
sentence = sentence & " P.M."
end if
else
sentence = sentence & " A.M."
end if
end if
end if
Sapi.speak sentence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment