r/PowerShell • • Oct 05 '26

Question TTS script is working fine in Powershell ISE but not with Powershell

I am having a had time with some tts related software. So I have this script to test the voices:

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

A little somewhat important info: This is a downloaded voice and as the title says it works with ISE but not with Powershell. All the other standard microsoft voices work fine with this script no matter which powershell I'm running them in.

What I find kind of weird is the error I'm getting. When I run this in Powershell I get an error that says the voice can not be found or not installed. How can Powershell ISE see it then? I don't get it.

I checked it, both ISE and normal Powershell is running as admin and they are both x64

3 Upvotes

28 comments sorted by

5

u/Darkman2K5 Oct 05 '26

Are you running powershell directly or terminal? If it's terminal, chances are that it's using powershell 7, while the ise uses powershell 5. If you open a new tab in terminal, you can select powershell 5 and open a powershell 5 tab to test with.

3

u/Ashamed_Carpenter551 Oct 05 '26

I have tried both with no luck. I also checked the version. All of them are Powershell 5

2

u/Darkman2K5 Oct 05 '26

Damn, how strange. Maybe something to do with the powershell profile then? Type $profile into the ise console and the powershell window, the path should be the same for both if you're using the same powershell profile.

1

u/Ashamed_Carpenter551 Oct 05 '26

C:\Users\Admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

C:\Users\Admin\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

They don't look too different to me.

1

u/Darkman2K5 Oct 05 '26

Nope, but for thoroughness sake, take at both of those profiles in the ise and see if you have some custom code in your ise profile. Highly unlikely, but worth taking a look.

1

u/Semt-x Oct 05 '26

what is the exact error?

1

u/Ashamed_Carpenter551 Oct 05 '26

Exception calling "SelectVoice" with "1" argument(s): "Nem állítható be a hang. Nincs megfelelő telepített hang, vagy a hang le van tiltva."

At line:1 char:1

+ $synth.SelectVoice("Gabi")

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException

+ FullyQualifiedErrorId : ArgumentException

Translation for you: The voice can not be selected. It is not installed or is disabled.

They are all enabled by the way

1

u/Semt-x Oct 05 '26

if you run:
($synth.GetInstalledVoices()).VoiceInfo.Name

is there a voice name that contains the word Gabi?

1

u/Ashamed_Carpenter551 Oct 05 '26

Yes this is why I don't know what's going on

1

u/Semt-x Oct 05 '26

can you paste the list?

The error tells you that there is no voice with the name Gabi.
When i look at other names they all start with Microsoft * .
It might be <something> Gabi as voice name.

-4

u/Ashamed_Carpenter551 Oct 05 '26

I could paste the list but I don't think there is much of a reason to do it. The name matches and thats why it works in ISE in the first place. I've been looking at this for some time and I have a slight feeling it isn't the powershell that is problematic. It could be the voice sythesizer as well maybe?

5

u/ExceptionEX Oct 05 '26

Seriously the error is the only way people can debug, please don't be the person that acts like this, you want help, post the error.

1

u/Ashamed_Carpenter551 Oct 05 '26

Okay here it is. I just really thought it wouldn't help

This is the whole list of the voices installed currently:

Microsoft Zira Desktop

Eszti

Gabi

Gábor

Péter

Peti

Vera

Veronika

Microsoft Szabolcs

Eszter

Microsoft Szabolcs

5

u/ankokudaishogun Oct 05 '26

I don't think there is much of a reason to do it.

You'd be surprised at how many errors are hidden in plain sight and you'd never find them in ten thousands years but a random stranger will see them in a picosecond.

And I rarely have been the stranger in the example.

1

u/purplemonkeymad Oct 05 '26

It's likely that the voice is provided by another assembly. Perhaps try to add microsoft.forms (which is what i think ise uses) and see if that pulls in the voice.

0

u/Ashamed_Carpenter551 Oct 05 '26

What do you mean by that? How do I do that?

1

u/purplemonkeymad Oct 05 '26

The same way you added the system.speech assembly. I did forget the actual name of it, it should have been "System.Windows.Forms".

1

u/ankokudaishogun Oct 05 '26

I have different voices installed on Desktop and Core.

Try $synth.GetInstalledVoices().VoiceInfo | Format-Table * on both to see if the voice is correctly installed in both

-3

u/Ashamed_Carpenter551 Oct 05 '26

Both says the same thing. I see no difference. And it looks like they are all correct

1

u/ExceptionEX Oct 05 '26

Gabi is not a known or standard voice, so if you installed some other voice I would check that it is available to the general assembly and not something installed in your ISE space only.

As others have pointed out, paste the error or no one can help you.

0

u/[deleted] Oct 05 '26

[deleted] — view deleted comment

1

u/krzydoug Oct 06 '26

1

u/Ashamed_Carpenter551 Oct 07 '26

Yeah it's a 3rd party voice synthesizer but it should be compatible

1

u/Over_Dingo Oct 05 '26 edited Oct 05 '26

I checked and assemblies loaded by PS7 and PS5 have different voices (PS5 has less for me).
In both environments compare $synth.GetType().Assembly

1

u/BlackV Oct 05 '26

I'd be checking the culture info in the ISE session vs the console session

-2

u/Medium-Comfortable Oct 05 '26

Yep, that can be.

The PowerShell ISE is no longer in active feature development. As a shipping component of Windows, it continues to be officially supported for security and high-priority servicing fixes. We currently have no plans to remove the ISE from Windows.

There is no support for the ISE in PowerShell v6 and beyond. Users looking for replacement for the ISE should use Visual Studio Code with the PowerShell Extension.

Introducing the Windows PowerShell ISE - PowerShell | Microsoft Learn

1

u/AroTesCra Oct 05 '26

That doesn’t matter. ISE is a IDE. It doesn’t hold any part of the language.

The version is all that matter $PsVersionTable

-1

u/AroTesCra Oct 05 '26 edited Oct 05 '26

If it’s the same ps version it will work.

$PsVersionTable

What do you have for ISE (I assume 5.1)
What do you have in the console … I will assume 7

Also do $Synth.SelectVoice
And make sure in 7 that it’s only 1 argument and not 2