PowerShell – Speech in a Function

email me

function TextToSpeech {
param([Parameter(Mandatory=$true)]$Text, [switch]$Fast, [switch]$Slow)
$VoiceObject = New-Object -ComObject SAPI.SpVoice
if ($Slow) { $VoiceObject.Rate = -8 }
if ($Fast) { $VoiceObject.Rate = +3 }
$VoiceObject.Speak($text) | Out-Null}
TextToSpeech -Text "Hello! My name is Eddie Jackson."
TextToSpeech -Text "Hello! My name is Eddie Jackson." -Slow
TextToSpeech -Text "Hello! My name is Eddie Jackson." -Fast