如何在日语中使用语音合成器?

时间:2016-03-21 03:30:38

标签: c# winforms text-to-speech

我想在C#中创建一个小型的文字转语音应用。我使用英语语音合成器,它工作得很好。但是,当我通过日语判决时,它没有奏效。我没有收到任何错误消息。我需要安装其他东西吗?

我在Win 7 32位和Win 10 64位上进行了测试。

1 个答案:

答案 0 :(得分:1)

尝试设置应用程序的CultureInfo。

var ci = new System.Globalization.CultureInfo("ja-JP");
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

您可以设置英语或日语,查看CurrentCultureInfo。

if (currentUICulture == "ja-JP")
{
    string colorsString = colors.Aggregate((first, Next) => (first += ";" + Next));
    string transColor = speak.Translate(colorsString, "en", "ja");
    string[] jaColors = transColor.Split(new char[]{';','、'});
    for (int i = 0; i < jaColors.Length; i++)
    {
        //
    }
    commands = new string[]{ "なし", "クリア", "イコール",
        "プラス", "マイナス", "掛ける", "分割", "追加" };
}

Choices commandsChoices = new Choices(commands);
GrammarBuilder gb = new GrammarBuilder(commandsChoices);
sr.LoadGrammar(new Grammar(gb));

Choices colorChoices = new Choices(colors);
gb = new GrammarBuilder(colorChoices);
sr.LoadGrammar(new Grammar(gb));

sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
sr.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(sr_SpeechDetected);
sr.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sr_SpeechRecognitionRejected);

我希望这可以帮到你

安东尼奥