System.Speech.Recognition Choosing Recognition Pro

2019-06-19 19:10发布

Does anyone know how to change recognition profiles from within a .NET application?

I am writing a .NET application that does speech recognition using the capabilities found in the System.Speech.Recognition namespace. The audio that I am feeding into the system comes from multiple different users. I would like to be able to train the system to more accurately recognize speech from each of the different users.

I have found the Speech Recognition control panel in windows (Windows 7 in this case) where I can configure training profiles. Setting up a profile for myself and doing the training process significantly improved the accuracy of the recognition. So I could setup profiles for every user and have them do the training process, but then I need to be able to select the right profile in my application.

My application is a "server" that receives audio streams from one or more users at a time and performs the speech recognition. So I need to be able to specify which recognition profile to use programmatically for each instance of the recognition engine that my application creates. This is not a single user application, so I can't just have them select their profile from the Windows control panel.

3条回答
甜甜的少女心
2楼-- · 2019-06-19 19:35

I don't see a way to do it via System.Speech.Recognition, but you can do it via speechlib (the SAPI IDispatch-compatible API). Look at ISpeechRecognizer::Profile.

To set the profile, you will need to add

using SpeechLib;

to your code, along with System.Speech.Recognition.

The tricky part would be getting the profile that you set via SpeechLib to 'stick' while you're creating the System.Speech.Recognition.RecognitionEngine. I'd probably set the profile to be default (via SpeechLib), create the RecognitionEngine, and reset the default profile.

(I'm assuming that you're not planning to use the shared recognizer, which won't work in a multiuser scenario.)

You'll probably need a critical section to make sure that only one thread can create the RecognitionEngine at a time.

查看更多
该账号已被封号
3楼-- · 2019-06-19 19:41

how about asking them each to say their name to prime it with a given user?

it's not a very secure method if you'd like this solution to have some amount of authentication... you could tell them to use a given phrase that the system will recognize as a 'certain user' that can't really be faked?

this is pretty interesting though, I gotta say.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-06-19 19:54

You can use the registry to change the default profile. The registry contains list of profiles. You can easily add them via the speech properties dialog. Train the profile and its ready to use.

Change the default profile in the registry and start the speech engine and its is using that profile. This has work fordifferent windows versions, have not tried on multiple instances.

The registry Key is located at. HKEY_CURRENT_USER\Software\Microsoft\Speech\RecoProfiles Change the "DefaultTokenId" key value to HKEY_CURRENT_USER\Software\Microsoft\Speech\RecoProfiles\Tokens{7A8C84A3-44DA-488F-A27D-BC5BC326A8BE}

Here is how to look through profiles and set a profile as default.

        RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Speech\RecoProfiles\Tokens");
        _profiles = rk.GetSubKeyNames();
        string findname = "{7A8C84A3-44DA-488F-A27D-BC5BC326A8BE}";
        string name = "";
        foreach (String s in _profiles)
        {
            using (RegistryKey sk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Speech\RecoProfiles\Tokens\" + s))
            {
                if (sk != null)
                    name = (string)sk.GetValue("");
                if (name == findname) break;
            }
        }
        RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Speech\RecoProfiles", true);
        rk.SetValue("DefaultTokenId", @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Speech\RecoProfiles\Tokens\" + name);
查看更多
登录 后发表回答