使用c ++调用和使用Windows语音识别 [英] Using c++ to call and use Windows Speech Recognition

查看:685
本文介绍了使用c ++调用和使用Windows语音识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个涉及使用windows语音识别的应用程序。我正在考虑使用c ++来做到这一点,因为我对这种语言有一些经验。我想使用语音识别的方式是使它在内部工作。如果我上传一个音频文件到我的程序,我想要语音识别将这个音频写为文本文件,但所有这一切都应该在内部完成。请提供一些帮助,如果我没有解释我的问题,请让我知道,我会尝试再次解释。

I am making an application that involves the use of windows speech recognition. I am thinking of using c++ to do this since i have some experience with this language. The way i want to use the speech recognition is so that it works internally. If i upload an audio file into my program, i want speech recognition to write this audio up as a text file, but all this should be done internally. Please provide some help with this and if i have not explained my question properly please let me know and i will try to explain again.

提前感谢
Divs

Thanks in advance, Divs

推荐答案

老问题,但没有接受的答案,并且在google中显得相当高)

(Old question, but no accepted answer, and appears quite high in google)

如果你真的想在C ++中做这个,你必须下载SAPI SDK不符合Windows标准: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en ,选择SpeechSDK51.exe

If you really want to do this in C++, you have to download the SAPI SDK, which does not come standard with Windows : http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&displaylang=en , select SpeechSDK51.exe

您可以在SAPI上找到的最佳文档不在网络上,而是在SDK本身的文档/文件夹中。 .chm解释一切真的很好。 此处是一个额外的链接

The best documentation you can find on SAPI is not on the web, it's in the SDK itself, in the Docs/ folder. The .chm explains everything really well. Here is an additional link to get you started.

但是,C ++不是你的要求,我强烈建议你在C#中做。它真的简单得多(没有COM组件,没有单独的SDK,更多的文档在MSDN上,更多的教程,...)。请参见此CodeProject文章;你必须删除所有的GUI东西,所有的语音合成的东西,你会看到,语音识别boeds下来10行代码。非常令人印象深刻。

However, it C++ is not a requirement for you, I strongly recommend you do it in C#. It's really much simpler (no COM components, no separate SDK, more doc on MSDN, more tutorials, ...) . See this CodeProject article; you'll have to remove all the GUI stuff, and all the speech synthesis stuff, and you'll see, speech recognition boild down to 10 lines of code. Quite impressive.

编辑示例代码,未编译,未测试:

EDIT sample code, not compiled, not tested :

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
}

ta dah,done

ta dah, done

这篇关于使用c ++调用和使用Windows语音识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆