talkclock.vbs

rem
rem http://www.davescomputertips.com/2013/05/how-to-create-a-speaking-clock-part-1/
rem
rem Set fso = CreateObject("Scripting.FileSystemObject")
rem Set StdOut = fso.GetStandardStream(1)
rem
Dim speaks, speech, xx, args

set args=wscript.arguments

Set speech = CreateObject("sapi.spvoice.1")
With speech
   rem 0,1,2 selects male or female voices!
   Set .voice = .getvoices.item(0)
   .Volume = 100
  if args.count=0 then
    rem
    rem tell the time
    rem
    strText = Minute(Now)
    intLength = Len(strText)
    intZeroes = 2 - intLength
    For i = 1 to intZeroes
        strText = "0" & strText
    Next
    .rate=3
    .Speak "Current time " & Hour(Now) & " " & strText
  else
    rem
    rem concat all command-line arguments as a string
    rem and speak it
    rem
    speaks = ""
    for each xx in args
      speaks = speaks & " " & xx
    next
    .Speak speaks
  end if
  speech.Speak xx
end with

wscript.quit(0)
Comments