Stupid PowerShell Tricks – Getting Your PC to Talk

WarGamesRemember the 80’s? (Too young?)

One of my 80’s favorites was the movie WarGames.

(Hint: You should really watch it on Netflix – it’s a classic.
Here’s the WarGames movie trailer for you kids.)

Anyway, for those of you who DO remember War Games, that speech synthesizer was pretty creepy back in the day.
But it was equally cool because speech was pretty rare in those days unless you had a Texas Instruments TI-99/4A (which I did – woot!)

It’s hard to believe that movie came out 30 years ago, and technology has changed a lot. Windows has had speech built in for quite some time, but did you know you can access the speech API with PowerShell?

Who cares, right? WRONG! It’s pretty fun! And it’s a good bit of code to use to prank your IT co-workers. (Think login script or batch file that runs as a scheduled task…)

Here is a video demo of Windows Server 2012 reading classic computer lines from the movie WarGames:

“Joshua” from WarGames (1983) as played by Windows Server 2012 & PowerShell


Not too shabby for a Windows Server, eh?

So, shall we play a game?

Below is the PowerShell code for you to play with and tweak.
Have fun annoying people!


Copy-and-paste code for WarGames.ps1

    This script employs the Speech API for speaking
    and quotes lines from the movie "WarGames" (1983)
    At the beginning load the Speech API, create a SpeechSynthesizer object.
    It uses this object’s Speak method to speak
    File Name : WarGames.ps1
    Code From : DimiG |
    Requires  : PowerShell Version 2.0
    Just for tutorial

# Add text for speaking here
$text = @(`
"Hello, my name is Joshua.",`
"Greetings Professor Falken.",`
"Shall we play a game?",`
"Of course. I should reach DEF CON 1",`
"and launch my missiles in 28 hours.",`
"Would you like to see some projected kill ratios?",`
"What’s the difference?",`
"You are a hard man to reach.",`
"Could not find you in Seattle",`
"and no terminal is in operation at your classified address.",`
"D O D pension files indicate current mailing as:",`
"Dr Robert Hume,",`
"AKA Stephen W Falken,",`
"5 Tall Cedar Road.",`
"Strange game.",`
"The only winning move is not to play.",`
"How about a nice game of chess?"`

# Load the dll
[System.Reflection.Assembly]::LoadWithPartialName("System.Speech") | out-null

# Create new object
$spk = New-Object System.Speech.Synthesis.SpeechSynthesizer

# Step Up Volume
$spk.Volume = 100

# Check out voices installed on this computer…
$spk.GetInstalledVoices() | %{$_.voiceinfo}

# Now say…

Props: DimiG for the PoSh code

VN:F [1.9.20_1166]
Rating: 7.7/10 (3 votes cast)