c# - 向 SpeechSynthesizer 添加新语言

标签 c# .net speech-synthesis

所以我正在尝试向 SpeechSynthesizer 添加一种新语言,特别是挪威语,但它似乎没有安装。

发现这个: Add another voice into .NET Speech (但这里的问题是不支持捷克语)

我已经从这里安装了挪威语包: http://www.microsoft.com/en-us/download/details.aspx?id=27224

在我的代码中,我使用它来检查它是否已安装:

     foreach (var voice in speaker.GetInstalledVoices())
        {
            Console.WriteLine(voice.VoiceInfo.Description);
        }

但它只输出: Microsoft Zira Desktop - 英语(美国)

已检查文本转语音工具,这也是唯一的选择。 还尝试注销/登录并重新启动计算机。

有人知道如何解决这个问题吗?

最佳答案

您可能需要向 Windows 10 添加语音语言并设置区域设置、国家/地区、Windows 显示语言和语音语言,以便它们都与 Cortana 支持的区域设置配置之一保持一致。

确认设置是否正确:

  1. 打开设置。选择时间和语言,然后选择区域和语言。

  2. 检查 Windows 显示语言的语言(设置为默认)设置。如果您想要的语言不可用,请添加您想要的语言:

    • 点击添加语言。
    • 从列表中选择您想要的语言。
    • 选择所需的区域设置,即语言/国家组合。
    • 点击新选择的语言环境并选择选项。
    • 在“下载语言包”下,单击“下载”。
    • 在“语音”下,点击“下载”。
    • 下载完成后(这可能需要几分钟),返回“时间和语言”设置。
    • 点击您的新语言并选择设置为默认语言。
    • 注意:如果您更改了语言,则必须退出帐户并重新登录才能使新设置生效。
  3. 检查国家或地区设置。确保所选国家/地区与语言设置中设置的 Windows 显示语言一致。

  4. 返回“设置”和“时间和语言”,然后选择“语音”。检查语音语言设置,并确保它与之前的设置一致。

正确完成上述操作后,您的语言应该出现在 SpeechSynthesizer.AllVoices 集合中。然后,您应该能够将此声音分配给您的 SpeechSynthesizer 实例的 Voice 属性:

    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

关于c# - 向 SpeechSynthesizer 添加新语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29163994/

相关文章:

c# - C#中如何替换两个字符之间的文本

c# - 如何使用 System.Speech

javascript - 带有较长文本的 Chrome 语音合成

c# - 使用 XML 文件绑定(bind)下拉列表

c# - 何时在 C# 中使用 'continue' 关键字

c# - 从 C# 中的 excel 中读取列索引和列值

c# - StartsWith Windows Server 2012 中的更改

javascript - speechSynthesis API 示例给出错误

c# - 当我在 DataGridTemplateColumn.CellTemplate 中使用 TextBox 时,DataGrid.BeginningEdit 事件未触发

c# - 使用扩展方法替换字符串