Text-to-Speech (TTS) fun with PowerShell!

Pre X-Mas fun in the office.

A colleague of mine pointed me to the “Bastard Operator From Hell”-Style Excuses generator. We figured it might be fun to use Text-to-Speech (TTS) to read-out random excuses or, if you down for it, some isults.

Using Text-to-Speech in Powershell

Using Text-to-Speech in PowerShell is quite easy. We use ‘Add-Type‘ to add the ‘System.Speach‘ .NET Framework namespace as this is not loaded by default. Then we use the ‘Speak‘ method from the ‘SpeechSynthesizer‘ class to read out a string.

Easy peasy….

Getting the excuse / insult

The “Bastard Operator From Hell”-Style Excuses generator provides the excuses while www.insultgenerator.org provides us with some random insults. We can use the ‘Invoke-WebRequest‘ cmdlet to get and parse the HTML data.

Let’s get an excuse first:

Now, we can do the same approach for insults:

I’ll spare you the output of this one ;-), use at your own risk.

Putting it all together in a module

Everything put together nicely in a PowerShell module below.

Leave a Comment

Your email address will not be published. Required fields are marked *