private void Initialize(RecognizerInfo recognizerInfo)
 {
     try
     {
         _sapiRecognizer = new SapiRecognizer(SapiRecognizer.RecognizerType.InProc);
     }
     catch (COMException e)
     {
         throw RecognizerBase.ExceptionFromSapiCreateRecognizerError(e);
     }
     if (recognizerInfo != null)
     {
         ObjectToken objectToken = recognizerInfo.GetObjectToken();
         if (objectToken == null)
         {
             throw new ArgumentException(SR.Get(SRID.NullParamIllegal), "recognizerInfo");
         }
         try
         {
             _sapiRecognizer.SetRecognizer(objectToken.SAPIToken);
         }
         catch (COMException e2)
         {
             throw new ArgumentException(SR.Get(SRID.RecognizerNotFound), RecognizerBase.ExceptionFromSapiCreateRecognizerError(e2));
         }
     }
     _sapiRecognizer.SetRecoState(SPRECOSTATE.SPRST_INACTIVE);
 }
        private void Initialize(RecognizerInfo recognizerInfo)
        {
            try
            {
                _sapiRecognizer = new SapiRecognizer(SapiRecognizer.RecognizerType.InProc);
            }
            catch (COMException e)
            {
                throw RecognizerBase.ExceptionFromSapiCreateRecognizerError(e);
            }

            if (recognizerInfo != null)
            {
                ObjectToken token = recognizerInfo.GetObjectToken();
                if (token == null)
                {
                    throw new ArgumentException(SR.Get(SRID.NullParamIllegal), nameof(recognizerInfo));
                }
                try
                {
                    _sapiRecognizer.SetRecognizer(token.SAPIToken);
                }
                catch (COMException e)
                {
                    throw new ArgumentException(SR.Get(SRID.RecognizerNotFound), RecognizerBase.ExceptionFromSapiCreateRecognizerError(e));
                }
            }

            // For the SpeechRecognitionEngine we don't want recognition to start until the Recognize() or RecognizeAsync() methods are called.
            _sapiRecognizer.SetRecoState(SPRECOSTATE.SPRST_INACTIVE);
        }