Beispiel #1
0
 private string GetRecognizedPhraseDisplayText(RecognizedSpeechAlternate alternate)
 {
     return
         (alternate.Text +
          " [" +
          (100 * alternate.Confidence).ToString("0.00") +
          "%]\r\n");
 }
Beispiel #2
0
        private RecognizedSpeech GenerateRecognizedSpeechObject(System.Collections.ObjectModel.ReadOnlyCollection <RecognizedPhrase> engineAlternates)
        {
            RecognizedSpeechAlternate[] alternates;
            RecognizedPhrase            phrase;
            RecognizedSpeech            recognizedSpeech;

            alternates = new RecognizedSpeechAlternate[engineAlternates.Count];
            for (int i = 0; i < engineAlternates.Count; ++i)
            {
                phrase        = engineAlternates[i];
                alternates[i] = new RecognizedSpeechAlternate(phrase.Text, phrase.Confidence);
            }
            recognizedSpeech = new RecognizedSpeech(alternates);
            return(recognizedSpeech);
        }
Beispiel #3
0
        private void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
        {
            ////result_textBox.AppendText(Result.PhraseInfo.GetText(0, -1, true) + "\n");
            //string result;

            //ISpeechPhraseInfo info;
            //ISpeechPhraseAlternate alternate;
            //ISpeechPhraseAlternates alternates = Result.Alternates(20, 0, -1);
            //ISpeechPhraseReplacements replacements;

            //if (alternates != null)
            //    alternate = alternates.Item(0);
            //info = Result.PhraseInfo;
            //replacements = info.Replacements;
            //string rep;
            //if (replacements != null)
            //    rep = replacements.Item(0).Text;

            //result = Result.PhraseInfo.GetText(0, -1, true);
            //if (result.Length < 1) result = "???";
            //OnSpeechRecognized(null);

            ////result_textBox.AppendText(Result.PhraseInfo.GetText(0, -1, true) + "\n");
            //string result;

            string result;
            float  confidence;

            RecognizedSpeechAlternate[] alternates;
            RecognizedSpeech            recognizedSpeech;

            result     = Result.PhraseInfo.GetText(0, -1, true);
            confidence = Result.PhraseInfo.Rule.EngineConfidence;
            //confidence = Result.PhraseInfo.Rule.Confidence;
            if (result.Length < 1)
            {
                return;
            }

            alternates       = new RecognizedSpeechAlternate[1];
            alternates[0]    = new RecognizedSpeechAlternate(result, confidence);
            recognizedSpeech = new RecognizedSpeech(alternates);

            OnSpeechRecognized(recognizedSpeech);
        }
Beispiel #4
0
        private void SpeechRecognizer_Hypothesis(int StreamNumber, object StreamPosition, ISpeechRecoResult Result)
        {
            string result;
            float  confidence;

            RecognizedSpeechAlternate[] alternates;
            RecognizedSpeech            recognizedSpeech;

            result     = Result.PhraseInfo.GetText(0, -1, true);
            confidence = Result.PhraseInfo.Rule.EngineConfidence;
            if (result.Length < 1)
            {
                return;
            }

            alternates       = new RecognizedSpeechAlternate[1];
            alternates[0]    = new RecognizedSpeechAlternate(result, confidence);
            recognizedSpeech = new RecognizedSpeech(alternates);

            OnSpeechHypothesized(recognizedSpeech);
        }
        private RecognizedSpeech GenerateRecognizedSpeechObject(System.Collections.ObjectModel.ReadOnlyCollection<RecognizedPhrase> engineAlternates)
        {
            RecognizedSpeechAlternate[] alternates;
            RecognizedPhrase phrase;
            RecognizedSpeech recognizedSpeech;

            alternates = new RecognizedSpeechAlternate[engineAlternates.Count];
            for (int i = 0; i < engineAlternates.Count; ++i)
            {
                phrase = engineAlternates[i];
                alternates[i] = new RecognizedSpeechAlternate(phrase.Text, phrase.Confidence);
            }
            recognizedSpeech = new RecognizedSpeech(alternates);
            return recognizedSpeech;
        }
        private void SpeechRecognizer_Hypothesis(int StreamNumber, object StreamPosition, ISpeechRecoResult Result)
        {
            string result;
            float confidence;
            RecognizedSpeechAlternate[] alternates;
            RecognizedSpeech recognizedSpeech;

            result = Result.PhraseInfo.GetText(0, -1, true);
            confidence = Result.PhraseInfo.Rule.EngineConfidence;
            if (result.Length < 1)
                return;

            alternates = new RecognizedSpeechAlternate[1];
            alternates[0] = new RecognizedSpeechAlternate(result, confidence);
            recognizedSpeech = new RecognizedSpeech(alternates);

            OnSpeechHypothesized(recognizedSpeech);
        }
        private void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
        {
            ////result_textBox.AppendText(Result.PhraseInfo.GetText(0, -1, true) + "\n");
            //string result;

            //ISpeechPhraseInfo info;
            //ISpeechPhraseAlternate alternate;
            //ISpeechPhraseAlternates alternates = Result.Alternates(20, 0, -1);
            //ISpeechPhraseReplacements replacements;

            //if (alternates != null)
            //    alternate = alternates.Item(0);
            //info = Result.PhraseInfo;
            //replacements = info.Replacements;
            //string rep;
            //if (replacements != null)
            //    rep = replacements.Item(0).Text;

            //result = Result.PhraseInfo.GetText(0, -1, true);
            //if (result.Length < 1) result = "???";
            //OnSpeechRecognized(null);

            ////result_textBox.AppendText(Result.PhraseInfo.GetText(0, -1, true) + "\n");
            //string result;

            string result;
            float confidence;
            RecognizedSpeechAlternate[] alternates;
            RecognizedSpeech recognizedSpeech;

            result = Result.PhraseInfo.GetText(0, -1, true);
            confidence = Result.PhraseInfo.Rule.EngineConfidence;
            //confidence = Result.PhraseInfo.Rule.Confidence;
            if (result.Length < 1)
                return;

            alternates = new RecognizedSpeechAlternate[1];
            alternates[0] = new RecognizedSpeechAlternate(result, confidence);
            recognizedSpeech = new RecognizedSpeech(alternates);

            OnSpeechRecognized(recognizedSpeech);
        }