开发者

Is there any way to suppress the background speech recognition functions and run smoothly?

I am using trying to develop a program in Visual Studio 2010 on Windows 7. I finally got it to run, although it is a bit temperamental (sometimes it runs smoothly and sometimes it doesn't). I have realized that there is no way for it to run without enabling speech recognition, which I turn on before I debug it, although I have found that the background functions of speech recognition interfere with the execution of my code. It starts trying to insert words into my code, which interrupts it and so on. Is there a way to suppress th开发者_如何学Goese background functions so that the speech recognition (SR) is focused solely on running my code?

I think the general idea is to find a configuration that will help it run smoothly consistently...


Try using the SpeechRecognitionEngine instead of the SpeechRecognizer

Here's an example:

using System;
using System.Collections.Generic; 
using System.Linq;
using System.Text;
using System.Speech.Recognition;
namespace speectest
{
class Program
{
    static void Main(string[] args)
    {
        SpeechRecognitionEngine engine = new SpeechRecognitionEngine();

        GrammarBuilder grandma = new GrammarBuilder();
        engine.SetInputToDefaultAudioDevice();
        grandma.AppendDictation();
        engine.LoadGrammar(new Grammar(grandma));
        engine.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(engine_RecognizeCompleted);
        engine.RecognizeAsync();
        System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    }

    static void engine_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
    {
        Console.WriteLine(e.Result.Text);
    }
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜