locked
speechRecognizer.RecognizeAsync() throwing system.exception RRS feed

  • Question

  • I am trying to use speech recognizer in my code, but each time I try to execute it, it throws me  System.Exception.

    I have added the required "Capabilities" in WMAppManifest as well.

    Following is my code logic:

    SpeechRecognizer speechRecognizer = new SpeechRecognizer();
    
                speechRecognizer.Settings.EndSilenceTimeout = TimeSpan.FromSeconds(6.0);
                speechRecognizer.Settings.BabbleTimeout = TimeSpan.FromSeconds(4.0);
                speechRecognizer.Grammars.AddGrammarFromList("answer", new string[] { "Yes" });
    
                var result = await speechRecognizer.RecognizeAsync();
                if (result.Text == "Yes" && (result.TextConfidence == SpeechRecognitionConfidence.High ||
    
                    result.TextConfidence == SpeechRecognitionConfidence.Medium))

    The code throws an error at line "var result = await speechRecognizer.RecognizeAsync();"

    I get following message "Exception was unhandled by user code". The inner exception is null., and the message is "The text associated with this error code could not be found", in exception snapshot.

    Any help on this would be great.

    Thanks in Advance.

    Saturday, November 1, 2014 6:56 AM

Answers

  • Hi!

    Your program works fine on any device and any emulator.
    But if you use the emulator it is as if you were using a win phone for the very first time. It will ask you to accept the privacy policy for text recognition. So just just hold the search button for a second and accept the privacy policy.

    If you use SpeechRecognizerUI instead of SpeechRecognizer, you don't have to worry about this problem.
    SpeechRecognizerUI has built in support for this error and it has built in support for the back key and many other problems.

    Best regards

    Gerhard

    Sunday, November 2, 2014 9:44 AM

All replies

  • Capabilities :
    ID_CAP_SPEECH_RECOGNITION
    ID_CAP_MICROPHONE
    ID_CAP_NETWORKING

    I test your code, it's correct.

    Then I remove ID_CAP_MICROPHONE, it fired execption like you said.


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Saturday, November 1, 2014 9:00 AM
  • Hey thanks for the reply.

    Well I added the said Capabilities, but I am still getting the same error again, and that too at that same line.

    Just an off topic, but is it that my manifest not detected due to expired developer licenses etc.?.

    But yeah saying that, I am facing the same exception.


    • Edited by Siddy Boy Saturday, November 1, 2014 6:32 PM
    Saturday, November 1, 2014 6:32 PM
  • did you test it by emulator ?  I found it not work correctly on emulator.

    but  i deploy app to my phone (Lumia 830 / Windows Phone 8.1), it work fine.


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Sunday, November 2, 2014 4:11 AM
  • Hey, yes I am testing it on my emulator only, and it is not working, though I saw some tutorials and videos which were able to execute it on the emulator but.

    So should I try it on the device you mean?. It works correctly there?..

    Also just one more question a little offbeat, can you fire the speech recognition without any user interaction like button pressing etc., or you require these events?.

    Thanks again for your reply.

    Sunday, November 2, 2014 4:36 AM
  • Hi!

    Your program works fine on any device and any emulator.
    But if you use the emulator it is as if you were using a win phone for the very first time. It will ask you to accept the privacy policy for text recognition. So just just hold the search button for a second and accept the privacy policy.

    If you use SpeechRecognizerUI instead of SpeechRecognizer, you don't have to worry about this problem.
    SpeechRecognizerUI has built in support for this error and it has built in support for the back key and many other problems.

    Best regards

    Gerhard

    Sunday, November 2, 2014 9:44 AM
  • Hey, I tried to change the settings and again accepted the required privacy policy, and re selected the capabilities, so it is working, but when I debug my code multiple times the error re-occurs.

    So it works correct in between and sometimes it rethrows that same error.

    Anyways I guess it should work fine on the device, and for now it sometimes works on the emulator, so guess should be fine.

    Anyways thanks for the response.

    Sunday, November 2, 2014 6:12 PM