SAPI 5.1 in C#

  • 12 years ago
    Hi guysI wrote an application for speech recognition in C#. In this application, I use several recognition profiles; I need to switch between the profiles in the run time environment. I wrote a code which do it but it threw an exception “HRESULT: 0x8004505F”, although the profile change at the Control Panel à Speech. The code is:using SpeechLib;//-----SpSharedRecognizer SharedRecognizer = new SpSharedRecognizer();SpObjectToken recoObject = null;//------public void ProfileSwitch(string profileName)        {            //get all profiles             string str10 = "", str11 = "";            objTokens = SharedRecognizer.GetProfiles(str10, str11);            //activate the current the requierd profile            for (int i = 0; i < objTokens.Count; i++)            {if (profileName == objTokens.Item(i).GetDescription(0))                  {                    recoObject = objTokens.Item(i);                    recoObject.Category.Default = recoObject.Id;                  }            }            try            {                            SharedRecognizer.Profile = recoObject;            }            catch (Exception ex)            {MessageBox.Show("Error in switching profiles \n" + "Error message: " + ex.Message, "ERROR");            }        }  Can someone please tell me what is the problem in the code?I thought to use in SetRecoProfile but I don’t know how to use it, so if anyone know hwo to use it I’ll thank him a lot!! Thanks in advance,Anna.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler