0

我正在使用以下代码创建语音识别器,但我只希望它识别 3 件事,即驾驶执照、邮政编码和日期格式

M1234-56789-01234
L9B 2X5
yyyy/mm/dd

我不关心这些字符'/','','-'。(因为它们不应该包含在识别器识别的文本中)。

我只关心字母和数字。

我创建了一个只有数字和字母的语法,但是在说话时,识别器会创建像“TO”或“THERE”这样的词。有没有办法限制只识别单个字母和数字?

        SpeechRecognizer sr = new SpeechRecognizer();

        Choices chars = new Choices();
        chars.Add(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" });

        GrammarBuilder gb = new GrammarBuilder();
        gb.Append(chars);

        // Create the Grammar instance.
        Grammar g = new Grammar(gb);

        sr.LoadGrammar(g);

        sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
4

0 回答 0