00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00051
00052 #include "plugin.h"
00053
00054
00056 cbmachine ww;
00057 HWND HScol = NULL;
00058
00059
00061 int OBJSPEECHSCOL;
00062 int OBJRECOSCOL;
00063
00064
00066 int SCOL_SPEECH_END_CB = 0;
00067 int SPEECH_END_CB;
00068
00069 int SCOL_SPEECH_WORD_CB = 1;
00070 int SPEECH_WORD_CB;
00071
00072 int SCOL_SPEECH_TEXT_CB = 2;
00073 int SPEECH_TEXT_CB;
00074
00075 int SCOL_SPEECH_PHONEME_CB = 3;
00076 int SPEECH_PHONEME_CB;
00077
00078
00080 int SCOL_RECO_END_CB = 0;
00081 int RECOGNITION_END_CB;
00082
00083 int SCOL_RECO_TEXT_CB = 1;
00084 int RECOGNITION_TEXT_CB;
00085
00086 int SCOL_RECO_START_CB = 2;
00087 int RECOGNITION_START_CB;
00088
00089 int SCOL_RECO_TEXTS_ALT_CB = 3;
00090 int RECOGNITION_TEXTS_ALT_CB;
00091
00092 int SCOL_RECO_WORDS_CB = 4;
00093 int RECOGNITION_WORDS_CB;
00094
00095
00097 wchar_t* convertCharToLPCWSTR(char * s_text)
00098 {
00099 int char_count = MultiByteToWideChar(CP_ACP, 0, s_text, -1, NULL, 0);
00100 wchar_t * w_text = new wchar_t[char_count];
00101 MultiByteToWideChar(CP_ACP, 0, s_text, -1, w_text, char_count);
00102
00103 return w_text;
00104 }
00105
00106
00107 char* convertWcharToChar(wchar_t * w_text)
00108 {
00109 int wchar_count = WideCharToMultiByte(CP_ACP, 0, w_text, -1, NULL, 0,NULL,NULL);
00110 char * s_text = new char[wchar_count];
00111 WideCharToMultiByte(CP_ACP, 0, w_text, -1, s_text, wchar_count,NULL,NULL);
00112
00113 return s_text;
00114 }
00115
00116
00125 int destroySpeechObj(mmachine m, int handsys, int speechTab)
00126 {
00127 Speech * SpeechObj = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00128 if (SpeechObj == NULL) {
00129 MMset(m, 0, NIL);
00130 return 0;
00131 }
00132
00133 SAFE_DELETE(SpeechObj);
00134 MMstore(m, MTOP(speechTab), 0, NULL);
00135 MMechostr(MSKDEBUG,"ObjSpeech destroyed.\n");
00136 return 0;
00137 }
00138
00139
00149 int _CRSpeech(mmachine m)
00150 {
00151 #ifdef _SCOL_DEBUG_
00152 MMechostr(MSKDEBUG,"_CRSpeech\n");
00153 #endif
00154
00155 int channel = MMget(m, 0);
00156 if (channel == NIL) {
00157 MMechostr(MSKDEBUG, "Channel NIL\n");
00158 MMpull(m);
00159 MMpush(m, NIL);
00160 return 0;
00161 }
00162
00163 Speech * newSpeech = new Speech();
00164 int speechTab = MMmalloc(m,1,TYPETAB) ;
00165 if ( speechTab == NIL )
00166 {
00167 SAFE_DELETE(newSpeech) ;
00168 MMpull(m);
00169 return MMpush(m, NIL);
00170 }
00171
00172 MMstore( m, speechTab, 0, (int)newSpeech ) ;
00173 MMpush(m, PTOM( speechTab )) ;
00174
00175 int k = 0;
00176 k = OBJcreate(m, OBJSPEECHSCOL, (int)newSpeech, NULL, NULL);
00177
00178 #ifdef _SCOL_DEBUG_
00179 MMechostr(MSKDEBUG,"ok\n");
00180 #endif
00181
00182 return k ;
00183 }
00184
00185
00195 int _DSSpeech (mmachine m)
00196 {
00197 #ifdef _SCOL_DEBUG_
00198 MMechostr(MSKDEBUG,"_DSSpeech\n");
00199 #endif
00200
00201 int speechTab = MMget(m, 0);
00202 if (speechTab == NIL) {
00203 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00204 MMset(m, 0, -1);
00205 return 0;
00206 }
00207
00208 OBJdelTM(m, OBJSPEECHSCOL, speechTab);
00209 MMset(m, 0, 0);
00210
00211 #ifdef _SCOL_DEBUG_
00212 MMechostr(MSKDEBUG,"ok\n");
00213 #endif
00214 return 0;
00215 }
00216
00217
00228 int _SetSpeechText (mmachine m)
00229 {
00230 #ifdef _SCOL_DEBUG_
00231 MMechostr(MSKDEBUG,"__SetSpeechText\n");
00232 #endif
00233
00234 int text = MMpull(m);
00235 int speechTab = MMget(m, 0);
00236 if (speechTab == NIL) {
00237 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00238 MMset(m, 0, NIL);
00239 return 0;
00240 }
00241
00242 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00243 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00244
00245 char* strText = (char*)MMstartstr(m,MTOP(text));
00246 objSpeech->SetSpeechText(strText);
00247 MMset(m, 0, 0);
00248
00249 #ifdef _SCOL_DEBUG_
00250 MMechostr(MSKDEBUG,"ok\n");
00251 #endif
00252 return 0;
00253 }
00254
00255
00266 int _SetSpeechVolume (mmachine m)
00267 {
00268 #ifdef _SCOL_DEBUG_
00269 MMechostr(MSKDEBUG,"_SetSpeechVolume\n");
00270 #endif
00271
00272 int volumeSpeech = MTOI(MMpull(m));
00273 int speechTab = MMget(m, 0);
00274 if (speechTab == NIL) {
00275 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00276 MMset(m, 0, NIL);
00277 return 0;
00278 }
00279
00280 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00281 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00282
00283 objSpeech->setVolumeSpeech(volumeSpeech);
00284 MMset(m, 0, 0);
00285
00286 #ifdef _SCOL_DEBUG_
00287 MMechostr(MSKDEBUG,"ok\n");
00288 #endif
00289 return 0;
00290 }
00291
00292
00302 int _GetSpeechVolume(mmachine m)
00303 {
00304 #ifdef _SCOL_DEBUG_
00305 MMechostr(MSKDEBUG,"_GetSpeechVolume\n");
00306 #endif
00307 int SpeechTab = MMget(m, 0);
00308 if (SpeechTab == NIL)
00309 {
00310 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00311 MMset(m, 0, NIL);
00312 return 0;
00313 }
00314 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(SpeechTab), 0);
00315 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00316
00317 MMset(m,0,ITOM(objSpeech->getVolumeSpeech()));
00318
00319 #ifdef _SCOL_DEBUG_
00320 MMechostr(MSKDEBUG,"ok\n");
00321 #endif
00322
00323 return 0;
00324 }
00325
00326
00337 int _SetSpeechRate (mmachine m)
00338 {
00339 #ifdef _SCOL_DEBUG_
00340 MMechostr(MSKDEBUG,"_SetSpeechRate\n");
00341 #endif
00342
00343 int rateSpeech = MTOI(MMpull(m));
00344 int speechTab = MMget(m, 0);
00345 if (speechTab == NIL) {
00346 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00347 MMset(m, 0, NIL);
00348 return 0;
00349 }
00350
00351 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00352 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00353
00354 objSpeech->setRateSpeech(rateSpeech);
00355 MMset(m, 0, 0);
00356
00357 #ifdef _SCOL_DEBUG_
00358 MMechostr(MSKDEBUG,"ok\n");
00359 #endif
00360 return 0;
00361 }
00362
00363
00373 int _GetSpeechRate(mmachine m)
00374 {
00375 #ifdef _SCOL_DEBUG_
00376 MMechostr(MSKDEBUG,"_GetSpeechRate\n");
00377 #endif
00378 int SppechTab = MMget(m, 0);
00379 if (SppechTab == NIL)
00380 {
00381 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00382 MMset(m, 0, NIL);
00383 return 0;
00384 }
00385 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(SppechTab), 0);
00386 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00387
00388 MMset(m,0,ITOM(objSpeech->getRateSpeech()));
00389
00390 #ifdef _SCOL_DEBUG_
00391 MMechostr(MSKDEBUG,"ok\n");
00392 #endif
00393
00394 return 0;
00395 }
00396
00397
00407 int _PlaySpeech (mmachine m)
00408 {
00409 #ifdef _SCOL_DEBUG_
00410 MMechostr(MSKDEBUG,"_PlaySpeech\n");
00411 #endif
00412
00413
00414 int speechTab = MMget(m, 0);
00415 if (speechTab == NIL) {
00416 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00417 MMset(m, 0, NIL);
00418 return 0;
00419 }
00420
00421 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00422 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00423
00424
00425 objSpeech->play();
00426
00427
00428 MMset(m, 0, 0);
00429
00430 #ifdef _SCOL_DEBUG_
00431 MMechostr(MSKDEBUG,"ok\n");
00432 #endif
00433 return 0;
00434 }
00435
00436
00446 int _PauseSpeech (mmachine m)
00447 {
00448 #ifdef _SCOL_DEBUG_
00449 MMechostr(MSKDEBUG,"_PauseSpeech\n");
00450 #endif
00451
00452
00453 int speechTab = MMget(m, 0);
00454 if (speechTab == NIL) {
00455 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00456 MMset(m, 0, NIL);
00457 return 0;
00458 }
00459
00460 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00461 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00462
00463 objSpeech->pauseResume();
00464 MMset(m, 0, 0);
00465
00466 #ifdef _SCOL_DEBUG_
00467 MMechostr(MSKDEBUG,"ok\n");
00468 #endif
00469 return 0;
00470 }
00471
00472
00482 int _ResumeSpeech (mmachine m)
00483 {
00484 #ifdef _SCOL_DEBUG_
00485 MMechostr(MSKDEBUG,"_PauseSpeech\n");
00486 #endif
00487
00488
00489 int speechTab = MMget(m, 0);
00490 if (speechTab == NIL) {
00491 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00492 MMset(m, 0, NIL);
00493 return 0;
00494 }
00495
00496 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00497 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00498
00499 objSpeech->pauseResume();
00500 MMset(m, 0, 0);
00501
00502 #ifdef _SCOL_DEBUG_
00503 MMechostr(MSKDEBUG,"ok\n");
00504 #endif
00505 return 0;
00506 }
00507
00508
00518 int _StopSpeech (mmachine m)
00519 {
00520 #ifdef _SCOL_DEBUG_
00521 MMechostr(MSKDEBUG,"_StopSpeech\n");
00522 #endif
00523
00524
00525 int speechTab = MMget(m, 0);
00526 if (speechTab == NIL) {
00527 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00528 MMset(m, 0, NIL);
00529 return 0;
00530 }
00531
00532 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00533 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00534
00535 objSpeech->stop();
00536 MMset(m, 0, 0);
00537
00538 #ifdef _SCOL_DEBUG_
00539 MMechostr(MSKDEBUG,"ok\n");
00540 #endif
00541 return 0;
00542 }
00543
00544
00558 int _CBSpeechEnd(mmachine m)
00559 {
00560 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_END_CB);
00561 }
00562
00563
00575 int getSpeechEndCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
00576 {
00577 int k = 0;
00578
00579 Speech * SpeechObj =(Speech *) id;
00580
00581 if (OBJbeginreflex(m, OBJSPEECHSCOL, (int)SpeechObj, SCOL_SPEECH_END_CB))
00582 return 0;
00583
00584 if ((k=OBJcallreflex(m, 0))) return k;
00585
00586 return k;
00587 }
00588
00589
00599 int _GetSpeechVoices(mmachine m)
00600 {
00601 #ifdef _SCOL_DEBUG_
00602 MMechostr(MSKDEBUG,"_GetSpeechVoices\n");
00603 #endif
00604 std::list <char *>::iterator c1_Iter;
00605 unsigned int k ;
00606
00607 int SpeechTab = MMget(m, 0);
00608
00609 if (SpeechTab == NIL)
00610 {
00611 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00612 MMset(m, 0, NIL);
00613 return 0;
00614 }
00615
00616 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(SpeechTab), 0);
00617 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00618
00619 std::list <char *> lParamSp = objSpeech->getVoiceAll();
00620
00621
00622 MMpull(m);
00623 for ( c1_Iter = lParamSp.begin( ); c1_Iter != lParamSp.end( ); c1_Iter++ )
00624 {
00625 if (k=Mpushstrbloc(m,(char*)*c1_Iter)) return k;
00626 }
00627 if (MMpush(m,NIL)) return MERRMEM;
00628 for ( c1_Iter = lParamSp.begin( ); c1_Iter != lParamSp.end( ); c1_Iter++ )
00629 {
00630 if (MMpush(m,2*2)) return MERRMEM;
00631 if (k=MBdeftab(m)) return k;
00632 }
00633
00634 #ifdef _SCOL_DEBUG_
00635 MMechostr(MSKDEBUG,"ok\n");
00636 #endif
00637 return 0;
00638 }
00639
00640
00651 int _SetSpeechVoice(mmachine m)
00652 {
00653 #ifdef _SCOL_DEBUG_
00654 MMechostr(MSKDEBUG,"_SetSpeechVoice\n");
00655 #endif
00656
00657 int voice = MMpull(m);
00658 int speechTab = MMget(m, 0);
00659 if (speechTab == NIL) {
00660 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00661 MMset(m, 0, NIL);
00662 return 0;
00663 }
00664
00665 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(speechTab), 0);
00666 if( !objSpeech ) { MMset(m,0,NIL) ; return 0 ; }
00667 MMechostr(MSKDEBUG,"_SetSpeechVoice : Get Speech Object\n");
00668 char * strVoice = ( char *)MMstartstr(m,MTOP(voice));
00669 MMechostr(MSKDEBUG,"_SetSpeechVoice strVoice: %s\n",strVoice);
00670 objSpeech->SetSpeechVoice(strVoice);
00671 MMechostr(MSKDEBUG,"_SetSpeechVoice FIN \n");
00672
00673 MMset(m, 0, 0);
00674
00675 #ifdef _SCOL_DEBUG_
00676 MMechostr(MSKDEBUG,"ok\n");
00677 #endif
00678 return 0;
00679 }
00680
00681
00692 int _GetSpeechVoice(mmachine m)
00693 {
00694 #ifdef _SCOL_DEBUG_
00695 MMechostr(MSKDEBUG,"_GetSpeechVoice\n");
00696 #endif
00697 int SpeechTab = MMget(m,0) ;
00698 if (SpeechTab == NIL)
00699 {
00700 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
00701 MMset(m,0,NIL) ;
00702 return 0;
00703 }
00704 Speech * objSpeech = (Speech *) MMfetch(m, MTOP(SpeechTab), 0);
00705 if( !objSpeech )
00706 {
00707 MMset(m,0,NIL) ;
00708 return 0 ;
00709 }
00710
00711 MMpull(m) ;
00712 Mpushstrbloc(m, objSpeech->getSpeechVoice());
00713
00714 #ifdef _SCOL_DEBUG_
00715 MMechostr(MSKDEBUG,"ok\n");
00716 #endif
00717
00718 return 0;
00719 }
00720
00721
00736 int _CBSpeechWord(mmachine m)
00737 {
00738 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_WORD_CB);
00739 }
00740
00741
00753 int getSpeechWordCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
00754 {
00755 int k = 0;
00756 cbData * cbdata = (cbData *) param;
00757 Speech * SpeechObj =(Speech *) id;
00758
00759 if (OBJbeginreflex(m, OBJSPEECHSCOL, (int)SpeechObj, SCOL_SPEECH_WORD_CB))
00760 return 0;
00761
00762 Mpushstrbloc(m, (char*)(cbdata->getParamChar()));
00763
00764 if ((k=OBJcallreflex(m, 1))) return k;
00765
00766 SAFE_DELETE(cbdata);
00767 return k;
00768 }
00769
00770
00785 int _CBSpeechText(mmachine m)
00786 {
00787 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_TEXT_CB);
00788 }
00789
00790
00802 int getSpeechTextCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
00803 {
00804 int k = 0;
00805 cbData * cbdata = (cbData *) param;
00806 Speech * SpeechObj =(Speech *) id;
00807
00808 if (OBJbeginreflex(m, OBJSPEECHSCOL, (int)SpeechObj, SCOL_SPEECH_TEXT_CB))
00809 return 0;
00810
00811 Mpushstrbloc(m, (char*)(cbdata->getParamChar()));
00812
00813 if ((k=OBJcallreflex(m, 1))) return k;
00814
00815 SAFE_DELETE(cbdata);
00816 return k;
00817 }
00818
00819
00834 int _CBSpeechPhoneme(mmachine m)
00835 {
00836 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_PHONEME_CB);
00837 }
00838
00839
00840
00852 int getSpeechPhonemeCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
00853 {
00854 int k = 0;
00855 Speech * SpeechObj =(Speech *) id;
00856
00857 if (OBJbeginreflex(m, OBJSPEECHSCOL, (int)SpeechObj, SCOL_SPEECH_PHONEME_CB))
00858 return 0;
00859
00860 MMpush(m, ITOM(param));
00861 if ((k=OBJcallreflex(m, 1))) return k;
00862 return k;
00863 }
00864
00865
00882 int _CRRecognition(mmachine m)
00883 {
00884 #ifdef _SCOL_DEBUG_
00885 MMechostr(MSKDEBUG,"_CRRecognition\n");
00886 #endif
00887
00888 int channel = MMget(m, 0);
00889 if (channel == NIL) {
00890 MMpull(m);
00891 MMpush(m, NIL);
00892 return 0;
00893 }
00894
00895 Recognition * newRecognition = new Recognition();
00896
00897 int RecognitionTab = MMmalloc(m,1,TYPETAB) ;
00898 if ( RecognitionTab == NIL )
00899 {
00900 SAFE_DELETE(newRecognition) ;
00901 MMpull(m);
00902 return MMpush(m, NIL);
00903 }
00904
00905 MMstore( m, RecognitionTab, 0, (int)newRecognition ) ;
00906 MMpush(m, PTOM( RecognitionTab )) ;
00907
00908 int k = 0;
00909 k = OBJcreate(m, OBJRECOSCOL, (int)newRecognition, NULL, NULL);
00910
00911 #ifdef _SCOL_DEBUG_
00912 MMechostr(MSKDEBUG,"ok\n");
00913 #endif
00914
00915 return k ;
00916 }
00917
00918
00927 int destroyRecognitionObj(mmachine m, int handsys, int recognitionTab)
00928 {
00929 Recognition * RecognitionObj = (Recognition *) MMfetch(m, MTOP(recognitionTab), 0);
00930 if (RecognitionObj == NULL) {
00931 MMset(m, 0, NIL);
00932 return 0;
00933 }
00934 SAFE_DELETE(RecognitionObj);
00935 MMstore(m, MTOP(recognitionTab), 0, NULL);
00936 MMechostr(MSKDEBUG,"ObjRecognition destroyed.\n");
00937 return 0;
00938 }
00939
00940
00950 int _DSRecognition (mmachine m)
00951 {
00952 #ifdef _SCOL_DEBUG_
00953 MMechostr(MSKDEBUG,"_DSRecognition\n");
00954 #endif
00955
00956 int recognotionTab = MMget(m, 0);
00957 if (recognotionTab == NIL) {
00958 MMechostr(MSKDEBUG,"ObjRecognition NIL\n");
00959 MMset(m, 0, -1);
00960 return 0;
00961 }
00962
00963 OBJdelTM(m, OBJRECOSCOL, recognotionTab);
00964 MMset(m, 0, 0);
00965
00966 #ifdef _SCOL_DEBUG_
00967 MMechostr(MSKDEBUG,"ok\n");
00968 #endif
00969 return 0;
00970 }
00971
00972
00986 int _CBRecognitionEnd(mmachine m)
00987 {
00988 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_END_CB);
00989 }
00990
00991
01003 int getRecognitionEndCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
01004 {
01005 int k = 0;
01006
01007 Recognition * RecognitionObj =(Recognition *) id;
01008
01009 if (OBJbeginreflex(m, OBJRECOSCOL, (int)RecognitionObj, SCOL_RECO_END_CB))
01010 return 0;
01011
01012 if ((k=OBJcallreflex(m, 0))) return k;
01013
01014 return k;
01015 }
01016
01017
01031 int _CBRecognitionStart(mmachine m)
01032 {
01033 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_START_CB);
01034 }
01035
01036
01048 int getRecognitionStartCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
01049 {
01050 int k = 0;
01051
01052 Recognition * RecognitionObj =(Recognition *) id;
01053
01054 if (OBJbeginreflex(m, OBJRECOSCOL, (int)RecognitionObj, SCOL_RECO_START_CB))
01055 return 0;
01056
01057 if ((k=OBJcallreflex(m, 0))) return k;
01058
01059 return k;
01060 }
01061
01062
01077 int _CBRecognitionText(mmachine m)
01078 {
01079 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_TEXT_CB);
01080 }
01081
01082
01094 int getRecognitionTextCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
01095 {
01096 int k = 0;
01097 cbData * cbdata = (cbData *) param;
01098 Recognition * RecognitionObj =(Recognition *) id;
01099 char * data = cbdata->getParamChar();
01100
01101 if (OBJbeginreflex(m, OBJRECOSCOL, (int)RecognitionObj, SCOL_RECO_TEXT_CB))
01102 return 0;
01103
01104 Mpushstrbloc(m, data);
01105
01106 if ((k=OBJcallreflex(m, 1))) return k;
01107
01108 SAFE_DELETE(cbdata);
01109 return k;
01110 }
01111
01112
01127 int _CBRecognitionTextsAlt(mmachine m)
01128 {
01129 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_TEXTS_ALT_CB);
01130 }
01131
01132
01144 int getRecognitionTextsAltCb(mmachine m,HWND h,unsigned msg,UINT id,LONG param,int *ret)
01145 {
01146
01147 int k = 0;
01148 int nb = 0 ;
01149 cbData * cbdata = (cbData *) param;
01150 Recognition * RecognitionObj =(Recognition *) id;
01151 if (OBJbeginreflex(m, OBJRECOSCOL, (int)RecognitionObj, SCOL_RECO_TEXTS_ALT_CB))
01152 return 0;
01153
01154 std::list <pTextRec> lParamText = cbdata->getlParamText();
01155
01156 std::list <pTextRec>::iterator c1_Iter = lParamText.begin();
01157 while(c1_Iter != lParamText.end())
01158 {
01159 nb++ ;
01160 if ( Mpushstrbloc(m,c1_Iter->altText.CopyToChar())) return MERRMEM ;
01161 if (MMpush(m,FTOM(c1_Iter->altConfidence))) return MERRMEM ;
01162 if (MMpush(m,4)) return MERRMEM ;
01163 MBdeftab(m);
01164 c1_Iter++ ;
01165 }
01166
01167 if (MMpush(m,NIL)) return MERRMEM;
01168 for(int i=0;i<nb;i++)
01169 {
01170 if (MMpush(m,2*2)) return MERRMEM;
01171 if (k=MBdeftab(m)) return k;
01172 }
01173 if ((k=OBJcallreflex(m, 1))) return k;
01174
01175 SAFE_DELETE(cbdata);
01176 return k;
01177 }
01178
01179
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01244 int _SetRecogntionVolume (mmachine m)
01245 {
01246 #ifdef _SCOL_DEBUG_
01247 MMechostr(MSKDEBUG,"_SetRecogntionVolume\n");
01248 #endif
01249 ULONG volumeReco = MTOI(MMpull(m));
01250 int recognitionTab = MMget(m, 0);
01251 if (recognitionTab == NIL) {
01252 MMechostr(MSKDEBUG,"ObjRecognition NIL\n");
01253 MMset(m, 0, -1);
01254 return 0;
01255 }
01256 Recognition * ObjRecognition = (Recognition *) MMfetch(m, MTOP(recognitionTab), 0);
01257 ObjRecognition->setvolumeReco(volumeReco);
01258 MMset(m, 0,0);
01259 #ifdef _SCOL_DEBUG_
01260 MMechostr(MSKDEBUG,"ok\n");
01261 #endif
01262 return 0;
01263 }
01264
01265
01275 int _GetRecogntionVolume(mmachine m)
01276 {
01277 #ifdef _SCOL_DEBUG_
01278 MMechostr(MSKDEBUG,"_GetRecogntionVolume\n");
01279 #endif
01280 int recognitionTab = MMget(m, 0);
01281 if (recognitionTab == NIL)
01282 {
01283 MMechostr(MSKDEBUG,"ObjRecognition NIL\n");
01284 MMset(m, 0, -1);
01285 return 0;
01286 }
01287 Recognition * ObjRecognition = (Recognition *) MMfetch(m, MTOP(recognitionTab), 0);
01288 if( !ObjRecognition ) { MMset(m,0,NIL) ; return 0 ; }
01289
01290 MMset(m,0,ITOM(ObjRecognition->getVolumeReco()));
01291
01292 #ifdef _SCOL_DEBUG_
01293 MMechostr(MSKDEBUG,"ok\n");
01294 #endif
01295
01296 return 0;
01297 }
01298
01299
01310 int _AddRecognitionWord (mmachine m)
01311 {
01312 #ifdef _SCOL_DEBUG_
01313 MMechostr(MSKDEBUG,"__SetSpeechText\n");
01314 #endif
01315
01316 int textWord = MMpull(m);
01317 int textRule = MMpull(m);
01318
01319 int recognitionTab = MMget(m, 0);
01320 if (recognitionTab == NIL) {
01321 MMechostr(MSKDEBUG,"ObjRecognition NIL\n");
01322 MMset(m, 0, -1);
01323 return 0;
01324 }
01325
01326 Recognition * ObjRecognition = (Recognition *) MMfetch(m, MTOP(recognitionTab), 0);
01327
01328 char* strRule = (char*)MMstartstr(m,MTOP(textRule));
01329 char* strWord = (char*)MMstartstr(m,MTOP(textWord));
01330 ObjRecognition->addWord(strRule,strWord);
01331 MMset(m, 0, 0);
01332
01333 #ifdef _SCOL_DEBUG_
01334 MMechostr(MSKDEBUG,"ok\n");
01335 #endif
01336 return 0;
01337 }
01338
01339
01341 #define NbTplPKG 29
01342
01343
01347 char *TplName[NbTplPKG] =
01348 {
01349 "ObjSpeech",
01350 "ObjRecognition",
01351 "_CRSpeech",
01352 "_DSSpeech",
01353 "_SetSpeechText",
01354 "_SetSpeechVolume",
01355 "_GetSpeechVolume",
01356 "_SetSpeechRate",
01357 "_GetSpeechRate",
01358 "_PlaySpeech",
01359 "_PauseSpeech",
01360 "_ResumeSpeech",
01361 "_StopSpeech",
01362 "_CBSpeechEnd",
01363 "_GetSpeechVoices",
01364 "_GetSpeechVoice",
01365 "_SetSpeechVoice",
01366 "_CBSpeechWord",
01367 "_CBSpeechText",
01368 "_CBSpeechPhoneme",
01369
01370 "_CRRecognition",
01371 "_DSRecognition",
01372 "_CBRecognitionEnd",
01373 "_CBRecognitionText",
01374 "_CBRecognitionTextsAlt",
01375
01376 "_CBRecognitionStart",
01377 "_SetRecogntionVolume",
01378 "_GetRecogntionVolume",
01379 "_AddRecognitionWord"
01380
01381 };
01382
01383
01387 int (*TplFunc[NbTplPKG])(mmachine m)=
01388 {
01389 NULL,
01390 NULL,
01391 _CRSpeech,
01392 _DSSpeech,
01393 _SetSpeechText,
01394 _SetSpeechVolume,
01395 _GetSpeechVolume,
01396 _SetSpeechRate,
01397 _GetSpeechRate,
01398 _PlaySpeech,
01399 _PauseSpeech,
01400 _ResumeSpeech,
01401 _StopSpeech,
01402 _CBSpeechEnd,
01403 _GetSpeechVoices,
01404 _GetSpeechVoice,
01405 _SetSpeechVoice,
01406 _CBSpeechWord,
01407 _CBSpeechText,
01408 _CBSpeechPhoneme,
01409
01410 _CRRecognition,
01411 _DSRecognition,
01412 _CBRecognitionEnd,
01413 _CBRecognitionText,
01414 _CBRecognitionTextsAlt,
01415
01416 _CBRecognitionStart,
01417 _SetRecogntionVolume,
01418 _GetRecogntionVolume,
01419 _AddRecognitionWord
01420 };
01421
01422
01423
01427 int TplNArg[NbTplPKG]=
01428 {
01429 TYPTYPE,
01430 TYPTYPE,
01431 1,
01432 1,
01433 2,
01434 2,
01435 1,
01436 2,
01437 1,
01438 1,
01439 1,
01440 1,
01441 1,
01442 3,
01443 1,
01444 1,
01445 2,
01446 3,
01447 3,
01448 3,
01449
01450 1,
01451 1,
01452 3,
01453 3,
01454 3,
01455
01456 3,
01457 2,
01458 1,
01459 3
01460 };
01461
01462
01466 char* TplType[NbTplPKG]=
01467 {
01468 NULL,
01469 NULL,
01470 "fun [Chn] ObjSpeech",
01471 "fun [ObjSpeech] I",
01472 "fun [ObjSpeech S] I",
01473 "fun [ObjSpeech I] I",
01474 "fun [ObjSpeech] I",
01475 "fun [ObjSpeech I] I",
01476 "fun [ObjSpeech] I",
01477 "fun [ObjSpeech] I",
01478 "fun [ObjSpeech] I",
01479 "fun [ObjSpeech] I",
01480 "fun [ObjSpeech] I",
01481 "fun [ObjSpeech fun [ObjSpeech u0] u1 u0] ObjSpeech",
01482 "fun [ObjSpeech] [S r1]",
01483 "fun [ObjSpeech] S",
01484 "fun [ObjSpeech S] I",
01485 "fun [ObjSpeech fun [ObjSpeech u0 S] u1 u0] ObjSpeech",
01486 "fun [ObjSpeech fun [ObjSpeech u0 S] u1 u0] ObjSpeech",
01487 "fun [ObjSpeech fun [ObjSpeech u0 I] u1 u0] ObjSpeech",
01488
01489 "fun [Chn] ObjRecognition",
01490 "fun [ObjRecognition] I",
01491 "fun [ObjRecognition fun [ObjRecognition u0] u1 u0] ObjRecognition",
01492 "fun [ObjRecognition fun [ObjRecognition u0 S] u1 u0] ObjRecognition",
01493 "fun [ObjRecognition fun [ObjRecognition u0 [[S F] r1]] u1 u0] ObjRecognition",
01494
01495 "fun [ObjRecognition fun [ObjRecognition u0] u1 u0] ObjRecognition",
01496 "fun [ObjRecognition I] I",
01497 "fun [ObjRecognition] I",
01498 "fun [ObjRecognition S S] I"
01499
01500 };
01501
01502
01507 int LoadSpeech(mmachine m)
01508 {
01509 int k;
01510
01511
01512 OBJSPEECHSCOL = OBJregister( 4, 1, destroySpeechObj, "OBJSPEECHSCOL" ) ;
01513 OBJRECOSCOL = OBJregister( 4, 1, destroyRecognitionObj, "OBJRECOSCOL" ) ;
01514
01515 SPEECH_END_CB = OBJgetUserEvent() ;
01516 OBJdefEvent( SPEECH_END_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getSpeechEndCb );
01517
01518 SPEECH_WORD_CB = OBJgetUserEvent() ;
01519 OBJdefEvent(SPEECH_WORD_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getSpeechWordCb );
01520
01521 SPEECH_TEXT_CB = OBJgetUserEvent() ;
01522 OBJdefEvent(SPEECH_TEXT_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getSpeechTextCb );
01523
01524 SPEECH_PHONEME_CB = OBJgetUserEvent() ;
01525 OBJdefEvent(SPEECH_PHONEME_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getSpeechPhonemeCb );
01526
01527 RECOGNITION_END_CB = OBJgetUserEvent() ;
01528 OBJdefEvent( RECOGNITION_END_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getRecognitionEndCb );
01529
01530 RECOGNITION_TEXT_CB = OBJgetUserEvent() ;
01531 OBJdefEvent( RECOGNITION_TEXT_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getRecognitionTextCb );
01532
01533 RECOGNITION_TEXTS_ALT_CB = OBJgetUserEvent() ;
01534 OBJdefEvent( RECOGNITION_TEXTS_ALT_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getRecognitionTextsAltCb );
01535
01536
01537
01538
01539 RECOGNITION_START_CB = OBJgetUserEvent() ;
01540 OBJdefEvent( RECOGNITION_START_CB, (int (__cdecl *)(struct Mmachine *,int,unsigned int,int,int,int *))getRecognitionStartCb );
01541
01542 k = PKhardpak(m, "SpeechEngine", NbTplPKG, TplName, TplFunc, TplNArg, TplType);
01543
01544 if (FAILED(::CoInitialize(NULL)))
01545 return 0;
01546
01547 return k;
01548 }
01549
01550
01555 extern "C" __declspec (dllexport) int SCOLloadSPEECH(mmachine m, cbmachine w)
01556 {
01557 int k = 0;
01558
01559 SCOLinitplugin(w);
01560
01561 HScol=(HWND)SCgetExtra("hscol");
01562
01563 MMechostr(MSKDEBUG,"SCOLloadSPEECH_RECOGNITION loading SpeechRecognition DLL ...\n");
01564
01565 LoadSpeech(m);
01566
01567 return k;
01568 }
01569
01570
01575 extern "C" __declspec (dllexport) int SCOLfreeSPEECH()
01576 {
01577 MMechostr(MSKDEBUG,"Release Speech DLL\n");
01578 ::CoUninitialize();
01579 return 0;
01580 }
01581
01582
01583