Speech-Week: Recording Voice to File Synthesizer

The built-in Microsoft text to speech engine can save audio to a file. This way, you can auto-generate WAV files. Here is an example: it creates a new “clickme.wav” file on your desktop, and when you run the file, you hear spoken text:

#requires -Version 2.0
$Path = "$home\Desktop\clickme.wav"

Add-Type -AssemblyName System.Speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.SetOutputToWaveFile($Path)
$speak.Speak('Hello I am PowerShell!')
$speak.SetOutputToDefaultAudioDevice()

Invoke-Item -Path $Path

Twitter This Tip! ReTweet this Tip!