Text to speech in Powershell using .NET

<br>function Out-TextToSpeech {  <p>param (<br>[Parameter(Mandatory=$true, ValueFromPipeline=$true)]<br>[string] $Text,<br>[switch] $Async=$false<br>)</p> <p>[Reflection.Assembly]::LoadWithPartialName('System.Speech') | Out-Null<br>$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer<br>if ($Async) {<br>$synth.SpeakAsync($Text)<br>} else {<br>$synth.Speak($Text)<br>}<br>}</p> <p>Out-TextToSpeech "i lost my socks" -async<br>

If you use the –Async switch then the func won’t block the console while the text is spoken

Advertisements

Tagged: ,

One thought on “Text to speech in Powershell using .NET

  1. ugg clearance 3.12.2012 at 03:50 Reply

    I am so happy to read this. This is the kind of manual that needs to be given and not the accidental misinformation that’s at the other blogs. Appreciate your sharing this best doc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

smsagent

Tips, tricks and time-savers for the Windows and ConfigMgr administrator

To The Point

Anything about Technology and Business

Brian's Power Windows Blog

Microsoft in the Enterprise. Windows, Hyper-V, Exchange, SQL, and more!

PowerScripting Podcast

Shownotes and links for the PowerScripting Podcast, a podcast to help people learn Windows Powershell

Learn Powershell | Achieve More

What is this Powershell of which you speak?

%d bloggers like this: