Adding a new Language to SpeechSynthesizer

家住魔仙堡 提交于 2019-11-29 11:14:06

You may need to add a Speech Language to Windows 10 and set your Locale, Country, Windows display language and Speech language so they are all aligned with one of Cortana's supported locale configurations.

To confirm the settings are set correctly:

  1. Open Settings. Select Time& language, and then Region & Language.

  2. Check the Language (set as default) setting for your Windows display language. If your desired language is not available, add your desired language:

    • Click Add Language.
    • Select your desired language from the list.
    • Select the desired locale, which is the language/country combination.
    • Click on the newly selected locale and select Options.
    • Under Download language pack, click Download.
    • Under Speech, click Download.
    • After the downloads are complete (this could take several minutes), return to the Time & Language settings.
    • Click on your new language and select Set as Default.
    • NOTE: IF you changed languages, you must sign out of your account and back in for the new setting to take effect.
  3. Check the Country or region setting. Make sure the country selected corresponds with the Windows display language set in the Language setting.

  4. Return to Settings and Time & language, and then select Speech. Check the Speech language setting, and make sure it’s aligned with the previous settings.

After you have correctly done the above, your language should appear in the SpeechSynthesizer.AllVoices collection. You should then be able to assign this voice to your SpeechSynthesizer instance's Voice property:

    private async void SpeakText(MediaElement audioPlayer, string TTS)
    {
        SpeechSynthesizer ttssynthesizer = new SpeechSynthesizer();

        //Set the Voice/Speaker to Spanish
        using (var speaker = new SpeechSynthesizer())
        {
            speaker.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Female && x.Language.Contains("ES")) );
            ttssynthesizer.Voice = speaker.Voice;
        }

        SpeechSynthesisStream ttsStream = await ttssynthesizer.SynthesizeTextToStreamAsync(TTS);

        audioPlayer.SetSource(ttsStream, "");
    }

http://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/speech-language-in-windows-10-home/3f04bc02-9953-40b1-951c-c1d262fc3f63?auth=1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!