【问题标题】:Error "No recognizer is installed" with recognition speech [duplicate]带有识别语音的错误“未安装识别器”[重复]
【发布时间】:2014-12-24 13:19:22
【问题描述】:

我尝试在 C# 中识别语音,但开始很糟糕。我在 YouTube 上遵循了一些教程,但每次都会出现这个错误。所以我得到了微软的 MSDN 代码,并试图在谷歌中找到一些解决方案。这是我正在使用的代码:

public Form1()
    {
        InitializeComponent();
        Initialize();
    }

    private void Initialize()
    {

        // Create a new SpeechRecognitionEngine instance.
        SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
        // Configure the input to the recognizer.
        //sre.SetInputToWaveFile(@"c:\Test\Colors.wav");
        sre.SetInputToDefaultAudioDevice();

        // Create a simple grammar that recognizes "red", "green", or "blue".
        Choices colors = new Choices();
        colors.Add(new string[] { "red", "green", "blue" });

        // Create a GrammarBuilder object and append the Choices object.
        GrammarBuilder gb = new GrammarBuilder();
        gb.Append(colors);

        // Create the Grammar instance and load it into the speech recognition engine.
        Grammar g = new Grammar(gb);
        sre.LoadGrammar(g);

        // Register a handler for the SpeechRecognized event.
        sre.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);

        // Start recognition.
        sre.Recognize();
    }

    // Create a simple handler for the SpeechRecognized event.
    void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
        MessageBox.Show("Speech recognized: " + e.Result.Text);
    }

我已经下载了Microsoft Speech Platform SDKRuntime Languages(美国)。错误仍然存​​在。

我也已经使用过这段代码,正如我在 StackOverflow 的一个主题中看到的那样:

 sre = new SpeechRecognitionEngine(new CultureInfo("en-GB"));

它不起作用,所以我尝试使用它(正如我在 MSDN 中看到的那样):

 SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));

当我尝试使用这些代码时,错误发生了变化并说:“找不到所需 ID 的识别器”。 我使用 Windows 7 (Home Basic, x64), Microsoft Visual C# 2010 Express。我的默认语言(系统语言也是)是葡萄牙语(巴西),也许是错误原因? 好了,就是这样,希望我写的都详细,让你明白。对不起我的英语我正在训练这个,哈哈:P

【问题讨论】:

  • @Saruman 我已切换,错误更改为“未找到所需 ID 的识别器”。在 CultureInfo 中(当我创建 sre 时)。我试图下载 pt-BR 文件,但它也发生了。如果我不理会它,错误会更改为“此系统上无法使用语音识别。找不到 SAPI 和语音识别引擎。”

标签: c# .net speech-recognition


【解决方案1】:

运行以下命令来确定您安装了哪些识别器、断点/调试并检查是否需要

foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
    System.Diagnostics.Debug.WriteLine(ri.Culture.Name);
}

并使用SpeechRecognitionEngine 构造函数中列出的文化之一

【讨论】:

  • 嗯,它没有响应单一的文化。如何进行?
猜你喜欢
  • 1970-01-01
  • 2020-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多