Text-to-Speech

by Oct 6, 2011

Here is a fun function that converts text to speech. It even has a switch parameter called -Drunk to change the voice accordingly:

function Out-Text {
    param(
        [Parameter(Mandatory=$true)]
        $Text,

        [switch]
        $Drunk
    )

    $object = New-Object -ComObject SAPI.SpVoice
    if ($drunk) { $object.Rate = -10 }
    $object.Speak($text) | Out-Null
}

Twitter This Tip!
ReTweet this Tip!