Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 演讲质量非常差,尤其是与Word相比_C#_Wpf_Speech Recognition - Fatal编程技术网

C# 演讲质量非常差,尤其是与Word相比

C# 演讲质量非常差,尤其是与Word相比,c#,wpf,speech-recognition,C#,Wpf,Speech Recognition,我正在使用WPF语音识别库,试图在桌面应用程序中使用它作为菜单命令的替代品。(我想专注于平板电脑的体验,因为你没有键盘)。它可以工作——有点像,只是识别的准确性太差,无法使用。所以我试着听写单词。这个词很管用。我在这两种情况下都使用了内置的笔记本电脑麦克风,而且两个程序都能够同时听到相同的语音(前提是Word保持键盘焦点),但Word做对了,WPF做得非常糟糕 我试过通用听写语法()和微型专业语法,我也试过“en-US”和“en-AU”,在所有情况下,Word的性能都很好,WPF的性能都很差。即

我正在使用WPF语音识别库,试图在桌面应用程序中使用它作为菜单命令的替代品。(我想专注于平板电脑的体验,因为你没有键盘)。它可以工作——有点像,只是识别的准确性太差,无法使用。所以我试着听写单词。这个词很管用。我在这两种情况下都使用了内置的笔记本电脑麦克风,而且两个程序都能够同时听到相同的语音(前提是Word保持键盘焦点),但Word做对了,WPF做得非常糟糕

我试过通用听写语法()和微型专业语法,我也试过“en-US”和“en-AU”,在所有情况下,Word的性能都很好,WPF的性能都很差。即使将WPF中的专业语法与Word中的一般语法进行比较,WPF也有50%的情况是错误的,例如将“小尺寸”作为“小颜色”

WPF中的相同音频,听写语法:

a lower
make it back
when Ted Brach
making reader
and he
liked the
ethanol and
act out
to be putting
it off the parking
zoom in
and out
我用Nuget获得了装配。我使用的是运行时版本=v4.0.30319和版本=4.0.0.0。如果我要“培训”它,文档中没有解释如何做到这一点,我也不知道培训是否与其他程序(如Word)共享,或者培训保存在哪里。我已经玩了足够长的时间,现在它知道我的声音


有人能告诉我我做错了什么吗?

因为您实际上是在创建语音用户界面,而不仅仅是在进行语音识别,所以您应该检查一下。使用Speechly,创建不需要硬编码命令,而是支持多种方式表达同一事物的自然体验要容易得多。
将其集成到应用程序中也应该非常简单。首页上有一个小的代码笔,可以让你了解基本情况。

我想说的是,你最好不要使用
听写语法,而是使用带有完整短语或键值赋值的特定语法:

private static SpeechRecognitionEngine CreateRecognitionEngine()
{
    var cultureInf = new System.Globalization.CultureInfo("en-US");

    var recoEngine = new SpeechRecognitionEngine(cultureInf);
    recoEngine.SetInputToDefaultAudioDevice();
            
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "weight", new string[] { "normal", "bold", "demibold" }));
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "color", new string[] { "red", "green", "blue" }));
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "size", new string[]{ "small", "medium", "large" }));

    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "", new string[] { "Put whole phrase here", "Put whole phrase here again", "another long phrase" }));

    return recoEngine;
}

static Grammar CreateKeyValuesGrammar(CultureInfo cultureInf, string key, string[] values)
{
    var grBldr = string.IsNullOrWhiteSpace(key) ? new GrammarBuilder() { Culture = cultureInf } : new GrammarBuilder(key) { Culture = cultureInf };
    grBldr.Append(new Choices(values));

    return new Grammar(grBldr);
}

您也可以尝试使用Microsoft.Speech.Recognition
请参见

这是预期的。Word的听写使用基于云的AI/ML辅助语音服务:。它正在不断地进行培训和更新,以获得最佳的准确性。你可以通过离线并尝试Word中的听写功能来轻松测试这一点——它不会起作用

.NET的System.Speech使用脱机模式,据我所知,该模式自Windows 7以来从未更新过。核心技术本身(Windows95时代)比今天的手机或基于云的服务要古老得多。Microsoft.Speech.Recognition也使用类似的核心,不会有太大的改进,尽管您可以尝试一下

如果您想探索其他脱机选项,我建议尝试。据我所知,这项技术与Cortana和其他现代语音识别应用程序在Windows 8及更高版本上使用的技术相同,不使用SAPI5

在网上很容易找到Azure或Windows.Media.SpeechRecognition的示例,使用后者的最佳方法是将应用程序更新到.NET 5并使用它访问UWP API。

Speechly是否有C#库?我可以像使用Microsoft库一样使用它吗?
a lower
make it back
when Ted Brach
making reader
and he
liked the
ethanol and
act out
to be putting
it off the parking
zoom in
and out
private static SpeechRecognitionEngine CreateRecognitionEngine()
{
    var cultureInf = new System.Globalization.CultureInfo("en-US");

    var recoEngine = new SpeechRecognitionEngine(cultureInf);
    recoEngine.SetInputToDefaultAudioDevice();
            
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "weight", new string[] { "normal", "bold", "demibold" }));
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "color", new string[] { "red", "green", "blue" }));
    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "size", new string[]{ "small", "medium", "large" }));

    recoEngine.LoadGrammar(CreateKeyValuesGrammar(cultureInf, "", new string[] { "Put whole phrase here", "Put whole phrase here again", "another long phrase" }));

    return recoEngine;
}

static Grammar CreateKeyValuesGrammar(CultureInfo cultureInf, string key, string[] values)
{
    var grBldr = string.IsNullOrWhiteSpace(key) ? new GrammarBuilder() { Culture = cultureInf } : new GrammarBuilder(key) { Culture = cultureInf };
    grBldr.Append(new Choices(values));

    return new Grammar(grBldr);
}