I'm trying to build software that interprets various textual commands, all in a custom way. I use System.Speech.Recognition and it works surprisingly well, but I can't figure how to get around the fact that whenever I say "Delete", "Close", "Correct", etc, I will end up with the default Windows (7) implementation. Is there any way to get around that with System.Speech.Recognition? If not, which C# .NET library would you recommend the most?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Use SpeechRecognitionEngine instead of SpeechRecognizer.
Try this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
namespace speech
{
class Program
{
static void Main(string[] args)
{
SpeechRecognitionEngine mynizer = new SpeechRecognitionEngine();
GrammarBuilder builder = new GrammarBuilder();
builder.AppendDictation();
Grammar mygram = new Grammar(builder);
mynizer.SetInputToDefaultAudioDevice();
mynizer.LoadGrammar(mygram);
while (true)
{
Console.WriteLine(mynizer.Recognize().Text);
}
}
}
}