gpt4 book ai didi

c# - SpeechRecognitionEngine.InstalledRecognizers 返回未安装识别器

转载 作者:太空狗 更新时间:2023-10-29 23:23:33 25 4
gpt4 key购买 nike

我正在尝试启动一个简单的语音识别程序,但它不起作用,我已经安装了一些语言(en-GB 和 en-US),但每当我使用以下内容时:

SpeechRecognitionEngine.InstalledRecognizers

它返回一个空集合。即使我只是尝试启动识别器,它也会返回“未安装识别器”。但是当我重新安装一种语言时,它说它已经安装了。

using ( SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
{
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());

// Add a handler for the speech recognized event.
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();

// Start asynchronous, continuous speech recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple);

// Keep the console window open.
while (true)
{
Console.ReadLine();
}
}

找不到安装的识别器是什么原因?

编辑:

这是异常:{System.ArgumentException:找不到所需 ID 的识别器。参数名称:文化 在 System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo 文化)

并且:var recognitions = SpeechRecognitionEngine.InstalledRecognizers(); 返回一个计数为 0 的集合

最佳答案

问题是我安装了可以通过 Microsoft.Speech 访问的语言包,并且当我切换到 Microsoft 时我正在使用 System.Speech。语音它起作用了。

关于c# - SpeechRecognitionEngine.InstalledRecognizers 返回未安装识别器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16856798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com