SpeechSynthesizer.SelectVoice () Doesn't work with "No matching voice or voice disabled"

I am modifying Scott Hanselman BabySmash's code to support other languages.

  • I installed Speech Platform and New Language in these steps .
  • The language is now displayed in the registry:

    enter image description here

  • The language can now be selected and played by Windows:

    enter image description here

  • System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices()

    now returns the voice.

  • However SelectVoice()

    , the code below generates the error "System.ArgumentException: Voice cannot be installed. The corresponding voice is not installed, or the voice is disabled.
string phrase = null;
SpeechSynthesizer speech = new SpeechSynthesizer();
CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
if (neededVoice == null)
{
    phrase = "Unsupported Language";
}
else if (!neededVoice.Enabled)
{
    phrase = "Voice Disabled";
}
else
{
    speech.SelectVoice(neededVoice.VoiceInfo.Name);
}

speech.Speak(phrase);

      

  1. I've tried upgrading to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Speech.dll

    .

  2. I have confirmed that the versions Microsoft.Speech.dll

    and language pack are the same.

    enter image description here

  3. This code works for the default voices I have already installed.

  4. In desperation, I even tried to call System.Speech.Internal.Synthesis.VoiceSynthesis.GetVoice()

    directly through reflection, but the same exact error.

I really appreciate any help you can provide! Thank.

+1


source to share


3 answers


ha ha I feel special: this post in Python actually solved my problem: you need to build a config platform x64 , not Any CPU

!



+1


source


Another solution is to set the (x64) bits of the Microsoft Speech Platform SDK and Microsoft Server Speech Platform Runtime version. I think you have set (x86) bits of both and plataform will try to read it in (x64) bits.



I had the same problem as you, but the other way around and it works for me!

0


source


In my case, Instead of the System.Speech.Synthesis library, I need to use Microsoft.Speech.Synthesis. To do this, we need to go to Solution Explorer to VisualStudio -> Links and Browse for Microsoft.Speech.dll

using Microsoft.Speech.Synthesis;

      

You will then have other runtime languages ​​available.

        SpeechSynthesizer synth = new SpeechSynthesizer();    

        // Output information about all of the installed voices. 
        foreach (InstalledVoice voice in synth.GetInstalledVoices())
        {
            VoiceInfo info = voice.VoiceInfo;

            Console.WriteLine(" Name:          " + info.Name);
            Console.WriteLine(" Culture:       " + info.Culture);
            Console.WriteLine(" Age:           " + info.Age);
            Console.WriteLine(" Gender:        " + info.Gender);
            Console.WriteLine(" Description:   " + info.Description);
            Console.WriteLine(" ID:            " + info.Id);
        }

      

0


source







All Articles