Speech-Week: Using Different Voices with Speech Synthesizer

by Jan 27, 2017

In the previous tip we showed how you can tap into the text to speech converter and speak out text. Here is a way to find out the installed languages on your system:

#requires -Version 2.0
Add-Type -AssemblyName System.Speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.GetInstalledVoices() | 
  Select-Object -ExpandProperty VoiceInfo | 
  Select-Object -Property Culture, Name, Gender, Age

The result may look similar to this:

 
Culture Name                    Gender   Age
------- ----                    ------   ---
en-US   Microsoft Zira Desktop  Female Adult
en-US   Microsoft David Desktop   Male Adult
de-DE   Microsoft Hedda Desktop Female Adult
 

The default voice used by the synthesizer can be found like this:

$speak.Voice

Provided your system has different voices installed, here is how to select a different voice. Simply submit the name of the voice you want to use. This example uses the German voice engine on German Windows 10 systems:

#requires -Version 2.0
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.SelectVoice('Microsoft Hedda Desktop')
$speak.Speak('Jetzt spreche ich deutsch.')

Twitter This Tip! ReTweet this Tip!