Search code examples
windowsspeech-recognitionsapi

How to use the function GetStorageFileName for adding training files to registry?


I am using sapi 5.4 and I am able to retain the audio for training but for adding it to registry entries as given in this Acoustic training using SAPI 5.3 Speech API I am not able to understand the arguments to be used for ISpObjectToken::GetStorageFileName can somebody help me out with it?


Solution

  • ISpObjectToken::GetStorageFileName isn't the best documented API in the world. Luckily, I have some worked examples to help improve the documentation.

    clsidCaller

    Set this if you need the file name associated with the object token. For training, this should be CLSID_NULL. (If you're updating engine-related data, then it would be the CLSID of the engine.)

    pszValueName

    The name of the registry subkey to store the filename in. For training, this should be L"TrainingAudio-<locale>", where locale should be the 4 digit locale ID for the engine.

    pszFileNameSpecifier

    The name of the file to be created.

    If this starts with "X:\" or "\" it is assumed to be a full path.

    Otherwise it is assumed to be relative to the special folder ID given in the nFolder parameter.

    If pszFileNameSpecifier ends with a '\', or is NULL a unique file name will be created.

    If the name contains a %d the %d is replaced by a number to give a unique file name.

    For training, you should specify something like L"TrainingAudio\\TR_%d.wav".

    nFolder

    A CSIDL value that identifies the folder whose path is to be retrieved. The user can force the creation of a folder by combining the folder's CSIDL with CSIDL_FLAG_CREATE. If pszFileNameSpecifier is NULL or "\", nFolder must have a specified CSIDL folder combined with CSIDL_FLAG_CREATE if the user wants to force to create the file.

    For training, this should be CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE.

    ppszFilePath

    Address of a pointer to the null-terminated string that receives the file path information. Use CoTaskMemFree to release the string when done.