Created
June 8, 2016 21:53
-
-
Save mickdekkers/0e58604368bff1b3be96e25a97b49600 to your computer and use it in GitHub Desktop.
Command line Text-to-Speech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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