public void CancelWhileRecognize()
        {
            var clientConfig = this.CreateClientConfigDefault(this.CreateConfigDefault());
            //Send all buffer to be writter
            var audioSource = new BufferAudioSource(File.ReadAllBytes(@"8k\ContinuosMode\joao_mineiro_marciano_intro_8k.wav"));

            SpeechRecognizer speechRecognizer = SpeechRecognizer.Create(clientConfig);

            try
            {
                var lModelLst = new LanguageModelList();
                lModelLst.AddFromUri("builtin:slm/general");

                speechRecognizer.Recognize(audioSource, lModelLst);

                Thread.Sleep(2000);

                speechRecognizer.CancelRecognition();

                var result = speechRecognizer.WaitRecognitionResult();
                Assert.IsTrue(result.Count == 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                speechRecognizer.Close();
            }
        }
예제 #2
0
        public void CancelNoRecognize()
        {
            var clientConfig = CreateClientWithCredentials(CreateConfigDefault(), TestsReferences.DefaultASRURL, TestsReferences.User, TestsReferences.Password);

            using (SpeechRecognizer speechRecognizer = SpeechRecognizer.Create(clientConfig))
            {
                speechRecognizer.CancelRecognition();
            }
        }
        public void CancelNoRecognize()
        {
            var clientConfig = this.CreateClientConfigDefault(this.CreateConfigDefault());

            SpeechRecognizer speechRecognizer = SpeechRecognizer.Create(clientConfig);

            try
            {
                speechRecognizer.CancelRecognition();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                speechRecognizer.Close();
            }
        }
예제 #4
0
        public void CancelWhileRecognize()
        {
            var clientConfig = CreateClientWithCredentials(CreateConfigDefault(), TestsReferences.DefaultASRURL, TestsReferences.User, TestsReferences.Password);
            var lModelLst    = new LanguageModelList();
            var audioSource  = new BufferAudioSource(File.ReadAllBytes(TestsReferences.AudioCpf));
            List <RecognitionResult> results = null;

            using (SpeechRecognizer speechRecognizer = SpeechRecognizer.Create(clientConfig))
            {
                lModelLst.AddFromUri(TestsReferences.FreeLanguageModel);
                speechRecognizer.Recognize(audioSource, lModelLst);

                Thread.Sleep(1000);

                speechRecognizer.CancelRecognition();
                results = speechRecognizer.WaitRecognitionResult();
            }

            Assert.AreEqual(0, results.Count);
        }