我正在制作一个涉及使用 Windows 语音识别的应用程序。我正在考虑使用 C++ 来做到这一点,因为我对这种语言有一些经验。我想要使用语音识别的方式是让它在内部工作。如果我将音频文件上传到我的程序中,我希望语音识别将此音频写入为文本文件,但所有这些都应该在内部完成。请提供一些帮助,如果我没有正确解释我的问题,请告诉我,我会尝试再次解释。
提前致谢,
分区
(老问题,但没有被接受的答案,并且在谷歌中显得相当高)
如果您确实想在 C++ 中执行此操作,则必须下载 SAPI SDK,它不是 Windows 的标准配置:,选择SpeechSDK51.exe
using System.Speech;
using System.Speech.Recognition;
// in constructor or initialisation
SpeechRecognitionEngine recognizer = null;
recognizer = new SpeechRecognitionEngine();
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.RecognizeAsync(RecognizeMode.Multiple);
// The callback called when a sentence is recognized
private void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e){
string text = e.Result.Text;
// Do whatever you want with 'text' now
}