Use the Windows Speech Synthesizer to read Hitchhiker’s Guide to the Galaxy to you

5/5 - (4 votes)

While messing around today on lunch, I got it in my head that it would be fun to have my computer read the infamous “Hitchhiker’s Guide to the Galaxy” to me.

While I didn’t intend for it to happen in the worst possible way, I did succeed.

$url = "https://archive.org/stream/TheultimateHitchhikersGuide/The%20Hitchhiker%27s%20Guide%20To%20The%20Galaxy_djvu.txt"
$data = Invoke-WebRequest -Uri $url
$text = $data.AllElements | ? { $_.Tagname -eq "pre" }

Add-Type -AssemblyName System.Speech
(New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak("$text")

You can’t pause the recording (or even Ctrl-C your way out of it).  But hey, it’s what you get for free.

So long, and thanks for all the fish.