How to register .dlm and .ngr files generated in D

2019-06-11 10:14发布

问题:

I am using Windows Dictation Resource kit and I have geneated .dlm and .ngr files of a medical model and now how do I register these dictation topics in Windows 7, I also would like to know if is there a way to directly load them in the program?

回答1:

You need to register the topics under the engine GUID key. For US English, the key is

HKLM\SOFTWARE\Microsoft\Speech\Recognizers\Tokens\MS-1033-80-DESK\Models\1033\L1033\LMs\AddOn

Create a REG_SZ key whose name is the dictation topic name, and whose value is the path to the .dlm/.ngr (both files need to be in the same directory).

For example, if the dictation topic was named "Medical", and you the path was in "c:\medical", then the reg key would be

HKLM\SOFTWARE\Microsoft\Speech\Recognizers\Tokens\MS-1033-80-DESK\Models\1033\L1033\LMs\AddOn\Medical = c:\medical

To specify the dictation topic in code, you just need to specify the topic name when loading the dictation grammar.

For C# (using System.Speech.Recognition), the code looks like this:

string topic = "grammar:dictation#Medical";
DictationGrammar dg = new DictationGrammar(topic);

In C++, using native SAPI,

ISpRecoGrammar* pGrammar;
// initialize pGrammar before use...
HRESULT hr = pGrammar->LoadDictation(L"Medical", SPLO_STATIC);

If you want your new topic to show up in Windows Speech Recognition, you also need to update

HKCU\Software\Microsoft\Speech\Preferences\DictationLanguageModels

and add a value whose name is the topic name, and whose value is the display value. For example, if your topic is "Medical" and you wanted it to appear as "Medical Dictation", then you would have

HKCU\Software\Microsoft\Speech\Preferences\DictationLanguageModels\Medical = "Medical Dictation"