我想知道是否有办法将Windows语音识别库限制为只包含几个单词的小型库?
我尝试用几个单词制作一个语音操作程序,但是当我添加了计算机很难识别的单词(就像名字一样)时,它将该名称识别为另一个单词。这就是为什么我想添加一个像名单一样的特定字典。
Eks:Sondre,Robert,Bob
当说出一个名字时,程序只会检查3个单词中的一个是否被识别
答案 0 :(得分:6)
我将以下代码用于我之前使用Kinect相机完成的项目。 我限制了短语{更快,更慢,停止..}并建立了一个语法。我希望它会回答你的问题
private void initSpeech()
{
// You need to change here if you are not using kinect camera
RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == "SR_MS_en-US_Kinect_10.0").FirstOrDefault();
if (ri == null)
{
throw new ApplicationException("Could not locate speech recognizer. Ensure you have the Kinect Speech SDK/runtime/MSKinectLangPack_enUS installed.");
}
sr = new SpeechRecognitionEngine(ri.Id);
//Phrases that will be recognised added
Choices phrases = new Choices();
phrases.Add(
"faster",
"slower",
"stop",
"invert y",
"music volume",
"effects volume",
"okay");
GrammarBuilder gb = new GrammarBuilder();
//adding our phrases to the grammar builder
gb.Append(phrases);
// Loading the grammer
sr.LoadGrammar(new Grammar(gb));
}