Monday, July 12, 2010

PowerShell Needs a New Approved Verb

I’ve been playing around a bit with the System.Speech namespace, in particular the System.Speech.Synthesis.SpeechSynthesizer class. This class allows you go get the Speech Synthesis engine speak for you. On my workstation, I have just one voice, called Anna. If you look over on my PSHScripts blog, there’s a script to get all of the voices installed on your system.

As you can see from the script, the class is pretty simple, although it’s one that PowerShell loads by default. Once you create a SpeechSynthesizer object, you can then get the installed voices as the script shows. As you can see, on my system, there’s only one loaded voice (Anna).  The Speech Synthesizer has another useful class – Speak (well two, the second being SpeakAsync). These methods enable the SpeechSynthesizer object to speak some text.

I’ve written a couple of scripts that will demonstrate these APIs, and I’ll publish these shortly. But in doing so, I realised that the PowerShell Approved Verb list needs a new verb: Speak, which mirrors the Speak method. If you look closely at the approved verb list, there’s no verbs relating to a voice modality, which with the benefit of hindsight, is unfortunate. For Version 3, I think a new verb is needed, which could be Speak (my favourite) or perhaps Say.

 

2 comments:

Shay Levy said...

How about Out-Voice?

Unknown said...

+1 for Out-Voice. Then you can change your command from Get-InstalledVoice to simply Get-Voice, and all of a sudden you're on your way to a Voice module. :)

Out is the right verb because you would want this command at the end of the pipeline anyway.