######################################################################## # # Demonstrate how to use built-in Windows speech synthesis, i.e., to # make your computer say stuff... # ######################################################################## Param ( $TextToSpeak = "You can make your computer say anything you wish, such as for audio alerts." ) # Load the .NET assembly (DLL) with the SpeechSynthesizer class: Add-Type -AssemblyName "System.Speech" # Create a SpeechSynthesizer object: $Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer # List available voice types: $Voices = $Speech.GetInstalledVoices() $Voices | ForEach { $_.VoiceInfo | Select Gender,Age,Name,Description } | Format-Table -AutoSize # Select a voice to use, in this case, the last one from the list: $Speech.SelectVoice( $Voices[-1].VoiceInfo.Name ) # Make sure your speakers aren't muted... $Speech.Speak( $TextToSpeak ) return # By adding Speech Synthesis Markup Language (SSML) tags in XML, you can control # pitch, speed, gender, pauses, and other voice qualities: $SSMLmarkup = @' Oh my this is the best SANS course I've ever taken! You betcha sister! '@ $Speech.SpeakSsml( $SSMLmarkup ) # And as long as we are on the subject of Stupid PowerShell Tricks, # here's how you can make your computer sound like it's working hard: Start-Job -Name ThinkingHard -ScriptBlock { while ($true){ [Console]::Beep( (Get-Random -Min 300 -Max 7000), 200) } } # Then stop the beeping later with this: Stop-Job -Name ThinkingHard -PassThru | Remove-Job