Search code examples
c#sapi

How to open sapi train window in a c# application?


I want to open windows sapi train window in my application.

I find this process's file path is "C:\Windows\System32\Speech\SpeechUX\SpeechUXWiz.exe".But when i attempt to open it by dobule click,it faild.I try to open this file in my application by process.start() method will be faild too.

 Process.Start(@"C:\Windows\System32\Speech\SpeechUX\SpeechUXWiz.exe");

Is there someone know how to open it? Is there a interface to do that in sapi? Thank you!

My system is windows7 x64.


Solution

  • Don't start the process directly; the details of the command line are version-dependent (and, in fact, the process itself may change from version to version).

    You can start training (in C#) using speechlib (the SAPI IDispatch-compatible API). Look at ISpeechRecognizer::DisplayUI.

    To use SpeechLib, add

    using SpeechLib;
    

    to your code, and add a reference (via Project/Add Reference/COM) to the Microsoft Speech Object Library to your project.

    Then, to start training, you would have some code that looks like this:

    static void RunTraining()
    {
        SpSharedRecoContext RC = new SpSharedRecoContext();
        string Title = "My App's Training";
        ISpeechRecognizer spRecog = RC.Recognizer;
        spRecog.DisplayUI(hWnd, Title, SpeechLib.SpeechStringConstants.SpeechUserTraining, "");
    }