System.Speech.Synthesis.SpeechSynthesizer Speak method throws Object reference not set to an instance of an object." in PowerShell 7.x, but not in PowerShell 5.1.
See original GitHub issueSpeech.Synthesis.SpeechSynthesizer Broken in CORE
RE-OPENED 8809
Steps to reproduce
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.Speak("test");
Expected behavior
hear "test" from speakers, just like in PS 5.1
Actual behavior
Exception calling "Speak" with "1" argument(s): "Object reference not set to an instance of an object."
Environment data
POWERSHELL 5
PSVersion 5.1.17134.407
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.407
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
POWERSHELL CORE 7.1.3
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
Function ported from Powershell 5 to Powershell 7 fails ...
System.Speech.Synthesis.SpeechSynthesizer Speak method throws Object reference not set to an instance of an object." in PowerShell 6.1.2.
Read more >Getting Error "Object reference not set to an instance" while ...
Hi, I am trying to execute get subscription using get-msolaccountsku. I am executing this script in .Net core application. Getting "Object ...
Read more >How to Convert Text to Speech with PowerShell
"ParentContainsErrorRecordException: Exception calling "Speak" with "1" argument(s): " Object reference not set to an instance of an object." ?
Read more >Give PowerShell a Voice Using The SpeechSynthesizer Class
Lets start digging into this by creating an object using the SpeechSynthesizer class. But before that, we need to add the System.Speech assembly ......
Read more >Object reference not set to an instance of an object
I'm now using a service account (e.g. “PSUSvc”) and using that account the script runs fine in an interactive PowerShell session (both v5.1...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
All good. I understand. Thank you for the time you took for this reply. I will go down the rabbit hole and let the community know if I figure out anything. Cheers!
Just to fully clarify, this will work in the latest preview because PowerShell happens to ship with a new version of the
System.Speech
library that no longer has this bug. The label for this could be switched toResolution-Fixed
.