Skip to content

Instantly share code, notes, and snippets.

@pferreirafabricio
Last active June 30, 2021 20:23
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 pferreirafabricio/1eae02c6f315c8c62de43478d4475421 to your computer and use it in GitHub Desktop.
Save pferreirafabricio/1eae02c6f315c8c62de43478d4475421 to your computer and use it in GitHub Desktop.
Making PowerShell talk
<#
Usage example:
./Speak-Powershell.ps1 "Hy PowerShell"
#>
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$textToSpeak = switch ( [String]::IsNullOrEmpty($args[0]) ) {
$true { "Hello World" }
$false { $args[0] }
}
$speak.Speak($textToSpeak)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment