Попытка использовать свободные диктуемые слова для распознавания голоса. Но это не работает для меня. Может быть, кто-то может взглянуть.
Здесь начинается:
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, но я не могу интегрировать его, чтобы получить вывод.
К сожалению, ничего не происходит.
Что я могу сделать?