Ejemplo n.º 1
0
 public void Init(IEnumerable <int> input, IEnumerable <int> expected, string inputText)
 {
     Stack.Clear();
     Registers.Clear();
     for (int i = 0; i < 4; i++)
     {
         Registers.Add(0);
     }
     Input.Clear();
     Expected.Clear();
     Output.Clear();
     foreach (int i in input)
     {
         Input.Add(i);
     }
     foreach (int i in expected)
     {
         Expected.Add(i);
     }
     Status = Status.Running;
     Build(inputText);
 }
Ejemplo n.º 2
0
 private void Initialize()
 {
     Expected.Clear();
     Missing.Clear();
     Additional.Clear();
 }
Ejemplo n.º 3
0
        // THESE MAKE ABSOLUTELY NO DIFFERENCE WHATSOEVER TO AUDIOFILE INPUT ->
        // apparently.
        // CFGConfidenceRejectionThreshold
        // HighConfidenceThreshold
        // NormalConfidenceThreshold
        // LowConfidenceThreshold

//			int val = 0;
//			_recognizer.GetPropertyNumber("CFGConfidenceRejectionThreshold", ref val);	// default 60-
//			logfile.Log(". CFGConfidenceRejectionThreshold= " + val);
//			_recognizer.GetPropertyNumber("HighConfidenceThreshold", ref val);			// default 80+
//			logfile.Log(". HighConfidenceThreshold= " + val);
//			_recognizer.GetPropertyNumber("NormalConfidenceThreshold", ref val);		// default 50+
//			logfile.Log(". NormalConfidenceThreshold= " + val);
//			_recognizer.GetPropertyNumber("LowConfidenceThreshold", ref val);			// default 20+
//			logfile.Log(". LowConfidenceThreshold= " + val);
//			logfile.Log();
//
//			_recognizer.SetPropertyNumber("CFGConfidenceRejectionThreshold", 0); // tried 100 ... results are identical to 0.
//			_recognizer.GetPropertyNumber("CFGConfidenceRejectionThreshold", ref val);
//			logfile.Log(". CFGConfidenceRejectionThreshold= " + val);
//
//			_recognizer.SetPropertyNumber("HighConfidenceThreshold", 0);
//			_recognizer.GetPropertyNumber("HighConfidenceThreshold", ref val);
//			logfile.Log(". HighConfidenceThreshold= " + val);
//
//			_recognizer.SetPropertyNumber("NormalConfidenceThreshold", 0);
//			_recognizer.GetPropertyNumber("NormalConfidenceThreshold", ref val);
//			logfile.Log(". NormalConfidenceThreshold= " + val);
//
//			_recognizer.SetPropertyNumber("LowConfidenceThreshold", 0);
//			_recognizer.GetPropertyNumber("LowConfidenceThreshold", ref val);
//			logfile.Log(". LowConfidenceThreshold= " + val);
//			logfile.Log();


        internal void Start(string text)
        {
#if DEBUG
            logfile.Log();
            logfile.Log("Start()");
#endif
            // these don't all need to be cleared ->
            Expected.Clear();

            RatioWords_def             =
                RatioPhons_def         =
                    RatioWords_enh     =
                        RatioPhons_enh = 0.0;

            _ars_def.Clear();
            _ars_enh.Clear();

            Confidence_def       = 0f;
            Confidence_def_count = 0;


            if (SetRecognizer(FxeGeneratorF.That.GetRecognizer()))             // <- workaround. See FxeGeneratorF.GetRecognizer()
            {
                _text = text;
#if DEBUG
                logfile.Log(". _text= " + _text);
#endif
                if (_text == String.Empty)
                {
#if DEBUG
                    logfile.Log(". . DEFAULT - fire TtsStreamEnded event");
#endif
//					if (TtsStreamEnded != null)
                    TtsStreamEnded();
                }
                else
                {
#if DEBUG
                    logfile.Log(". . ENHANCED - call SpVoice.Speak()");
                    logfile.Log(". . _phoneConverter.LanguageId= " + _phoneConverter.LanguageId);
#endif
                    _voice.Speak(_text);                     // -> fire TtsEndStream when the TTS-stream ends.
                    _voice.WaitUntilDone(-1);
                }

#if DEBUG
                logfile.Log(". create (SpInProcRecoContext)_recoContext");
#endif
                _recoContext = (SpInProcRecoContext)_recognizer.CreateRecoContext();
#if DEBUG
                logfile.Log(". (SpInProcRecoContext)_recoContext CREATED");
#endif
                _recoContext.FalseRecognition += rc_FalseRecognition;
                _recoContext.Recognition      += rc_Recognition;
                _recoContext.EndStream        += rc_EndStream;
#if DEBUG
                _recoContext.Hypothesis   += rc_Hypothesis;
                _recoContext.StartStream  += rc_StartStream;
                _recoContext.SoundStart   += rc_SoundStart;
                _recoContext.SoundEnd     += rc_SoundEnd;
                _recoContext.PhraseStart  += rc_PhraseStart;
                _recoContext.Interference += rc_Interference;
//				_recoContext.AudioLevel       += rc_AudioLevel; // does not fire. SURPRISE!

//				_recoContext.EventInterests = SpeechRecoEvents.SREAllEvents;
                _recoContext.EventInterests = (SpeechRecoEvents)(int)SpeechRecoEvents.SREFalseRecognition
                                              + (int)SpeechRecoEvents.SRERecognition
                                              + (int)SpeechRecoEvents.SREStreamEnd
                                              + (int)SpeechRecoEvents.SREHypothesis
                                              + (int)SpeechRecoEvents.SREStreamStart
                                              + (int)SpeechRecoEvents.SRESoundStart
                                              + (int)SpeechRecoEvents.SRESoundEnd
                                              + (int)SpeechRecoEvents.SREPhraseStart
                                              + (int)SpeechRecoEvents.SREInterference;
//															  + (int)SpeechRecoEvents.SREAudioLevel; // does not fire. SURPRISE!
                logfile.Log(". _recoContext.EventInterests= " + _recoContext.EventInterests);
#else
                _recoContext.EventInterests = (SpeechRecoEvents)(int)SpeechRecoEvents.SREFalseRecognition
                                              + (int)SpeechRecoEvents.SRERecognition
                                              + (int)SpeechRecoEvents.SREStreamEnd;
#endif

/*				https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee125206%28v%3dvs.85%29
 *                              enum SpeechRecoEvents
 *                              SREStreamEnd            = 1
 *                              SRESoundStart           = 2
 *                              SRESoundEnd             = 4
 *                              SREPhraseStart          = 8
 *                              SRERecognition          = 16
 *                              SREHypothesis           = 32
 *                              SREBookmark             = 64
 *                              SREPropertyNumChange    = 128
 *                              SREPropertyStringChange = 256
 *                              SREFalseRecognition     = 512
 *                              SREInterference         = 1024
 *                              SRERequestUI            = 2048
 *                              SREStateChange          = 4096
 *                              SREAdaptation           = 8192
 *                              SREStreamStart          = 16384
 *                              SRERecoOtherContext     = 32768
 *                              SREAudioLevel           = 65536
 *                              SREPrivate              = 262144
 *                              SREAllEvents            = 393215
 */
                _generato = Generator.Dictati;
                Generate();
#if DEBUG
                logfile.Log("Start() DONE");
                logfile.Log();
#endif
            }
        }