UseSpeech Registry Entry

Some users do not wish to have the computer speak or to talk to the computer. These users can indicate their preferences by using a voice-navigation application, which records their preferences in the registry. Microsoft Voice is an example of a voice-navigation application. An application can check the value of this entry before trying to load its voice-command or voice-text code and can save memory by not loading the code if it is not needed.

An application that uses voice commands or voice text on the local computer (not necessarily over the telephone) should check the following registry entry.

HKEY_CURRENT_USER\Software\Voice\UseSpeech

UseSpeech is a DWORD value under the Voice key that is TRUE if the user has turned on speech recognition or text-to-speech using the installed voice-navigation application. An application should assume that the value is FALSE if the UseSpeech entry is not in the registry.

If the value of UseSpeech is FALSE when the application starts, it should not call the CoCreateInstance function for the CLSID_VCmd or CLSID_VTxt class identifier.

An application can use the following code to obtain the value of UseSpeech from the registry.

HKEY hKey;

DWORD dwValue, dwType = REG_DWORD, dwSize = sizeof(DWORD);

if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Voice", 0, KEY_READ,

&hKey) == ERROR_SUCCESS) {

RegQueryValueEx(hKey, "UseSpeech", 0, &dwType, (LPBYTE) &dwValue,

&dwSize);

RegCloseKey(hKey);

}

Whenever speech is turned on or off, the voice-navigation application sends the WM_SPEECHSTARTED or WM_SPEECHENDED message to all top-level windows in the system. An application can use these messages to determine when to dynamically create or release instances of its voice-command or voice-text objects. Although highly recommended, the use of these messages by applications is optional. These messages are not defined in the SPEECH.H header file. You can use the RegisterWindowMessage function to obtain the message identifiers to use in your application.