gorexy
asked on
Text-to_Speech MS Agent 4.0 Question
I am working on the MS Agent 4.0 application and got 2 problems.
1. How can I change the speaker? by default, is MSMary and I want to use other user like MSMike
2. My code is working fine now for MS Mary but when I play a few times, it will crash! How to solve it?
////////my code/////////////////////
BSTR sIP = ::SysAllocString(L"");
char key[20];
int i;
TCHAR wsIP[300];
static const LPTSTR kpszAppTitle="";
static const LPWSTR kpwszCharacter = L"orgmerlin.acs";
HRESULT hRes;
_TCHAR szError[256];
VARIANT vPath;
BSTR bszSpeak;
long lCharID;
long lRequestID;
IAgentEx *pAgentEx;
IAgentCharacterEx *pCharacterEx = NULL;
ISpObjectToken *pToken = NULL;
ULONG ulCount = 0;
hRes = CoCreateInstance(CLSID_Age ntServer,N ULL, CLSCTX_SERVER,IID_IAgentEx , (LPVOID *)&pAgentEx);
// First try to load the default character
VariantInit(&vPath);
vPath.vt = VT_BSTR;
//vPath.vt = VT_EMPTY;
vPath.bstrVal = SysAllocString(kpwszCharac ter);
hRes = pAgentEx->Load(vPath, &lCharID, &lRequestID);
hRes = pAgentEx->GetCharacterEx(l CharID, &pCharacterEx);
hRes = pCharacterEx->Show(TRUE, &lRequestID);
hRes = pCharacterEx->SetLanguageI D(MAKELANG ID(LANG_EN GLISH, SUBLANG_ENGLISH_US));
bszSpeak = SysAllocString(A2W((LPTSTR )sIP));
pVoice->Speak(bszSpeak, NULL, &lRequestID);
SysFreeString(bszSpeak);
1. How can I change the speaker? by default, is MSMary and I want to use other user like MSMike
2. My code is working fine now for MS Mary but when I play a few times, it will crash! How to solve it?
////////my code/////////////////////
BSTR sIP = ::SysAllocString(L"");
char key[20];
int i;
TCHAR wsIP[300];
static const LPTSTR kpszAppTitle="";
static const LPWSTR kpwszCharacter = L"orgmerlin.acs";
HRESULT hRes;
_TCHAR szError[256];
VARIANT vPath;
BSTR bszSpeak;
long lCharID;
long lRequestID;
IAgentEx *pAgentEx;
IAgentCharacterEx *pCharacterEx = NULL;
ISpObjectToken *pToken = NULL;
ULONG ulCount = 0;
hRes = CoCreateInstance(CLSID_Age
// First try to load the default character
VariantInit(&vPath);
vPath.vt = VT_BSTR;
//vPath.vt = VT_EMPTY;
vPath.bstrVal = SysAllocString(kpwszCharac
hRes = pAgentEx->Load(vPath, &lCharID, &lRequestID);
hRes = pAgentEx->GetCharacterEx(l
hRes = pCharacterEx->Show(TRUE, &lRequestID);
hRes = pCharacterEx->SetLanguageI
bszSpeak = SysAllocString(A2W((LPTSTR
pVoice->Speak(bszSpeak, NULL, &lRequestID);
SysFreeString(bszSpeak);
ASKER
thanks
actually sIP will be filled from external progrm (Virtools Dev) and Ihave checked there is content inside.
actually sIP will be filled from external progrm (Virtools Dev) and Ihave checked there is content inside.
1. For sIP, how you are allocating additional memory. What would be the length of the string from your external program. Inital calling of SysAllocString has emptry string value for the sIP variable.
2. how the memory is deallocated for sIP
2. how the memory is deallocated for sIP
ASKER
hm..Ok I will copy my code tomorrow and show you.
ASKER
I use this to get input
beh->GetInputParameterValu e(0, sIP);
bszSpeak = SysAllocString(A2W((LPTSTR )sIP));
beh->GetInputParameterValu
bszSpeak = SysAllocString(A2W((LPTSTR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok let me test
how about
How can I change the speaker? by default, is MSMary and I want to use other user like MSMike
?
how about
How can I change the speaker? by default, is MSMary and I want to use other user like MSMike
?
>>How can I change the speaker? by default, is MSMary and I want to use other user like MSMike?
I am not sure about that.
I am not sure about that.
>>bszSpeak = SysAllocString(A2W((LPTSTR
>>SysFreeString(bszSpeak);
SysAllocString allocates a new string and copies the passed string into it. Appears you are calling SysAllocString twice but not freeing it twice.
You can pass sIP to
pVoice->Speak(sIP, NULL, &lRequestID);
Btw where you are assigning the value to sIP?
Also try to debug your application during crash to pin point the problem. Look at the call stack to determine which line of your code is causing the problem.