尝试使用自由指示的单词进行语音识别。但这对我不起作用。也许有人可以看看。
从这里开始:
public MainWindow()
{
InitializeComponent();
recognizer = new SpeechRecognitionEngine();
freeTextDictation();
}
这是逻辑:
private void freeTextDictation()
{
GrammarBuilder startStop = new GrammarBuilder();
GrammarBuilder dictation = new GrammarBuilder();
dictation.AppendDictation();
startStop.Append(new SemanticResultKey("StartDictation", new SemanticResultValue("Start Dictation", true)));
startStop.Append(new SemanticResultKey("DictationInput", dictation));
startStop.Append(new SemanticResultKey("StopDictation", new SemanticResultValue("Stop Dictation", false)));
Grammar grammar = new Grammar(startStop);
grammar.Enabled = true;
grammar.Name = " Free-Text Dictation ";
recognizer.LoadGrammar(grammar);
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += Recognizer_SpeechRecognized;
}
private void Recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//MessageBox.Show(e.Result.Text.ToString());
Console.WriteLine(e.Result.Text.ToString());
}
该代码来自Microsoft网站,但我无法对其进行集成以获取输出。 不幸的是,什么都没有发生。
我该怎么办?