Tuesday 13 July 2010

Say-HelloWorld.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script uses the Speech API to say "Hello World" 
  4. .DESCRIPTION 
  5.     This script first loads the Speech API, then creates a  
  6.     SpeechSynthesiser object. It uses this object's Speak method 
  7.     to speak the time honoured phrase "hello world." 
  8. .NOTES 
  9.     File Name  : Say-HelloWorld.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN Sample posted at: 
  16.         http://msdn.microsoft.com/en-us/library/ms586901.aspx 
  17. .EXAMPLE 
  18.     Left as an exercise for the reader. 
  19. #> 
  20. # First load the dll 
  21. [System.Reflection.Assembly]::LoadWithPartialName("System.Speech") | out-null 
  22. $spk = New-Object system.Speech.Synthesis.SpeechSynthesizer 
  23.   
  24. # Now say "Hello world" 
  25. $spk.Speak("Hello world"

No comments: