Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

C++ Voice Commands with SDK5.1


  • Please log in to reply

#1
gpcdon

gpcdon

    New Member

  • Member
  • Pip
  • 1 posts
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.
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP