Why does a custom TTS voice work in PowerShell ISE but not in the console?

0
2
Asked By VelvetKite42 On

I'm testing text-to-speech voices with this PowerShell script:

Add-Type -AssemblyName System.Speech
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$synth.SelectVoice("Gabi")
$synth.Speak("Text goes here")

The downloaded voice named "Gabi" works from PowerShell ISE, but the same script fails in the regular PowerShell console with an error saying that the voice cannot be selected because it is not installed or is disabled. The built-in Microsoft voices work in both environments. Both PowerShell processes are running as administrators and are 64-bit. Why can ISE find the voice when the normal console cannot?

2 Answers

Answered By QuietPanda88 On

ISE and the regular console are separate host processes, so a voice or assembly can be exposed differently even when both are running elevated and as 64-bit. Check the loaded assembly and runtime in each session, and explicitly load System.Speech before creating the synthesizer. Also verify that the downloaded voice is installed for the same Windows account and architecture used by the console; some third-party voices register only for a particular user or host.

Answered By MapleOrbit7 On

First compare the voices that each process can actually see rather than relying on the installed-voices list in Windows. Run this in both environments:

$synth.GetInstalledVoices().VoiceInfo | Format-Table *

If "Gabi" is missing or has a different name in the console, SelectVoice must use the exact voice name returned by VoiceInfo. If the lists really are identical, the next things to compare are the PowerShell versions, process bitness, and whether one session is loading a different System.Speech assembly.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.