语音识别引擎返回从错误语音中找到的语法

Speech Recognition Engine returning grammar found from wrong speech

我正在尝试在 VisualStudio Express 中将 .NET SpeechRecognitionEngine 与 C# 结合使用。但是我发现它会选择完全错误的单词/句子并假设它们在语法中。

EG 如果我将 "test 1" 加载到语法中并说 "filthy beast" 甚至不接近单词 "test 1",EventHandler SpeechRecognized 就会触发。我在编码时让一部电影在 netflix 上播放,它正在将识别的事件触发到电影中的音乐和谈话中,所以它还有很长的路要走。

有没有办法阻止它假定口语单词在语法中?或者有什么办法可以阻止这个?

有什么建议吗?

这是我说 "filthy beast" 的日志输出,而语法只加载了 "test 1"。

speechDetectedHandler():
speechHypothesizedHandler():  confidence = 0.002903746    e.Result.Text = Test
speechHypothesizedHandler():  confidence = 0.8096436    e.Result.Text = Test
speechRecognizedHandler():  confidence = 0.7723699    e.Result.Text = Test 1

代码:

public SpeechRecognitionEngine sre;

String culture = "en-US";
foreach (RecognizerInfo config in SpeechRecognitionEngine.InstalledRecognizers())
{
    if (config.Culture.ToString() == culture)
    {
      s = new SpeechRecognitionEngine(config);
      break;
    }
}
s.SetInputToDefaultAudioDevice();

sre.MaxAlternates = 0;

sre.AudioLevelUpdated += new EventHandler<AudioLevelUpdatedEventArgs>(audioLevelHandler);
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechRecognizedHandler);

sre.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(speechHypothesizedHandler);
sre.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(speechDetectedHandler);


gb = new GrammarBuilder(speechCommands);
g = new Grammar(gb);

sre.UnloadAllGrammars();
sre.LoadGrammar(g);
startListening();

您可以使用 Wildcard 语法元素来接受其他单词,而无需强制使用语法中的元素。您可以将通配符与您的命令一起添加到选项中。

如果您想在存在其他语音的情况下识别命令,此解决方案可能不容易调整。寻找像 "ok google" 这样的关键词的专门关键词发现解决方案可能更有意义。 Microsoft 语音引擎没有 API,但有外部库。

解决方案是创建并加载与您要使用的单词/语法/语音相似的语法,这将提高准确性。然后评估假设的触发器 1、触发器 2,然后识别置信度和结果文本。不太实用,因为这对每个人/用户来说都是不同的。

无法阻止 .NET 语音识别引擎始终返回语法匹配。您不妨在安静的房间里对着录音室级麦克风说 "bob",它会识别 "open windows media player"。哈哈

警告 1:超过 1,000 个语法单词列表会降低速度并可能锁定应用程序。

警告 2:en-US 具有良好的英文识别能力,切换到 en-GB 等会大大降低准确性

到目前为止,Google 的语音识别 API(确实需要您在线),但它的准确度提高了 10 倍,您可以轻松地自己测试匹配。