[英]How do I use SpeechRecognitionEngine in a Windows Service?
I have been trying to get speech recognition working from a Windows Service without much luck. 我一直在尝试从Windows服务获得语音识别,但是运气不佳。 I am able to get it working just fine from a Console, winForms or WPF application, but when I try to put the same code into a Service.
我可以从Console,winForms或WPF应用程序中使它正常工作,但是当我尝试将相同的代码放入Service中时。 I based my sample console app on the example here: http://msdn.microsoft.com/en-us/library/ms554584.aspx Then I literally copied the same code to the service and it fails.
我基于以下示例创建了示例控制台应用程序: http : //msdn.microsoft.com/zh-cn/library/ms554584.aspx然后,我从字面上将相同的代码复制到了该服务,但它失败了。 I did read somewhere that the account that the Services run in don't have a access to a default audio device, so the problem lies with this line:
我确实在某处读到,运行服务的帐户无权访问默认音频设备,因此问题出在这一行:
recognizer.SetInputToDefaultAudioDevice();
Is there some way I can get speech recognition from a microphone working from within a service? 我可以通过某种方式从服务内工作的麦克风获得语音识别吗?
It is probably a permissions problem. 这可能是权限问题。 Run "services.msc", double-click on your service to edit it, and specify an account on the Log On tab.
运行“ services.msc”,双击您的服务以对其进行编辑,然后在“登录”选项卡上指定一个帐户。 Use the account where you are able to run successfully as a console application.
使用您能够成功作为控制台应用程序运行的帐户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.