Created
December 5, 2016 00:08
-
-
Save SadProcessor/b220f2329325d7b878f58b8a9986105e to your computer and use it in GitHub Desktop.
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
function Out-Loud(){ | |
Param( | |
#Message | |
[Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] | |
[ValidateNotNull()] | |
[String[]]$Text, | |
#Voice | |
[ValidateSet('David', 'Zira', 'Hazel')] | |
[String]$Voice = 'Zira', | |
#Volume | |
[ValidateRange(0,100)] | |
[int]$Volume=100, | |
#Rate | |
[ValidateRange(-10,10)] | |
[int]$Rate=-1 | |
) | |
Begin{ | |
#add Text type and create Text object | |
Add-Type -AssemblyName System.Speech | |
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer | |
#adjust voice settings | |
$SpeechSynth.SelectVoice("Microsoft $voice Desktop") | |
$SpeechSynth.volume=$Volume | |
$SpeechSynth.Rate=$Rate | |
} | |
Process{ | |
# Say it loud... | |
$SpeechSynth.Speak($Text) | Out-Null | |
} | |
End{} | |
} | |
#create alias for cmdlet | |
set-alias Say Out-Loud | |
function Play-ImperialMarch(){ | |
[console]::beep(440,500) | |
[console]::beep(440,500) | |
[console]::beep(440,500) | |
[console]::beep(349,350) | |
[console]::beep(523,150) | |
[console]::beep(440,500) | |
[console]::beep(349,350) | |
[console]::beep(523,150) | |
[console]::beep(440,1000) | |
[console]::beep(659,500) | |
[console]::beep(659,500) | |
[console]::beep(659,500) | |
[console]::beep(698,350) | |
[console]::beep(523,150) | |
[console]::beep(415,500) | |
[console]::beep(349,350) | |
[console]::beep(523,150) | |
[console]::beep(440,1000) | |
} | |
set-alias ImperialMarch Play-ImperialMarch | |
## | |
Say 'Luke... I am your Shell Father!' -voice David -Rate -4 -volume 100 | |
ImperialMarch | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment