Make PowerShell Speak!

By adding a new system type called System.Speech, you can make PowerShell speak out loudly:

Add-Type -AssemblyName System.Speech

$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.Speak('Hey, I can speak!')

This .NET approach can replace the old COM-based approach occasionally used:

$oldstuff = New-Object COMObject SAPI.SpVoice
$oldstuff.Speak(Hey, I can speak!) | Out-Null

The .NET code can do much more, supports lexicons and provides more information. This line will list the voices installed on your system for example:

$synthesizer.GetInstalledVoices() | ForEach-Object { $_.VoiceInfo }

Twitter This Tip! ReTweet this Tip!


Posted Feb 20 2012, 06:00 AM by ps1

Comments

rec wrote re: Make PowerShell Speak!
on 02-22-2012 1:57 PM

How can you change the voice?

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.