Skip to content

Instantly share code, notes, and snippets.

@mickdekkers
Created June 8, 2016 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickdekkers/0e58604368bff1b3be96e25a97b49600 to your computer and use it in GitHub Desktop.
Save mickdekkers/0e58604368bff1b3be96e25a97b49600 to your computer and use it in GitHub Desktop.
Command line Text-to-Speech
#NoEnv
; Require exactly one command line argument
; "The left side of a non-expression if-statement is always the name of a variable." -- https://autohotkey.com/docs/Scripts.htm#cmd
if 0 != 1
{
; Exit the script with code 1 (error)
ExitApp, 1
}
; The first command line argument is the text to say
Loop, %0%
{
speech := %A_Index%
break
}
voice := ComObjCreate("SAPI.SpVoice")
; Try to set the voice to a female voice
Try {
voice.Voice := voice.GetVoices.item(1)
}
voice.Speak(speech)
ExitApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment