Hello,
I have been asked to use Microsoft SDK 5.1 to enable voice commands in a program. After installing the SDK I am using the Reco sample program. I am using a vocabulary which I have created. Reco recognizes this vocabulary and is working fine.
For the program I need to translate the verbal numbers I give the computer into the actual number so the computer can understand it. For example, when I say "zero five zero" the computer understand that as 3 distinct digits. But what I am trying to do is get the computer to recognize that as the int variable 050 or 50. I am having trouble doing this.
I can translate one number at a time using this sample:
if (pProp->vValue.vt != VT_EMPTY)
{
int temp = 0;
CComVariant cv = pProp->vValue;
cv.ChangeType(VT_BSTR);
temp = atoi(W2T(cv.bstrVal)) * 100;
wsprintf(szText, _T("CLOSEQUOTE\" (ULID %d = VARIANTVALUE %s) extracted: (%d)"), pProp->ulId, W2T(cv.bstrVal), temp); //CLOSE QUOTE
//variable cv is already a string in this line. if propname is number then we can use that
//string value to change to an int.
}
SAMPLE OUTPUT:
PROPERTIES:
"(Here I am)" = " [FIRSTELEM 2, COUNTELEM 2] "PROPNAME command" = "OPENQUOTEheadingCLOSEQUOTE" (ULID 0 = VARIANTVALUE 1) extracted: (100)
[FIRSTELEM 3, COUNTELEM 3] "PROPNAME number" = "OPENQUOTEzeroCLOSEQUOTE" (ULID 1 = VARIANTVALUE 0) extracted: (0)
[FIRSTELEM 4, COUNTELEM 4] "PROPNAME number" = "OPENQUOTEfiveCLOSEQUOTE" (ULID 1 = VARIANTVALUE 5) extracted: (500)
[FIRSTELEM 5, COUNTELEM 5] "PROPNAME number" = "OPENQUOTEzeroCLOSEQUOTE" (ULID 1 = VARIANTVALUE 0) extracted: (0)
the extracted value demonstrates that the number is now an integer.
But I am having trouble linking three numbers in a row. So I tried writing a toInteger function but it's not working how I anticipated.
int CRecoDlgClass::toInteger(const SPPHRASEPROPERTY *pProp)
{
USES_CONVERSION;
int result = -2;
while(pProp->pszValue != L"\0")
{
if (pProp->pszName == L"pilot_command")
{
CComVariant cv = pProp->vValue;
cv.ChangeType(VT_BSTR);
result = atoi(W2T(cv.bstrVal)) * 100;
pProp->pNextSibling;
cv = pProp->vValue;
result += atoi(W2T(cv.bstrVal)) * 10;
pProp->pNextSibling;
cv = pProp->vValue;
result += atoi(W2T(cv.bstrVal));
}
else
{
pProp->pNextSibling;
}
}
return result;
}
If anyone could help me with this problem it would be greatly appreciated.