1# Speak text to a WAV file with a Windows SAPI voice. Called by `speak`. 2param( 3 [Parameter(Mandatory)] [string] $Text, 4 [Parameter(Mandatory)] [string] $Out, 5 [string] $Voice = "Microsoft David Desktop", 6 [int] $Rate = 0 7) 8Add-Type -AssemblyName System.Speech 9$s = New-Object System.Speech.Synthesis.SpeechSynthesizer 10$s.SelectVoice($Voice) 11$s.Rate = $Rate 12$s.SetOutputToWaveFile($Out) 13$s.Speak($Text) 14$s.Dispose()