我正在使用以下代码通过麦克风将文本输入到 RichTextBox:
private void button1_Click(object sender, EventArgs e)
{
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
Grammar dictationGrammar = new DictationGrammar();
recognizer.LoadGrammar(dictationGrammar);
try
{
MessageBox.Show("Ready to talk?", "Speak", MessageBoxButtons.OKCancel);
recognizer.SetInputToDefaultAudioDevice();
RecognitionResult result = recognizer.Recognize();
richTextBoxPrintCtrl1.SelectedText = result.Text;
}
catch (InvalidOperationException exception)
{
MessageBox.Show("Could not recognize input from default audio device. Is a microphone or sound card available?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
recognizer.UnloadAllGrammars();
}
但是,结果不是很准确。我想在我的应用程序中实现一个相当准确的语音到文本听写服务。有人知道我可以改进此代码的方法,或者知道实现语音到文本的任何其他方法吗?
提前致谢。