Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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