Did you know that PowerShell has built in commands for speech? This mean that you can get PowerShell to read your commands or results of commands.
How to use PowerShell Speech commands
I recently came across an interesting blogpost about speech commands in PowerShell. I was not aware that PowerShell had built-in commands for Speech, but it has. It is not easy to find much official documentation about it, but I will show you some small examples to get started.
Getting started with PowerShell Speech
At first, we will need to setup the basic and select the voice we want to read up for us. In this example I have chosen the build in female voice named Zira.
$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer
$Speech.SelectVoice(“Microsoft Zira Desktop”)
Now we got the basic covered and now we are ready to give Zira some commands to read up loud.
$message = $message.ToString()
$Speech.speak(“The current time is” + $message)
$Speech.speak(“User logged in is ” + $env:USERNAME)
$Speech.speak(“Computername is ” + $env:computername)
Set Volume level
If you want to control the volume of the speech, you can set the volume level between 0-100 with the command below:
Show available Voices installed
In Windows 10 (US version) there is two default voices to choose. If you have another language of Windows, you might have other voices to choose from. If you install e.g. the German language pack to Windows 10, you will get a voice named Hedda. To see a list of installed voices, execute the command line below:
Change reading speed
It is also possible to change the speed that PowerShell reads with. Try changing the speed to 7 like the example below. This will speed up the reading rate. The rate can be any value between -10 through 10:
More Speech commands
To see the full list of Voice commands, enter the following command:
Now it is your time
I have now learned you the basic skills to get started with PowerShell Speech. Now you can move on an make your own small scripts to read messages up loud. Maybe you can make PowerShell read the weather forecast for you or maybe you can ask PowerShell for the current CPU temperature. Only your imagination is the limit 🙂 Feel free to drop me a comment or ask a question below.
If you, like me, love PowerShell, you should go and visit my little PowerShell World at blogger