WagoL
WagoL

Reputation: 107

Speech synthesizer can't select installed voice

I'm having the following program:

        SpeechSynthesizer synth = new SpeechSynthesizer();
        List<InstalledVoice> installedVoices = new List<InstalledVoice>();
        foreach (InstalledVoice voice in synth.GetInstalledVoices())
        {
            installedVoices.Add(voice);
            Console.WriteLine(voice.VoiceInfo.Name);
        }
        synth.SelectVoice(installedVoices[1].VoiceInfo.Name);
        synth.Speak("This is in English");

The output of the installed voices is this:

Microsoft Anna
Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)
Microsoft Server Speech Text to Speech Voice (fr-CA, Harmonie)
Microsoft Server Speech Text to Speech Voice (nl-NL, Hanna)

When I run the program with synth.SelectVoice(installedVoices[0].VoiceInfo.Name); It works without any problem. When run it with synth.SelectVoice(installedVoices[1].VoiceInfo.Name); To get Hazel to read the sentence I get the following SystemArgumentException:

{"Cannot set voice. No matching voice is installed or the voice was disabled."}

And all voices are enabled. I have installed the following things:

  1. Microsoft Speech Platform - Runtime (Version 11)
  2. Microsoft Speech Platform - Software Development Kit (SDK) (Version 11)
  3. And additional languages as seen in the printed list.

And I followed this guide to get my languages to be recognized by my OS (win7x64). How come I can only use Anna?

Upvotes: 0

Views: 3465

Answers (1)

WagoL
WagoL

Reputation: 107

I made it work. This is what I did. I used the wrong SpeechSynthesizer I used System.Speech.SpeechSynthesizer instead of Microsoft.Speech.Synthesis. You have to add Speech.dll reference wich located at C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly

And then I could use Hazel, Harmonie and Hanna but Anna not anymore (I don't need her anyway).

Also don't forget to set your project build to x64 because the SDK is x64 or install the x86 SDK and runtime.

Upvotes: 3

Related Questions