简体   繁体   中英

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

So I'm using the Windows.Media.SpeechRecognition libraries.

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.

Anybody done some simple Speech Recognition for Windows Phone that can point me in the right direction?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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