×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Speech recogniton error

    I have below code for speech recognition
    Code:
                    // Initialize the SpeechRecognizerUI object.
                    SpeechRecognizerUI recoWithUI = new SpeechRecognizerUI();
    
                    // Display text to prompt the user's input.
                    recoWithUI.Settings.ListenText = "one plus two?";
    
                    // Give an example of ideal speech input.
                    recoWithUI.Settings.ExampleText = "'One Plus Two', 'Calculate Fourty Divide Two', 'Fifty Six Multiply by Three'";
    
                    // Initialize a URI with a path to the SRGS-compliant XML file.
                    Uri calculatorRulesUri = new Uri("file://" + Windows.ApplicationModel.Package.Current.InstalledLocation.Path + @"/CalculatorRules.xml", UriKind.RelativeOrAbsolute);
    
                    // Add the grammar to the grammar set.
                    recoWithUI.Recognizer.Grammars.AddGrammarFromUri("calculatorRulesUri", calculatorRulesUri);
    
                    // Load the grammar set and start recognition.
                    SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();
    When i execute it on emulator it works fine. But when i execute it on device. After executing last line it throws exception with below details.
    Message = "Exception from HRESULT: 0x800455B1"

    StackTrace = " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n ...

    What could be the issue. I have English(India) speech language installed on my phone.

    Regards,
    Vinay

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    295

    Re: Speech recogniton error

    Your issue seems to be this "An attempt to load a CFG grammar with a LANGID different than other loaded grammars."
    as stated here http://msdn.microsoft.com/en-us/libr...v=vs.105).aspx for the HResult : 0x800455B1

    it might be xml:lang="en-US" in your CFG grammar (the one the emulator uses by default), and you need to add en-in English(India) langID to your rules (the one used in your device).
    exemple :
    Code:
    <rule id="yes">
        <one-of>
          <item>yes</item>
          <item xml:lang="en-IN">yes</item>
        </one-of> 
      </rule>
    Last edited by Loukt; 2013-04-08 at 10:52.

  3. #3
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Speech recogniton error

    Hi Yassine,

    Quote Originally Posted by Loukt View Post
    Your issue seems to be this "An attempt to load a CFG grammar with a LANGID different than other loaded grammars."
    as stated here http://msdn.microsoft.com/en-us/libr...v=vs.105).aspx for the HResult : 0x800455B1

    it might be xml:lang="en-US" in your CFG grammar (the one the emulator uses by default), and you need to add en-in English(India) langID to your rules (the one used in your device).
    exemple :
    Code:
    <rule id="yes">
        <one-of>
          <item>yes</item>
          <item xml:lang="en-IN">yes</item>
        </one-of> 
      </rule>
    Oh yes. I had xml:lang="en-US" in my SRGS file. Changed it to xml:lang="en-IN" and it worked.

    Now to support multiple languages is it possible to get list of installed language packs on the phone. So i can load correct grammar file depending on installed language pack or show error if required language pack is not installed(i know the error showing part can be done by catching exception too)

    Regards,
    Vinay

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    295

    Re: Speech recogniton error

    Glad that it worked however can you test this one xml:lang="en" it should work for all english language packs.

    For the language pack are you refering to the culture ?

    then you should compare CultureInfo.CurrentCulture.Name with the LangID in your gammar file.

  5. #5
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Speech recogniton error

    Hi Yassine,
    Quote Originally Posted by Loukt View Post
    Glad that it worked however can you test this one xml:lang="en" it should work for all english language packs.

    For the language pack are you referring to the culture ?

    then you should compare CultureInfo.CurrentCulture.Name with the LangID in your gammar file.
    No, it did not worked for xml:lang="en". Requires a strict language ISO code. And by language pack i did nor mean culture info. To use speech on windows phone you need to install language packs. You wont find any speech packs installed on a brand new phone. But user can install as many packs as he wish from the available list. So is there a way to get list of language packs installed on the device.??

    Regards,
    Vinay

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    295

    Re: Speech recogniton error

    Ok I see, Can you try this snippet ?

    this will normally list all the installed package
    Code:
    var voices = InstalledSpeechRecognizers.All;
    foreach (var v in voices)
    {
           Debug.WriteLine(v.Language); 
    }
    You'll just have to compare with the language in your Grammar config.
    sommething like
    Code:
    if( voices.Any(o => o.Language = "en-IN")  )
    PS : You might need to edit the snippets, since I didn't tryed any.

  7. #7
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Speech recogniton error

    Hi Yassine,

    Quote Originally Posted by Loukt View Post
    Ok I see, Can you try this snippet ?

    this will normally list all the installed package
    Code:
    var voices = InstalledSpeechRecognizers.All;
    foreach (var v in voices)
    {
           Debug.WriteLine(v.Language); 
    }
    You'll just have to compare with the language in your Grammar config.
    sommething like
    Code:
    if( voices.Any(o => o.Language = "en-IN")  )
    PS : You might need to edit the snippets, since I didn't tryed any.
    Thanks. I will test these snippets and let you know.

    Regards,
    Vinay

  8. #8
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Speech recogniton error

    Hi Yassine,

    Sound strange but InstalledSpeechRecognizers.All is returning empty list both on emulator and device even though at least one speech is installed on both. I have no idea whats going wrong.

    Regards,
    Vinay

  9. #9
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    295

    Re: Speech recogniton error

    Hello Vinayppatil,

    I've just tested it, and it will return empty, if you don't allow these capabilities :

    Code:
    ID_CAP_SPEECH_RECOGNITION
    ID_CAP_MICROPHONE
    ID_CAP_NETWORKING
    One checked, it returned the right value.

  10. #10
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Speech recogniton error

    Quote Originally Posted by Loukt View Post
    Hello Vinayppatil,

    I've just tested it, and it will return empty, if you don't allow these capabilities :

    Code:
    ID_CAP_SPEECH_RECOGNITION
    ID_CAP_MICROPHONE
    ID_CAP_NETWORKING
    One checked, it returned the right value.
    Ah.! Yes it was permission issue. Worked after adding capabilities.

    Thanks and Regards,
    Vinay

Similar Threads

  1. Speech to text and text to speech APIs
    By Digish in forum Symbian
    Replies: 6
    Last Post: 2010-05-11, 07:10
  2. Speech to text.
    By ashutosh12 in forum Symbian
    Replies: 4
    Last Post: 2009-12-23, 08:30
  3. Text to speech
    By pranay_preet in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2009-02-09, 08:47
  4. Speech recognition (speech capture)
    By amauri in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2008-09-25, 20:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×