我如何才能停止该过程,直到在SpeechToText中找到一个单词?

时间:2019-06-10 20:18:07

标签: c# speech-to-text

当我说一个特定的词以便以后继续其他内容时,我需要此功能完成。

我正在使用System.Speech.Recognition库处理c#。 另外,我正在使用西班牙语,并且之前尝试过识别功能,但是它可以通过按键“录音”完成。

public static void waitforstart() {
            while (true) {
                SpeechRecognitionEngine oEscucha = new SpeechRecognitionEngine();
                oEscucha.SetInputToDefaultAudioDevice();
                GrammarBuilder gr = new GrammarBuilder();
                oEscucha.LoadGrammar(new DictationGrammar());

                oEscucha.SpeechRecognized += Deteccion;
                oEscucha.RecognizeAsync(RecognizeMode.Single);

                Console.WriteLine("1");
                if (intro.IndexOf("botella", 0, StringComparison.CurrentCultureIgnoreCase) != -1) { //That chechs if "botella" is inside the text ignoring uppercase
                    break;
                }
        } }

1 个答案:

答案 0 :(得分:-1)

public static void waitforstart() {
        while (true) {
            SpeechRecognitionEngine oEscucha = new SpeechRecognitionEngine();
            oEscucha.SetInputToDefaultAudioDevice();
            GrammarBuilder gr = new GrammarBuilder();
            oEscucha.LoadGrammar(new DictationGrammar());

            oEscucha.SpeechRecognized += Deteccion;
            oEscucha.Recognize();

            Console.WriteLine(intro);
            if (intro.IndexOf("botella", 0, StringComparison.CurrentCultureIgnoreCase) != -1) { //That chechs if "botella" is inside the text ignoring uppercase
                break;
            }
    } }