This is a fun way to utilize Text to Speed (TTS) with PowerShell for Halloween. This is a fun little prank you can use to turn your users computers into “haunted” computers as long as they’ve got their speakers on.
We use the cmdlet Add-Type to add a .NET framework type to a PowerShell session. We can then instantiate a SpeechSynthesizer object to turn our text into audio output. It’s pretty exciting.
The easiest way to try this is like so:
You can even jazz it up a bit by modifying the speed of speech by modifying the rate property of the object. Here’s a good resource to see the different properties/methods of this object – link (scroll towards the bottom).
Buy PDQ Inventory
From there, we can start having some fun. For example, we could place a list of phrases into an array or a separate text file and pull a phrase at random to be synthesized. Be sure to choose which method you’d like to use.
Hopefully, this gives you some fun ideas for Halloween tomorrow!
Those of you who want to experiment with even more control over TTS can make use of Speech Synthesis Markup Language (SSML).
Here’s an example: