Daedalus357
October 14th, 2008, 10:46 PM
I'm currently working with developing an application (currently console-based) with Text-To-Speech capability. So far my implementation of the TTS SDK into my program has been almost seamless, until i attempted to implement a user-input action. up to this point, all the application's TTS has been pre-designated in each line. I want my application to be able to read the user's name back to them as it is speaking, to make it a little more... "friendly" for a lack of better terms.
anyway, the code in question is from my prototype AI (see attached ode snippet). As i said, i want to be able to read my user's input, send it to the TTS speech, and have the program read it.
this is the error i receive when i compile / build my program:
error C2664: 'Speak' : cannot convert parameter 1 from 'char' to 'const unsigned short *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
I've tried searching through the MSDN knowledge database, specifically on the SAPI Speech SDK, but to no avail. This has been an ongoing headache for the past 5 hours, so any help or suggestions will be greatly appreciated!
-----------------CODE SNIPPET-----------------------------
#include <stdafx.h>
#include <sapi.h>
#include <iostream>
int main(int argc, int response, char* argv[])
{
ISpVoice *pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
std::cout << "Good morning user.\n";
hr = pVoice->Speak(L"Good Morning User", 0, NULL);
std::cout << "How are you today?\n\n";
hr = pVoice->Speak(L"How are you today?", SPF_IS_XML, NULL );
std::cout << "please select a response:\n 1) I am well\n 2) I am not well\n selection: ";
std::cin >> response;
/* -------PROBLEMATIC USER-INPUT CODE----------
char test;
std::cin >> test;
pVoice->Speak(test, 0, NULL);
-----------END OF PROBLEMATIC CODING---------*/
//------------Functional Code resumes here----------
while (response !=1 || response !=2)
{
if (response == 1)
{
std::cout << "I am happy to hear that, user\n";
hr = pVoice->Speak(L"I am happy to hear that, user.", 0, NULL);
return 0;
}
else if (response == 2)
{
std::cout << "I am sorry to hear that, user.\n";
hr = pVoice->Speak(L"I am sorry to hear that, user.", 0, NULL);
return 0;
}
else
{
std::cout << "I am sorry user, that choice was invalid.\n";
hr = pVoice->Speak(L"I am sorry user, that choice was invalid.", 0, NULL);
std::cout << "please select a response:\n 1) I am well\n 2) I am not well\n selection: ";
std::cin >> response;
}
}
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}
anyway, the code in question is from my prototype AI (see attached ode snippet). As i said, i want to be able to read my user's input, send it to the TTS speech, and have the program read it.
this is the error i receive when i compile / build my program:
error C2664: 'Speak' : cannot convert parameter 1 from 'char' to 'const unsigned short *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
I've tried searching through the MSDN knowledge database, specifically on the SAPI Speech SDK, but to no avail. This has been an ongoing headache for the past 5 hours, so any help or suggestions will be greatly appreciated!
-----------------CODE SNIPPET-----------------------------
#include <stdafx.h>
#include <sapi.h>
#include <iostream>
int main(int argc, int response, char* argv[])
{
ISpVoice *pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
std::cout << "Good morning user.\n";
hr = pVoice->Speak(L"Good Morning User", 0, NULL);
std::cout << "How are you today?\n\n";
hr = pVoice->Speak(L"How are you today?", SPF_IS_XML, NULL );
std::cout << "please select a response:\n 1) I am well\n 2) I am not well\n selection: ";
std::cin >> response;
/* -------PROBLEMATIC USER-INPUT CODE----------
char test;
std::cin >> test;
pVoice->Speak(test, 0, NULL);
-----------END OF PROBLEMATIC CODING---------*/
//------------Functional Code resumes here----------
while (response !=1 || response !=2)
{
if (response == 1)
{
std::cout << "I am happy to hear that, user\n";
hr = pVoice->Speak(L"I am happy to hear that, user.", 0, NULL);
return 0;
}
else if (response == 2)
{
std::cout << "I am sorry to hear that, user.\n";
hr = pVoice->Speak(L"I am sorry to hear that, user.", 0, NULL);
return 0;
}
else
{
std::cout << "I am sorry user, that choice was invalid.\n";
hr = pVoice->Speak(L"I am sorry user, that choice was invalid.", 0, NULL);
std::cout << "please select a response:\n 1) I am well\n 2) I am not well\n selection: ";
std::cin >> response;
}
}
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}