TTS_LOG_ERROR_CB

Invoked when the Vocalizer instance has detailed error information to deliver to the application.

typedef LH_VOID (*TTS_LOG_ERROR_CB)(
 LH_VOID* pAppData,
 LH_U32 u32ErrorID, 
 const wchar_t* szErrorIDText, 
 TTS_ERROR_SEVERITY eErrorSeverity,
 const VXIVector* pKeys, 
 const VXIVector* pValues);

Argument

Description

pAppData

Application data pointer that was passed into TtsOpen or TtsSystemInit.

u32ErrorID

[out] Unique error ID number. This error ID corresponds to the "num" attribute within install_path\doc\VocalizerLogStrings.enu.xml.

szErrorIDText

[out] The associated error string for that error ID, corresponding to the content of the error with a matching "num" attribute within install_path\doc\VocalizerLogStrings.enu.xml.

eErrorSeverity

[out] The severity level for that error ID, corresponding to the "severity" attribute of the error with a matching "num" attribute within install_path\doc\VocalizerLogStrings.enu.xml.

  • 1: critical error
  • 2: severe error
  • 3: warning
  • 4: informational message
  • 5: disabled error (callback will not be called for these)

pKeys

[out] Vector containing the keys of the error string.

pValues

[out] Vector containing the values of the error string’s keys.

Vocalizer invokes this callback when the engine instance encounters errors. To register your callback, see TTS_OPEN_PARAMS. To enable, set log_cb_enabled to true.

Use this callback to acquire and report error information to system operators (via application logs or other notification systems). Do not presume that the error is fatal. Instead, wait for the return and examine the code of the API function (TTSRETVAL value).

You can use this callback to report global errors that occur during initialization of the Vocalizer engine. (These would be licensing errors, configuration errors, invalid folders for data, missing environment variables, and so on.) To enable this feature you must provide a pointer to the registered callback when invoking TtsSystemInit.

Return values: None.

Note: The VXIVector parameters represent the keys and values as they make up the arguments of the complete error string. The number of elements in both vectors must be the same at all times and their values must be strings (VALUE_STRING).

A typical usage of these VXIVectors is shown in the nvscmdline sample application, which is shipped with the product. See Testing the Vocalizer installation.

Sample code:

static LH_VOID TtsLogErrorCb(LH_VOID* lpAppData,
 LH_U32 iErrorID,
 const wchar_t* szErrorIDString,
 TTS_ERROR_SEVERITY eErrorSeverity,
 const VXIVector* lpKeys,
 const VXIVector* lpValues)
{
 std::wstring strMessage;
 const wchar_t *szSEVERITY[] = {
 L"UNKNOWN", /* Unknown error severity */
 L"CRITICAL", /* All instances out of service */
 L"SEVERE", /* Service affecting failure */
 L"WARNING", /* Application or non-service affecting failure */
 L"INFO", /* Informational message */
};
 
strMessage = szErrorIDString;
 
for (size_t i = 0;
 (i < VXIVectorLength(lpKeys)) &&
 (i < VXIVectorLength(lpValues)); i++)
{
 strMessage += L", ";
 strMessage += VXIStringCStr((const VXIString *)
  VXIVectorGetElement(lpKeys, i));
 strMessage += L"=";
 strMessage += VXIStringCStr((const VXIString *)
  VXIVectorGetElement(lpValues, i));
}
 wprintf(L"%s %u: %s\n", szSEVERITY[eErrorSeverity], iErrorID,
  strMessage.c_str());
}