Skip to content

System.NullReferenceException when using System.Speech 7.0.0-rc.1.22426.10 from Windows Forms  #75667

Closed
@Shkyrockett

Description

@Shkyrockett

.NET version

.NET 7.0.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

.NET 6.0.0

Issue description

When trying to use the latest version of System.Speech from Windows Forms, it throws a System.NullReferenceException while trying to access the SpeechSynthesizer class.

Steps to reproduce

Run the attached project and click the button.

        private void Button_Click(object sender, EventArgs e)
        {
            label.Text = string.Empty;
            using var speech = new SpeechSynthesizer();

            // System.Speech 7.0.0-rc.1.22426.10 throws System.NullReferenceException exception here.
            speech.SetOutputToDefaultAudioDevice();
            speech.SelectVoiceByHints(VoiceGender.Female);
            speech.SpeakProgress += (sender, e) => { label.Text += $"{e.Text} "; };

            speech.Speak("This is a test of the SpeechSynthesizer class.");

            label.Text += "\r\nFinished speaking...\r\n";
        }

Expected: The speech synthesizer should read out the contents of the string.

Actual: Accessing the newly created speech SpeechSynthesizer object throws a System.NullReferenceException exception.

Repro project:
WinFormsSpeechRepro.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions