So in a previous post, I discussed how to make a PowerShell Annoy-a-Tron and remotely deploy it via WMI / Remote PowerShell. Recently, a close friend who has become obsessed with PowerShell created a snippet of code that uses the TTS engine to make the computer say anything:
# talking computers
# bring in the speech assembly into powershell
Add-Type -AssemblyName System.Speech
# get a speech synthesizer object
$synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
# say what you want
$synth.Speak('Would You Like To Play A Game?')
#clear out the message
$synth.Dispose()
#### info lookups
#SpeakAsync()
$synth | Get-Member
$synth.GetInstalledVoices().voiceInfo
$synth.SelectVoice('Microsoft David Desktop')
'Microsoft Zira Desktop'
'Microsoft David Desktop'
And here we have wrapped it into a remote scriptblock:
Invoke-Command -ComputerName $computername -Credential $cred -ScriptBlock{
Add-Type -AssemblyName System.Speech
# get a speech synthesizer object
$synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
# say what you want
$synth.Speak('I'm afraid I can't do that, Dave')
#clear out the message
$synth.Dispose()
}
Credit goes to my close friend Drew Crouch, for hacking up the speech code using the System.Speech .NET method.