Multi-Language Voice Output

On Windows 10, the operating system ships with a bunch of high-quality text-to-speech engines and is no longer limited to just the English language. The number of available TTS Engines depends on the languages you installed.

PowerShell can send text to these TTS Engines, and via tags can also control the language used. If you have both the English and German TTS Engines installed, you could mix languages like below:

$text = "<LANG LANGID=""409"">Your system will restart now!</LANG>
<LANG LANGID=""407""><PITCH MIDDLE = '2'>Oh nein, das geht nicht!</PITCH></LANG>
<LANG LANGID=""409"">I don't care baby</LANG>
<LANG LANGID=""407"">Ich rufe meinen Prinz! Herbert! Tu was!</LANG>
"

$speaker = New-Object -ComObject Sapi.SpVoice
$speaker.Rate = 0
$speaker.Speak($text)

If you want to use different languages, simply adjust the LANGID number to the culture you would like to use.

Twitter This Tip! ReTweet this Tip!

  • There are 2 voices installed by default in Windows 10.  David and Zira.

    Using the above code, you can view all installed voices by using the following command:

    $speaker.GetVoices()

    To change from David (first voice) to Zira (second voice) use thje following command:

    $speaker.voice=$speaker.GetVoices().item(1)

    To change back to David, use this command:

    $speaker.voice=$speaker.GetVoices().item(0)