-1

We write software (C#) for Speech Recognition, up until a particular W10 update we had no problems with speech recognition (via usb Microphone/headset). We are now facing issues with recognition and have found that it is caused by the (audio) input device setting "Signal Enhancements" and "Enable Audio Enhancements". We have found that when this setting is disabled, the recognition results are far better and we are not losing words or sentences.

At the moment the only way we are able to disable this is to manually uncheck the box, but this must be done every time a device is connected, and sometimes after Win Update also.

Is there any way of turning this setting of programmatically?

Any pointers or advice would be very much appreciated :)

Richard Gale
  • 1,816
  • 5
  • 28
  • 45
  • It looks like you can fiddle with registry settings but it is unclear which keys/values map to exactly those settings: https://github.com/dechamps/APO and you might end-up with access-control issues if you try to change the regsitry keys from within your code. But it is worth trying. – rene May 12 '23 at 11:49
  • 1
    While I'm happy to leave that last sentence in, I removed it because some trigger happy close voters might read "Any pointers" as a signal to a request for an off-site resource, which still is a valid close reason. Without that noise your question is a "how do I do X" and that is a valid question. I leave the risk assessment for potential closure up to you. – rene May 12 '23 at 11:53

2 Answers2

1

We are facing a similar problem with our softphone. Signal Enhancements apparently produces a delay start of the audio device (WaveInOpen method with CALLBACK_THREAD) but this effect only appears at few PCs. We cannot for sure say that signal enhancements are the problem but the point is that disabling "signal enhancements" improved the situation at these PCs, no such a big delay, from 1.5 sec to 200 milliseconds.

I anyway wanted to programatically deactivate and activate it again for each telephone call.

I could follow inside my Windows registry (Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture) that the entry

{1da5d803-d492-4edd-8c23-e0c0ffee7f0e},5 (PKEY_AudioEndpoint_Disable_SysFx)

is set and unset when I activate and deactivate the signal enhancements option in the audio settings.

Problem is that this registry entry is inside the FxProperties folder. There are two folders for devices offering audio effects:

...MMDevices\Audio\Capture\{guid}\Properties

...MMDevices\Audio\Capture\{guid}\FxProperties

And when I read the properties with the IMMDevice interface I only get the list of entries inside the Properties folder but no idea how to get access to the FxProperties folder. I use following code: (some parts and checkings are removed, just wrote the necessary)

pEnumerator->EnumAudioEndpoints(eAll, DEVICE_STATEMASK_ALL, &pMMDeviceCollection);
pMMDeviceCollection->GetCount(&nDevices);
for (UINT i = 0; i < nDevices; i++) {
    pMMDeviceCollection->Item(i, &pMMDevice);
    pMMDevice->OpenPropertyStore(STGM_READ, &store);
}

OpenPropertyStore only gives you access to the Properties folder.

I continue investigating how to gain access to FxProperties store. In this case I would implement something like that:

fxStore->SetValue(PKEY_AudioEndpoint_Disable_SysFx, ENDPOINT_SYSFX_DISABLED);

which would hopefully deactivate the signal enhancement for the corresponding device.

Another attemps with SHGetPropertyStoreFromParsingName or RegGetValue were neither successfull. Error codes were 0x80070002 and ERROR_FILE_NOT_FOUND.

I also tried to start my application with administrative rights but no difference. No sign of the FxProperties entries.

EDIT: I found this link: https://learn.microsoft.com/en-us/answers/questions/669471/how-to-control-enable-audio-enhancements-with-code

IPolicyConfig does the trick but it is an undocumented Windows Interface. I would not rely on it.

Sergio
  • 241
  • 2
  • 9
0

base on Sergio's answer and this Q&A https://learn.microsoft.com/en-us/answers/questions/669471/how-to-control-enable-audio-enhancements-with-code, i found a way to disable audio enhancements:

  1. Add this key {1da5d803-d492-4edd-8c23-e0c0ffee7f0e},5 to your audio device registry key as this ...MMDevices\Audio\Capture{guid}\FxProperties
  2. then you can use set value 1 to this key

NOTE: you can reference this github project to operate registry item, NetworkDLS

std::wstring key_path = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio\\Capture\\{guid}\\FxProperties";
std::wstring key_item = L"{1da5d803-d492-4edd-8c23-e0c0ffee7f0e},5";
unsigned long val = 0;
bool res = Get_DWORDRegistryValue(HKEY_LOCAL_MACHINE, (LPCTSTR)key_path.c_str(), (LPCTSTR)key_item.c_str(), val);
if (!res)
{
  std::cout << "Get key item failed, not exist!\n";
  val = 1;
  // Must use Admin right to run this code
  if (!Set_DWORDRegistryValue(HKEY_LOCAL_MACHINE, (LPCTSTR)key_path.c_str(), (LPCTSTR)key_item.c_str(), val))
  {
    std::cout << "Set Registry failed\n";
  }
}

// Writes a DWORD value to the registry
bool Set_DWORDRegistryValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, unsigned long ulValue)
{
  HKEY hKey;
  LONG lRes;

  lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, &hKey);

  if (lRes != ERROR_SUCCESS)
  {
    SetLastError(lRes);
    return false;
  }

  lRes = RegSetValueEx(hKey, pszValue, 0, REG_DWORD, (unsigned char *)&ulValue, sizeof(ulValue));

  RegCloseKey(hKey);

  if (lRes != ERROR_SUCCESS)
  {
    SetLastError(lRes);
    return false;
  }

  return true;
}

Update: I found another way to add registry value into audio device, just like following cmd script:

@echo off
echo Windows Registry Editor Version 5.00> audio_test.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{device_guid}\FxProperties]>> audio_test.reg
echo "{1da5d803-d492-4edd-8c23-e0c0ffee7f0e},5"=dword:1>> audio_test.reg
call audio_test.reg
del audio_test.reg

I tested it works on my computer, only drawback is this will request to privileged rights from admin user.

Grey
  • 5
  • 3