简体   繁体   English

Windows Phone 8.1上的语音识别问题

[英]Speech Recognition Issue on Windows Phone 8.1

I'm working on an app that is trying to use Speech Recognition to enter text. 我正在尝试使用语音识别来输入文本的应用程序。 I don't have a particular grammar, I just want to dump the spoken text into a text box on Windows Phone 8.1 我没有特定的语法,我只想将语音文本转储到Windows Phone 8.1上的文本框中

So I'm using the Windows.Media.SpeechRecognition libraries. 所以我正在使用Windows.Media.SpeechRecognition库。

My code is basically this 我的代码基本上就是这个

SpeechRecognizer sr = new SpeechRecognizer();
SpeechRecognitionResult result = await sr.RecognizeAsync();
if(result.Confidence == SpeechRecognitionConfidence.High || result.Confidence == SpeechRecognitionConfidence.Medium)
    txtBox.Text = result.Text;
else
    txtBox.Text = "Huh?";

sr.Close()

I'm getting an error when I press the button to start the voice recognition: "Operation is not valid due to the current state of the object" 当我按下按钮开始语音识别时出现错误:“由于对象的当前状态,操作无效”

I've done some searching but the big results seem to be about some issues with ASP.NET years ago. 我已经做了一些搜索,但几年前似乎是关于ASP.NET的一些问题的重大结果。

Anybody done some simple Speech Recognition for Windows Phone that can point me in the right direction? 有人为Windows Phone做了一些简单的语音识别,可以指出我正确的方向吗?

UPDATE I eventually found the answer. 更新我最终找到了答案。 Even though there are no additional constraints you need still need to compile the defaults. 即使没有其他约束,您仍然需要编译默认值。

sr.CompileConstraintsAsync();

And then you can do the 然后你可以做到

sr.RecognizeAsync() 

function. 功能。

Thanks. 谢谢。

您是否在应用清单中检查了麦克风功能?

I eventually found the answer. 我终于找到了答案。 Even though there are no additional constraints you need still need to compile the defaults. 即使没有其他约束,您仍然需要编译默认值。

sr.CompileConstraintsAsync();

And then you can do the 然后你可以做到

sr.RecognizeAsync()

function. 功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM