KinectSDKの例をモデルにしています
private static RecognizerInfo GetKinectRecognizer()
{
foreach (RecognizerInfo recognizer in SpeechRecognitionEngine.InstalledRecognizers())
{
string value;
recognizer.AdditionalInfo.TryGetValue("Kinect", out value);
if ("True".Equals(value, StringComparison.OrdinalIgnoreCase) && "en-US".Equals(recognizer.Culture.Name, StringComparison.OrdinalIgnoreCase))
{
return recognizer;
}
}
return null;
}
ウィンドウロード時
RecognizerInfo ri = GetKinectRecognizer();
if (null != ri)
{
this.speechEngine = new SpeechRecognitionEngine(ri.Id);
var directions = new Choices();
directions.Add(new SemanticResultValue("forward", "FORWARD"));
directions.Add(new SemanticResultValue("backward", "BACKWARD"));
directions.Add(new SemanticResultValue("turn left", "LEFT"));
directions.Add(new SemanticResultValue("turn right", "RIGHT"));
var gb = new GrammarBuilder { Culture = ri.Culture };
gb.Append(directions);
var g = new Grammar(gb);
speechEngine.SpeechRecognized += SpeechRecognized;
speechEngine.SpeechRecognitionRejected += SpeechRejected;
speechEngine.SetInputToAudioStream(
kinect.AudioSource.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
speechEngine.RecognizeAsync(RecognizeMode.Multiple);
}
エラー:
タイプ'System.InvalidOperationException'の未処理の例外がMicrosoft.Speech.dllで発生しました
追加情報:認識を行う前に、少なくとも1つの文法をロードする必要があります。
私にできることは何ですか?