日期:2014-05-17 浏览次数:20816 次
public class SpRecognition
{
private static SpRecognition _Instance = null;
private SpeechLib.ISpeechRecoGrammar isrg;
private SpeechLib.SpSharedRecoContextClass ssrContex = null;
private System.Windows.Forms.Control cDisplay; //fan:用来显示语音转化后的文本
public System.Windows.Forms.TextBox textbox; //fan:增加textbox在SpRecognition 类
public SpRecognition()
{
ssrContex = new SpSharedRecoContextClass();
isrg = ssrContex.CreateGrammar(1);
SpeechLib._ISpeechRecoContextEvents_RecognitionEventHandler recHandle =
new _ISpeechRecoContextEvents_RecognitionEventHandler(ContexRecognition);
ssrContex.Recognition += recHandle;
}
public void BeginRec(Control tbResult)
{
isrg.DictationSetState(SpeechRuleState.SGDSActive);
cDisplay = tbResult;
//cDisplay.Text = "dddddddddd"; 测试,可以成功在textbox1那里显示出来
}
public static SpRecognition instance()
{
if (_Instance == null)