00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include "bsapi.h"
00004
00005 class ErrorHandler : public SErrorCallbackI
00006 {
00007 public:
00008 virtual void BSAPI_METHOD OnTextMessage(unsigned int iId, message_type type, unsigned int messageId, char *pMessage)
00009 {
00010 char *ptext_iid = BSAPIInterfaceId2Text(iId);
00011
00012 switch(type)
00013 {
00014 case mtError:
00015 fprintf(stderr, "ERROR: %s - %s\n", ptext_iid, pMessage);
00016 break;
00017 case mtWarning:
00018 fprintf(stderr, "WARNING: %s - %s\n", ptext_iid, pMessage);
00019 break;
00020 case mtLog:
00021 fprintf(stdout, "%s\n", pMessage);
00022 break;
00023 }
00024 }
00025 } gErrorHandler;
00026
00027 main()
00028 {
00029
00030 SSpeechRecI *psrec;
00031 psrec = static_cast<SSpeechRecI *>(BSAPICreateInstance(SIID_SPEECHREC));
00032 if(!psrec)
00033 {
00034 fprintf(stderr, "ERROR: Memory allocation error\n");
00035 exit(1);
00036 }
00037
00038 psrec->SetErrorHandler(&gErrorHandler);
00039
00040 if(psrec->Init(...))
00041 exit(1);
00042
00043 ...
00044
00045 psrec->Release();
00046
00047 return 0;
00048 }