The first step is to open a speech port. The speech port creates the link with the Speech Engine.
C: HPORT LV_SRE_OpenPort (ExportLogMsg log, void *p, int verbosity)
C++: int LVSpeechPort::OpenPort (ExportLogMsg log, void *p, int verbosity)
ExportLogMsg is a callback function designed to allow the client application to define behaviors based on the message received while the Speech Engine is processing data.
typedef void (*ExportLogMsg)(const char* String, void* p);
#include <windows.h>
#include <stdio.h>
#include <LVSpeechPort.h>
class CMyData //an arbitrary class defining some behavior
{
public:
CMyData(){m_nSomeNumber = 0; m_nLogType = 1;}
INT m_nSomeNumber;
INT m_nLogType;
};
//ExportLogMsg callback
void SPLogging(const char* String, void* p)
{
CMyData* pMD = (CMyData *) p;
If(pMD->m_nLogType == 1) //example use of userdata
{
printf(String);
}
else
{
//display the msg to a GUI.
}
}
#ifdef _C_
//the C way
HPORT OpenTheSpeechport(void)
{
HPORT hPort; //the soon-to-be-created speech port
CMyData* pMD = new CMyData; //user-defined behaviors for the userdata parameter
hPort = LV_SRE_OpenPort(SPLogging, pMD, 3); //open the port
return hPort;
}
#elsif def _CPLUSPLUS_
//the C++ way; assumes myPort is an existing LVSpeechPort object
int OpenTheSpeechPort(LVSpeechPort &myPort, CMyData* mydataobject)
{
//Opens the port
//3 specifies a middling amount of logging
return myPort.OpenPort(SPLogging, mydataobject, 3);
}
#endif
When using the C API, the returned value of hport will be needed for all calls accessing the Speech Engine.
When using the C++ API, the return value indicates success or failure. All calls accessing the Speech Engine use the myPort parameter, which is now a valid speech port (assuming no errors).
Complete Help Topic List | Speech Engine Product Information