我在C#中有一个应用程序,我使用Kinect传感器进行语音识别。
可以在其中设置文化 - IT ??
我认为问题出在方法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();
}
我们可以帮助我吗?
答案 0 :(得分:1)
我假设您已经安装了Italian language pack,因为这是先决条件。然后,在GetKinectRecognizer方法中,您需要更改
return "True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "en-US".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase);
到
return "True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "it-IT".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase);
另外,你的函数看起来与this question中的代码非常相似,它有自己的问题,所以你可能还没有走出困境。
但总体大纲就在那里 - 您需要返回意大利语识别器的ID(必须安装)。