我有一个 C# 应用程序,我使用 Kinect 传感器进行语音识别。
可以在其中设置文化吗?
我认为问题出在 GetKinectRecognizer() 方法中,因为在此方法中我设置了语音识别的属性。
现在我有这个方法
//riconoscimento vocale
private SpeechRecognitionEngine RiconoscimentoVocale()
{
RecognizerInfo ri = GetKinectRecognizer();
SpeechRecognitionEngine sre;
try
{
sre = new SpeechRecognitionEngine(ri.Id);
}
catch
{
this.Close();
return null;
}
//vengono aggiunte la parole grammaticali da riconoscere
var grammar = new Choices();
grammar.Add("rosso");
grammar.Add("aiuto");
grammar.Add("caduto");
//creo il vocabolario delle parole
var vocabolario = new GrammarBuilder { Culture = ri.Culture };
vocabolario.Append(grammar);
// Create the actual Grammar instance, and then load it into the speech recognizer.
var g = new Grammar(vocabolario);
//carico la grammatica
sre.LoadGrammar(g);
//aggiungo l'evento per il riconoscimento delle parole
sre.SpeechRecognized += this.RiconoscimentoParole;
return sre;
}
private static RecognizerInfo GetKinectRecognizer()
{
//Console.WriteLine("recognizer info ");
Func<RecognizerInfo, bool> matchingFunc = r =>
{
Console.WriteLine("recognizer info " + r.Culture.Name);
string value;
r.AdditionalInfo.TryGetValue("Kinect", out value);
return "True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "en-US".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase);
};
return SpeechRecognitionEngine.InstalledRecognizers().Where(matchingFunc).FirstOrDefault();
}
我们能帮帮我吗?