question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Speech.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:closed
  • Created 2 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
ghostcommented, Jun 17, 2021

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!

2reactions
SeeminglySciencecommented, Jun 21, 2021

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 to Resolution-Fixed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found