Voice Recognition grammar problem
I have already posted in the forum, I just figure out there is this section, sorry for repost.
I'm trying to implement Voice Recognition inside Unity. I had tried the Keyboard emulation solution made by ZJP, and is very a nice application, but my idea was using the windows System.Speech.dll to call the speech recognition from inside the project.
So I copied System.Speech.dll inside the asset folder and I wrote down the simple code below, follow the MSDN sample
However there is some problem with this Grammar g = new Grammar (gb);
Error :
MissingMethodException: Method not found: 'System.Reflection.MethodInfo.op_Inequality'. System.Speech.Recognition.Grammar.LoadAndCompileCfgData (Boolean isImportedGrammar, Boolean stgInit) System.Speech.Recognition.Grammar.InitialGrammarLoad (System.String ruleName, System.Object[] parameters, Boolean isImportedGrammar) System.Speech.Recognition.Grammar..ctor (System.Speech.Recognition.GrammarBuilder builder) TTSUnityWin.Start () (at Assets/TTSUnityWin.cs:52)
using UnityEngine;
using System.Collections;
using SpeechLib;
using System.Xml;
using System.IO;
using System.Speech.Recognition;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System ;
using System.Speech.AudioFormat;
using System.Speech.Recognition.SrgsGrammar;
using System.Speech.Synthesis; //need later
using System.Speech.Synthesis.TtsEngine;
public class TTSUnityWin : MonoBehaviour {
void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
print ("something");
}
void Start(){
SpeechRecognizer sr = new SpeechRecognizer ();
sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
Choices colori = new Choices();
colori.Add (new string[] {"red","green","blue"});
GrammarBuilder gb = new GrammarBuilder ();
//gb.Culture = new CultureInfo("en-US");
//gb.Culture = new System.Globalization.CultureInfo (1033);
gb.Append (colori);
Grammar g = new Grammar (gb);
//sr.RequestRecognizerUpdate();
sr.LoadGrammar(g);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
//DO NOTHING :)
}
}
}
Your answer