Template
plugin.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25
26/*
27 Speech SCOL API based on SAPI library from microsoft : http://msdn.microsoft.com/en-us/library/ms723627(VS.85).aspx
28 First version : may 2010
29 Author : Hamza HAMDI
30*/
31
32
50#include <scolMemoryHelper.hpp>
51
52#ifdef RECO_USE_SAPI
53# include "reco.h"
54#else
55//# include "reco_sphinx.h"
56# include "reco_vosk.h"
57#endif
58
59#ifdef SPEECH_USE_SAPI
60# include "speech.h"
61#endif
62
64#ifdef SCOL_STATIC
65extern cbmachine ww;
66extern mmachine mm;
67#else
68cbmachine ww;
69mmachine mm;
70#endif
71
75
76
80
83
86
89
92
95
96
100
103
106
109
112
113
115#ifdef _WIN32
116wchar_t* convertCharToLPCWSTR(char * s_text)
117{
118 int char_count = MultiByteToWideChar(CP_ACP, 0, s_text, -1, NULL, 0);
119 wchar_t* w_text = new wchar_t[char_count];
120 MultiByteToWideChar(CP_ACP, 0, s_text, -1, w_text, char_count);
121
122 return w_text;
123}
124
125
126char* convertWcharToChar(wchar_t * w_text)
127{
128 int wchar_count = WideCharToMultiByte(CP_ACP, 0, w_text, -1, NULL, 0, NULL, NULL);
129 char* s_text = new char[wchar_count];
130 WideCharToMultiByte(CP_ACP, 0, w_text, -1, s_text, wchar_count, NULL, NULL);
131
132 return s_text;
133}
134#endif
135
144int destroySpeechObj(mmachine m, SCOL_PTR_TYPE handsys, int speechTab)
145{
146#ifdef _SCOL_DEBUG_
147 MMechostr(MSKDEBUG, "destroySpeechObj\n");
148#endif
149
150#ifdef SPEECH_USE_SAPI
151 Speech* SpeechObj = MMgetPointer<Speech*>(m, MTOP(speechTab));
152 SAFE_DELETE(SpeechObj);
153
154 MMsetPointer<Speech*>(m, MTOP(speechTab), 0);
155#endif
156 MMechostr(MSKDEBUG, "ObjSpeech destroyed.\n");
157 return 0;
158}
159
160
170int _CRSpeech(mmachine m)
171{
172 int k = 0;
173#ifdef _SCOL_DEBUG_
174 MMechostr(MSKDEBUG, "_CRSpeech\n");
175#endif
176
177#ifdef SPEECH_USE_SAPI
178 Speech* newSpeech = new Speech();
179 if (newSpeech == 0)
180 {
181 MMset(m, 0, NIL);
182 return 0;
183 }
184
185 if ((MMpushPointer(m, newSpeech) != 0))
186 {
187 SAFE_DELETE(newSpeech);
188 MMset(m, 0, NIL);
189 return MERRMEM;
190 }
191
192 k = OBJcreate(m, OBJSPEECHSCOL, SCOL_PTR newSpeech, NULL, NULL);
193#else
194 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
195 MMset(m, 0, NIL);
196 return 0;
197#endif
198
199#ifdef _SCOL_DEBUG_
200 MMechostr(MSKDEBUG, "ok\n");
201#endif
202
203 return k;
204}
205
206
216int _DSSpeech(mmachine m)
217{
218#ifdef _SCOL_DEBUG_
219 MMechostr(MSKDEBUG, "_DSSpeech\n");
220#endif
221
222 int speechTab = MMget(m, 0);
223 if (speechTab == NIL)
224 {
225 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
226 MMset(m, 0, NIL);
227 return 0;
228 }
229
230 OBJdelTM(m, OBJSPEECHSCOL, speechTab);
231 MMset(m, 0, ITOM(1));
232
233#ifdef _SCOL_DEBUG_
234 MMechostr(MSKDEBUG, "ok\n");
235#endif
236 return 0;
237}
238
239
250int _SetSpeechText(mmachine m)
251{
252#ifdef _SCOL_DEBUG_
253 MMechostr(MSKDEBUG, "__SetSpeechText\n");
254#endif
255
256 int text = MMpull(m);
257 int speechTab = MMget(m, 0);
258 if (speechTab == NIL)
259 {
260 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
261 MMset(m, 0, NIL);
262 return 0;
263 }
264
265#ifdef SPEECH_USE_SAPI
266 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
267 if (!objSpeech)
268 {
269 MMset(m, 0, NIL);
270 return 0;
271 }
272
273 std::string strText;
274 if (text != NIL)
275 strText = MMstartstr(m, MTOP(text));
276
277 objSpeech->SetSpeechText(strText);
278 MMset(m, 0, ITOM(1));
279#else
280 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
281 MMset(m, 0, NIL);
282 return 0;
283#endif
284
285#ifdef _SCOL_DEBUG_
286 MMechostr(MSKDEBUG, "ok\n");
287#endif
288 return 0;
289}
290
291
302int _SetSpeechVolume(mmachine m)
303{
304#ifdef _SCOL_DEBUG_
305 MMechostr(MSKDEBUG, "_SetSpeechVolume\n");
306#endif
307
308 int vol = MMpull(m);
309 int speechTab = MMget(m, 0);
310 if ((speechTab == NIL) || (vol == NIL))
311 {
312 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
313 MMset(m, 0, NIL);
314 return 0;
315 }
316
317#ifdef SPEECH_USE_SAPI
318 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
319 if (!objSpeech)
320 {
321 MMset(m, 0, NIL);
322 return 0;
323 }
324
325 int nvolume = 0;
326 if (MTOI(vol) > 0)
327 nvolume = MTOI(vol);
328
329 objSpeech->setVolumeSpeech(nvolume);
330
331 MMset(m, 0, ITOM(1));
332#else
333 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
334 MMset(m, 0, NIL);
335 return 0;
336#endif
337
338#ifdef _SCOL_DEBUG_
339 MMechostr(MSKDEBUG, "ok\n");
340#endif
341 return 0;
342}
343
344
354int _GetSpeechVolume(mmachine m)
355{
356#ifdef _SCOL_DEBUG_
357 MMechostr(MSKDEBUG, "_GetSpeechVolume\n");
358#endif
359
360 int speechTab = MMget(m, 0);
361 if (speechTab == NIL)
362 {
363 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
364 MMset(m, 0, NIL);
365 return 0;
366 }
367
368#ifdef SPEECH_USE_SAPI
369 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
370 if (!objSpeech)
371 {
372 MMset(m, 0, NIL);
373 return 0;
374 }
375
376 MMset(m, 0, ITOM(objSpeech->getVolumeSpeech()));
377#else
378 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
379 MMset(m, 0, NIL);
380 return 0;
381#endif
382#ifdef _SCOL_DEBUG_
383 MMechostr(MSKDEBUG, "ok\n");
384#endif
385
386 return 0;
387}
388
389
400int _SetSpeechRate(mmachine m)
401{
402#ifdef _SCOL_DEBUG_
403 MMechostr(MSKDEBUG, "_SetSpeechRate\n");
404#endif
405
406 int rate = MMpull(m);
407 int speechTab = MMget(m, 0);
408 if ((speechTab == NIL) || (rate == NIL))
409 {
410 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
411 MMset(m, 0, NIL);
412 return 0;
413 }
414
415#ifdef SPEECH_USE_SAPI
416 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
417 if (!objSpeech)
418 {
419 MMset(m, 0, NIL);
420 return 0;
421 }
422
423 objSpeech->setRateSpeech(MTOI(rate));
424
425 MMset(m, 0, ITOM(1));
426#else
427 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
428 MMset(m, 0, NIL);
429 return 0;
430#endif
431
432#ifdef _SCOL_DEBUG_
433 MMechostr(MSKDEBUG, "ok\n");
434#endif
435 return 0;
436}
437
438
448int _GetSpeechRate(mmachine m)
449{
450#ifdef _SCOL_DEBUG_
451 MMechostr(MSKDEBUG, "_GetSpeechRate\n");
452#endif
453
454 int speechTab = MMget(m, 0);
455 if (speechTab == NIL)
456 {
457 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
458 MMset(m, 0, NIL);
459 return 0;
460 }
461
462#ifdef SPEECH_USE_SAPI
463 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
464 if (!objSpeech)
465 {
466 MMset(m, 0, NIL);
467 return 0;
468 }
469
470 MMset(m, 0, ITOM(objSpeech->getRateSpeech()));
471#else
472 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
473 MMset(m, 0, NIL);
474 return 0;
475#endif
476
477#ifdef _SCOL_DEBUG_
478 MMechostr(MSKDEBUG, "ok\n");
479#endif
480
481 return 0;
482}
483
484
494int _PlaySpeech(mmachine m)
495{
496#ifdef _SCOL_DEBUG_
497 MMechostr(MSKDEBUG, "_PlaySpeech\n");
498#endif
499
500 int speechTab = MMget(m, 0);
501 if (speechTab == NIL)
502 {
503 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
504 MMset(m, 0, NIL);
505 return 0;
506 }
507
508#ifdef SPEECH_USE_SAPI
509 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
510 if (!objSpeech)
511 {
512 MMset(m, 0, NIL);
513 return 0;
514 }
515
516 objSpeech->play();
517
518 MMset(m, 0, ITOM(1));
519#else
520 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
521 MMset(m, 0, NIL);
522 return 0;
523#endif
524
525#ifdef _SCOL_DEBUG_
526 MMechostr(MSKDEBUG, "ok\n");
527#endif
528 return 0;
529}
530
531
541int _PauseSpeech(mmachine m)
542{
543#ifdef _SCOL_DEBUG_
544 MMechostr(MSKDEBUG, "_PauseSpeech\n");
545#endif
546
547 int speechTab = MMget(m, 0);
548 if (speechTab == NIL)
549 {
550 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
551 MMset(m, 0, NIL);
552 return 0;
553 }
554
555#ifdef SPEECH_USE_SAPI
556 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
557 if (!objSpeech)
558 {
559 MMset(m, 0, NIL);
560 return 0;
561 }
562
563 objSpeech->pause(true);
564
565 MMset(m, 0, ITOM(1));
566#else
567 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
568 MMset(m, 0, NIL);
569 return 0;
570#endif
571
572#ifdef _SCOL_DEBUG_
573 MMechostr(MSKDEBUG, "ok\n");
574#endif
575 return 0;
576}
577
578
588int _ResumeSpeech(mmachine m)
589{
590#ifdef _SCOL_DEBUG_
591 MMechostr(MSKDEBUG, "_PauseSpeech\n");
592#endif
593
594 int speechTab = MMget(m, 0);
595 if (speechTab == NIL)
596 {
597 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
598 MMset(m, 0, NIL);
599 return 0;
600 }
601
602#ifdef SPEECH_USE_SAPI
603 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
604 if (!objSpeech)
605 {
606 MMset(m, 0, NIL);
607 return 0;
608 }
609
610 objSpeech->pause(false);
611
612 MMset(m, 0, ITOM(1));
613#else
614 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
615 MMset(m, 0, NIL);
616 return 0;
617#endif
618
619#ifdef _SCOL_DEBUG_
620 MMechostr(MSKDEBUG, "ok\n");
621#endif
622 return 0;
623}
624
625
635int _StopSpeech(mmachine m)
636{
637#ifdef _SCOL_DEBUG_
638 MMechostr(MSKDEBUG, "_StopSpeech\n");
639#endif
640
641 int speechTab = MMget(m, 0);
642 if (speechTab == NIL)
643 {
644 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
645 MMset(m, 0, NIL);
646 return 0;
647 }
648
649#ifdef SPEECH_USE_SAPI
650 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
651 if (!objSpeech)
652 {
653 MMset(m, 0, NIL);
654 return 0;
655 }
656
657 objSpeech->stop();
658
659 MMset(m, 0, ITOM(1));
660#else
661 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
662 MMset(m, 0, NIL);
663 return 0;
664#endif
665
666#ifdef _SCOL_DEBUG_
667 MMechostr(MSKDEBUG, "ok\n");
668#endif
669 return 0;
670}
671
672
686int _CBSpeechStart(mmachine m)
687{
688 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_START_CB);
689}
690
691
705int _CBSpeechEnd(mmachine m)
706{
707 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_END_CB);
708}
709
710
722int getSpeechStartCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
723{
724#ifdef _SCOL_DEBUG_
725 MMechostr(MSKDEBUG, "getSpeechStartCb\n");
726#endif
727
728 int k = 0;
729
730#ifdef SPEECH_USE_SAPI
731 Speech* SpeechObj = (Speech*)id;
732 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_START_CB))
733 return 0;
734
735 k = OBJcallreflex(m, 0);
736#endif
737 return k;
738}
739
740
752int getSpeechEndCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
753{
754#ifdef _SCOL_DEBUG_
755 MMechostr(MSKDEBUG, "getSpeechEndCb\n");
756#endif
757
758 int k = 0;
759
760#ifdef SPEECH_USE_SAPI
761 Speech* SpeechObj = (Speech*)id;
762 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_END_CB))
763 return 0;
764
765 k = OBJcallreflex(m, 0);
766#endif
767 return k;
768}
769
770
771
782int _GetSpeechVoices(mmachine m)
783{
784#ifdef _SCOL_DEBUG_
785 MMechostr(MSKDEBUG, "_GetSpeechVoices\n");
786#endif
787
788 std::list <char *>::iterator c1_Iter;
789 unsigned int k;
790
791 int voiceType = MMpull(m);
792 int speechTab = MMpull(m);
793 if ((speechTab == NIL) || (voiceType == NIL))
794 {
795 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
796 MMpush(m, NIL);
797 return 0;
798 }
799
800#ifdef SPEECH_USE_SAPI
801 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
802 if (!objSpeech)
803 {
804 MMpush(m, NIL);
805 return 0;
806 }
807
808 std::list <char*> lParamSp = objSpeech->getVoices(MTOI(voiceType));
809
810 for (c1_Iter = lParamSp.begin(); c1_Iter != lParamSp.end(); c1_Iter++)
811 {
812 if (k = Mpushstrbloc(m, (char*)*c1_Iter))
813 return k;
814 }
815
816 if (MMpush(m, NIL))
817 return MERRMEM;
818
819 for (c1_Iter = lParamSp.begin(); c1_Iter != lParamSp.end(); c1_Iter++)
820 {
821 if (MMpush(m, 2 * 2))
822 return MERRMEM;
823
824 if (k = MBdeftab(m))
825 return k;
826 }
827#else
828 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
829 MMpush(m, NIL);
830 return 0;
831#endif
832
833#ifdef _SCOL_DEBUG_
834 MMechostr(MSKDEBUG, "ok\n");
835#endif
836 return 0;
837}
838
839/*
840int _GetSpeechVoices(mmachine m)
841{
842#ifdef _SCOL_DEBUG_
843 MMechostr(MSKDEBUG,"_GetSpeechVoices\n");
844#endif
845
846 std::list <char *>::iterator c1_Iter;
847 unsigned int k ;
848
849 int speechTab = MMpull(m);
850 if (speechTab == NIL)
851 {
852 MMechostr(MSKDEBUG,"ObjSpeech NIL\n");
853 MMpush(m, NIL);
854 return 0;
855 }
856
857 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
858 if(!objSpeech)
859 {
860 MMpush(m, NIL);
861 return 0;
862 }
863
864 std::list <char*> lParamSp = objSpeech->getVoices(0);
865
866 for (c1_Iter = lParamSp.begin(); c1_Iter != lParamSp.end(); c1_Iter++)
867 {
868 if (k=Mpushstrbloc(m, (char*)*c1_Iter))
869 return k;
870 }
871
872 if (MMpush(m, NIL))
873 return MERRMEM;
874
875 for (c1_Iter = lParamSp.begin(); c1_Iter != lParamSp.end(); c1_Iter++)
876 {
877 if (MMpush(m, 2*2))
878 return MERRMEM;
879
880 if (k=MBdeftab(m))
881 return k;
882 }
883
884#ifdef _SCOL_DEBUG_
885 MMechostr(MSKDEBUG,"ok\n");
886#endif
887 return 0;
888}*/
889
900int _SetSpeechVoice(mmachine m)
901{
902#ifdef _SCOL_DEBUG_
903 MMechostr(MSKDEBUG, "_SetSpeechVoice\n");
904#endif
905
906 int voice = MMpull(m);
907 int speechTab = MMget(m, 0);
908 if (speechTab == NIL)
909 {
910 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
911 MMset(m, 0, NIL);
912 return 0;
913 }
914
915#ifdef SPEECH_USE_SAPI
916 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
917 if (!objSpeech)
918 {
919 MMset(m, 0, NIL);
920 return 0;
921 }
922
923 std::string strVoice = MMstartstr(m, MTOP(voice));
924 if (strVoice.empty())
925 {
926 MMset(m, 0, NIL);
927 return 0;
928 }
929
930 objSpeech->SetSpeechVoice(strVoice);
931 MMset(m, 0, ITOM(1));
932#else
933 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
934 MMset(m, 0, NIL);
935 return 0;
936#endif
937
938#ifdef _SCOL_DEBUG_
939 MMechostr(MSKDEBUG, "ok\n");
940#endif
941 return 0;
942}
943
944
954int _GetSpeechVoice(mmachine m)
955{
956#ifdef _SCOL_DEBUG_
957 MMechostr(MSKDEBUG, "_GetSpeechVoice\n");
958#endif
959
960 int speechTab = MMget(m, 0);
961 if (speechTab == NIL)
962 {
963 MMechostr(MSKDEBUG, "ObjSpeech NIL\n");
964 MMset(m, 0, NIL);
965 return 0;
966 }
967
968#ifdef SPEECH_USE_SAPI
969 Speech* objSpeech = MMgetPointer<Speech*>(m, MTOP(speechTab));
970 if (!objSpeech)
971 {
972 MMset(m, 0, NIL);
973 return 0;
974 }
975
976 std::string voice = objSpeech->getSpeechVoice();
977 if (voice.empty())
978 {
979 MMset(m, 0, NIL);
980 return 0;
981 }
982
983 //remove last param before push
984 MMpull(m);
985 Mpushstrbloc(m, (char*)voice.c_str());
986#else
987 MMechostr(MSKDEBUG, "ObjSpeech Not implemented\n");
988 MMset(m, 0, NIL);
989 return 0;
990#endif
991
992#ifdef _SCOL_DEBUG_
993 MMechostr(MSKDEBUG, "ok\n");
994#endif
995
996 return 0;
997}
998
999
1014int _CBSpeechWord(mmachine m)
1015{
1016 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_WORD_CB);
1017}
1018
1019
1031int getSpeechWordCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1032{
1033#ifdef _SCOL_DEBUG_
1034 MMechostr(MSKDEBUG, "getSpeechWordCb\n");
1035#endif
1036
1037 int k = 0;
1038
1039#ifdef SPEECH_USE_SAPI
1040 Speech* SpeechObj = (Speech*)id;
1041 std::string* word = (std::string*)param;
1042
1043 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_WORD_CB))
1044 {
1045 SAFE_DELETE(word);
1046 return 0;
1047 }
1048
1049 Mpushstrbloc(m, (char*)word->c_str());
1050 k = OBJcallreflex(m, 1);
1051 SAFE_DELETE(word);
1052#endif
1053
1054 return k;
1055}
1056
1057
1072int _CBSpeechText(mmachine m)
1073{
1074 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_TEXT_CB);
1075}
1076
1077
1089int getSpeechTextCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1090{
1091#ifdef _SCOL_DEBUG_
1092 MMechostr(MSKDEBUG, "getSpeechTextCb\n");
1093#endif
1094
1095 int k = 0;
1096
1097#ifdef SPEECH_USE_SAPI
1098 Speech* SpeechObj = (Speech*)id;
1099 std::string* sentence = (std::string*)param;
1100
1101 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_TEXT_CB))
1102 {
1103 SAFE_DELETE(sentence);
1104 return 0;
1105 }
1106
1107 Mpushstrbloc(m, (char*)sentence->c_str());
1108 k = OBJcallreflex(m, 1);
1109 SAFE_DELETE(sentence);
1110#endif
1111
1112 return k;
1113}
1114
1115
1130int _CBSpeechPhoneme(mmachine m)
1131{
1132 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_PHONEME_CB);
1133}
1134
1146int getSpeechPhonemeCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1147{
1148#ifdef _SCOL_DEBUG_
1149 MMechostr(MSKDEBUG, "getSpeechPhonemeCb\n");
1150#endif
1151
1152 int k = 0;
1153#ifdef SPEECH_USE_SAPI
1154
1155 Speech* SpeechObj = (Speech*)id;
1156
1157 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_PHONEME_CB))
1158 return 0;
1159
1160 MMpush(m, ITOM((int)param));
1161 k = OBJcallreflex(m, 1);
1162#endif
1163 return k;
1164}
1165
1166
1181int _CBSpeechViseme(mmachine m)
1182{
1183 return OBJaddreflex(m, OBJSPEECHSCOL, SCOL_SPEECH_VISEME_CB);
1184}
1185
1197int getSpeechVisemeCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1198{
1199#ifdef _SCOL_DEBUG_
1200 MMechostr(MSKDEBUG, "getSpeechVisemeCb\n");
1201#endif
1202
1203 int k = 0;
1204
1205#ifdef SPEECH_USE_SAPI
1206 Speech* SpeechObj = (Speech*)id;
1207
1208 if (OBJbeginreflex(m, OBJSPEECHSCOL, SCOL_PTR SpeechObj, SCOL_SPEECH_VISEME_CB))
1209 return 0;
1210
1211 MMpush(m, ITOM((int)param));
1212 k = OBJcallreflex(m, 1);
1213#endif
1214
1215 return k;
1216}
1217
1218
1235int _CRRecognition(mmachine m)
1236{
1237#ifdef _SCOL_DEBUG_
1238 MMechostr(MSKDEBUG, "_CRRecognition\n");
1239#endif
1240
1241 MMechostr(MSKRUNTIME, "_CRRecognition is deprecated, use _CRRecognition2 instead.\n");
1242
1243 Recognition* newRecognition = new Recognition();
1244 if (!newRecognition)
1245 {
1246 MMset(m, 0, NIL);
1247 return 0;
1248 }
1249
1250 if (!newRecognition->initializeObjects())
1251 {
1252 SAFE_DELETE(newRecognition);
1253 MMset(m, 0, NIL);
1254 return 0;
1255 }
1256
1257 if ((MMpushPointer(m, newRecognition) != 0))
1258 {
1259 SAFE_DELETE(newRecognition);
1260 MMset(m, 0, NIL);
1261 return MERRMEM;
1262 }
1263
1264 int k = 0;
1265 k = OBJcreate(m, OBJRECOSCOL, SCOL_PTR newRecognition, 0, 0);
1266
1267#ifdef _SCOL_DEBUG_
1268 MMechostr(MSKDEBUG, "ok\n");
1269#endif
1270
1271 return k;
1272}
1273
1274
1287int _CRRecognition2(mmachine m)
1288{
1289#ifdef _SCOL_DEBUG_
1290 MMechostr(MSKDEBUG, "_CRRecognition2\n");
1291#endif
1292
1293 int ilang = MMpull(m);
1294 int ibin = MMpull(m);
1295
1296 if ((ibin == NIL) || (ilang == NIL))
1297 {
1298 MMset(m, 0, NIL);
1299 return 0;
1300 }
1301
1302 std::string binpath = MMstartstr(m, MTOP(ibin));
1303 std::string lang = MMstartstr(m, MTOP(ilang));
1304
1305 Recognition* newRecognition = new Recognition(binpath, lang);
1306 if (!newRecognition)
1307 {
1308 MMset(m, 0, NIL);
1309 return 0;
1310 }
1311
1312 if (!newRecognition->initializeObjects())
1313 {
1314 SAFE_DELETE(newRecognition);
1315 MMset(m, 0, NIL);
1316 return 0;
1317 }
1318
1319 if ((MMpushPointer(m, newRecognition) != 0))
1320 {
1321 SAFE_DELETE(newRecognition);
1322 MMset(m, 0, NIL);
1323 return MERRMEM;
1324 }
1325
1326 int k = 0;
1327 k = OBJcreate(m, OBJRECOSCOL, SCOL_PTR newRecognition, 0, 0);
1328
1329#ifdef _SCOL_DEBUG_
1330 MMechostr(MSKDEBUG, "ok\n");
1331#endif
1332
1333 return k;
1334}
1335
1349{
1350#ifdef _SCOL_DEBUG_
1351 MMechostr(MSKDEBUG, "_FillRecognitionBuffer\n");
1352#endif
1353
1354#ifdef RECO_USE_SAPI
1355 MMechostr(MSKDEBUG, "Not implemented with SAPI!\n");
1356 MMset(m, 0, NIL);
1357 return 0;
1358#else
1359 int iBuff = MMpull(m);
1360 int recognitionTab = MMget(m, 0);
1361 if (recognitionTab == NIL)
1362 {
1363 MMechostr(MSKDEBUG, "ObjRecognition NIL\n");
1364 MMset(m, 0, NIL);
1365 return 0;
1366 }
1367
1368 if (iBuff == NIL)
1369 {
1370 MMechostr(MSKDEBUG, "ObjRecognition buffer is NIL\n");
1371 MMset(m, 0, NIL);
1372 return 0;
1373 }
1374
1375 Recognition* ObjRecognition = MMgetPointer<Recognition*>(m, MTOP(recognitionTab));
1376 if (!ObjRecognition)
1377 {
1378 MMset(m, 0, NIL);
1379 return 0;
1380 }
1381
1382 iBuff = MTOP(iBuff);
1383 unsigned int msize = MMsizestr(m, iBuff);
1384 const char* data = (char*)MMstart(m, (iBuff)+1);
1385
1386 ObjRecognition->fillAudioBuffer(data, msize);
1387 MMset(m, 0, ITOM(1));
1388
1389#ifdef _SCOL_DEBUG_
1390 MMechostr(MSKDEBUG, "ok\n");
1391#endif
1392
1393 return 0;
1394#endif
1395}
1396
1405int destroyRecognitionObj(mmachine m, SCOL_PTR_TYPE handsys, int recognitionTab)
1406{
1407#ifdef _SCOL_DEBUG_
1408 MMechostr(MSKDEBUG, "destroyRecognitionObj\n");
1409#endif
1410
1411 Recognition* RecognitionObj = MMgetPointer<Recognition*>(m, MTOP(recognitionTab));
1412 SAFE_DELETE(RecognitionObj);
1413
1414 MMsetPointer<Recognition*>(m, MTOP(recognitionTab), 0);
1415 MMechostr(MSKDEBUG, "ObjRecognition destroyed.\n");
1416 return 0;
1417}
1418
1419
1429int _DSRecognition(mmachine m)
1430{
1431#ifdef _SCOL_DEBUG_
1432 MMechostr(MSKDEBUG, "_DSRecognition\n");
1433#endif
1434
1435 int recognotionTab = MMget(m, 0);
1436 if (recognotionTab == NIL)
1437 {
1438 MMset(m, 0, NIL);
1439 return 0;
1440 }
1441
1442 OBJdelTM(m, OBJRECOSCOL, recognotionTab);
1443 MMset(m, 0, ITOM(1));
1444
1445#ifdef _SCOL_DEBUG_
1446 MMechostr(MSKDEBUG, "ok\n");
1447#endif
1448 return 0;
1449}
1450
1451
1465int _CBRecognitionEnd(mmachine m)
1466{
1467 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_END_CB);
1468}
1469
1470
1482int getRecognitionEndCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1483{
1484#ifdef _SCOL_DEBUG_
1485 MMechostr(MSKDEBUG, "getRecognitionEndCb\n");
1486#endif
1487
1488 int k = 0;
1489 Recognition* RecognitionObj = (Recognition*)id;
1490
1491 if (OBJbeginreflex(m, OBJRECOSCOL, SCOL_PTR RecognitionObj, SCOL_RECO_END_CB))
1492 return 0;
1493
1494 k = OBJcallreflex(m, 0);
1495 return k;
1496}
1497
1498
1512int _CBRecognitionStart(mmachine m)
1513{
1514 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_START_CB);
1515}
1516
1517
1529int getRecognitionStartCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1530{
1531#ifdef _SCOL_DEBUG_
1532 MMechostr(MSKDEBUG, "getRecognitionStartCb\n");
1533#endif
1534
1535 int k = 0;
1536 Recognition* RecognitionObj = (Recognition*)id;
1537
1538 if (OBJbeginreflex(m, OBJRECOSCOL, SCOL_PTR RecognitionObj, SCOL_RECO_START_CB))
1539 return 0;
1540
1541 k = OBJcallreflex(m, 0);
1542 return k;
1543}
1544
1545
1560int _CBRecognitionText(mmachine m)
1561{
1562 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_TEXT_CB);
1563}
1564
1565
1577int getRecognitionTextCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1578{
1579#ifdef _SCOL_DEBUG_
1580 MMechostr(MSKDEBUG, "getRecognitionTextCb\n");
1581#endif
1582
1583 int k = 0;
1584 cbData* cbdata = (cbData*)param;
1585 Recognition* RecognitionObj = (Recognition*)id;
1586 std::string data = cbdata->getParamChar();
1587
1588 if (OBJbeginreflex(m, OBJRECOSCOL, SCOL_PTR RecognitionObj, SCOL_RECO_TEXT_CB))
1589 {
1590 SAFE_DELETE(cbdata);
1591 return 0;
1592 }
1593
1594 Mpushstrbloc(m, (char*)data.c_str());
1595 k = OBJcallreflex(m, 1);
1596 SAFE_DELETE(cbdata);
1597 return k;
1598}
1599
1600
1616{
1617 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_TEXTS_ALT_CB);
1618}
1619
1620
1632int getRecognitionTextsAltCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1633{
1634#ifdef _SCOL_DEBUG_
1635 MMechostr(MSKDEBUG, "getRecognitionTextsAltCb\n");
1636#endif
1637
1638 int k = 0;
1639 int nb = 0;
1640
1641 cbData* cbdata = (cbData*)param;
1642 Recognition* RecognitionObj = (Recognition *)id;
1643 if (OBJbeginreflex(m, OBJRECOSCOL, SCOL_PTR RecognitionObj, SCOL_RECO_TEXTS_ALT_CB))
1644 {
1645 SAFE_DELETE(cbdata);
1646 return 0;
1647 }
1648
1649 std::list<pTextRec*> lParamText = cbdata->getlParamText();
1650 std::list<pTextRec*>::iterator iText = lParamText.begin();
1651 while (iText != lParamText.end())
1652 {
1653 nb++;
1654 pTextRec* val = (*iText);
1655 if (Mpushstrbloc(m, (char*)val->altText.c_str()))
1656 {
1657 SAFE_DELETE(cbdata);
1658 return MERRMEM;
1659 }
1660 if (MMpush(m, FTOM(val->altConfidence)))
1661 {
1662 SAFE_DELETE(cbdata);
1663 return MERRMEM;
1664 }
1665 if (MMpush(m, 4))
1666 {
1667 SAFE_DELETE(cbdata);
1668 return MERRMEM;
1669 }
1670
1671 MBdeftab(m);
1672 iText++;
1673 }
1674
1675 if (MMpush(m, NIL))
1676 {
1677 SAFE_DELETE(cbdata);
1678 return MERRMEM;
1679 }
1680
1681 for (int i = 0; i < nb; i++)
1682 {
1683 if (MMpush(m, 2 * 2))
1684 {
1685 SAFE_DELETE(cbdata);
1686 return MERRMEM;
1687 }
1688
1689 if ((k = MBdeftab(m)))
1690 {
1691 SAFE_DELETE(cbdata);
1692 return k;
1693 }
1694 }
1695
1696 k = OBJcallreflex(m, 1);
1697 SAFE_DELETE(cbdata);
1698 return k;
1699}
1700
1701
1716/*
1717int _CBRecognitionWords(mmachine m)
1718{
1719 return OBJaddreflex(m, OBJRECOSCOL, SCOL_RECO_WORDS_CB);
1720}
1721*/
1722
1723/*
1724int getRecognitionWordsCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
1725{
1726 std::list <char*>::iterator c1_Iter;
1727 int k = 0;
1728 cbData * cbdata = (cbData *) param;
1729 Recognition * RecognitionObj =(Recognition *) id;
1730 std::list <char*> lParamWords = cbdata->getlParamWords();
1731
1732 // OBJbeginreflex(mmachine, objecttype, objectptr, cbtype)
1733 if (OBJbeginreflex(m, OBJRECOSCOL, (int)RecognitionObj, SCOL_RECO_WORDS_CB))
1734 return 0;
1735
1736
1737 //MMpull(m);
1738 for ( c1_Iter = lParamWords.begin( ); c1_Iter != lParamWords.end( ); c1_Iter++ )
1739 {
1740 if (k=Mpushstrbloc(m,(char*)*c1_Iter)) return k;
1741 }
1742 if (MMpush(m,NIL)) return MERRMEM;
1743 for ( c1_Iter = lParamWords.begin( ); c1_Iter != lParamWords.end( ); c1_Iter++ )
1744 {
1745 if (MMpush(m,2*2)) return MERRMEM;
1746 if (k=MBdeftab(m)) return k;
1747 }
1748
1749 // OBJcallreflex(mmachine, nbparam)
1750 if ((k=OBJcallreflex(m, 1))) return k;
1751
1752 SAFE_DELETE(cbdata);
1753 return k;
1754}
1755*/
1767{
1768#ifdef _SCOL_DEBUG_
1769 MMechostr(MSKDEBUG, "_SetRecogntionVolume\n");
1770#endif
1771
1772 int vol = MMpull(m);
1773 int recognitionTab = MMget(m, 0);
1774 if (recognitionTab == NIL)
1775 {
1776 MMechostr(MSKDEBUG, "ObjRecognition NIL\n");
1777 MMset(m, 0, NIL);
1778 return 0;
1779 }
1780
1781 Recognition* ObjRecognition = MMgetPointer<Recognition*>(m, MTOP(recognitionTab));
1782 if (!ObjRecognition)
1783 {
1784 MMset(m, 0, NIL);
1785 return 0;
1786 }
1787
1788 int volume = 0;
1789 if ((vol != NIL) && (MTOI(vol) > 0))
1790 volume = MTOI(vol);
1791
1792 ObjRecognition->setVolume(volume);
1793 MMset(m, 0, ITOM(1));
1794
1795#ifdef _SCOL_DEBUG_
1796 MMechostr(MSKDEBUG, "ok\n");
1797#endif
1798 return 0;
1799}
1800
1801
1812{
1813#ifdef _SCOL_DEBUG_
1814 MMechostr(MSKDEBUG, "_GetRecogntionVolume\n");
1815#endif
1816
1817 int recognitionTab = MMget(m, 0);
1818 if (recognitionTab == NIL)
1819 {
1820 MMechostr(MSKDEBUG, "ObjRecognition NIL\n");
1821 MMset(m, 0, NIL);
1822 return 0;
1823 }
1824
1825 Recognition* ObjRecognition = MMgetPointer<Recognition*>(m, MTOP(recognitionTab));
1826 if (!ObjRecognition)
1827 {
1828 MMset(m, 0, NIL);
1829 return 0;
1830 }
1831
1832 MMset(m, 0, ITOM(ObjRecognition->getVolume()));
1833
1834#ifdef _SCOL_DEBUG_
1835 MMechostr(MSKDEBUG, "ok\n");
1836#endif
1837
1838 return 0;
1839}
1840
1841
1853int _AddRecognitionWord(mmachine m)
1854{
1855#ifdef _SCOL_DEBUG_
1856 MMechostr(MSKDEBUG, "_AddRecognitionWord\n");
1857#endif
1858
1859 int textWord = MMpull(m);
1860 int textRule = MMpull(m);
1861
1862 if ((textWord == NIL) || (textRule == NIL))
1863 {
1864 MMset(m, 0, NIL);
1865 return 0;
1866 }
1867
1868 int recognitionTab = MMget(m, 0);
1869 if (recognitionTab == NIL)
1870 {
1871 MMechostr(MSKDEBUG, "ObjRecognition NIL\n");
1872 MMset(m, 0, NIL);
1873 return 0;
1874 }
1875
1876 Recognition* ObjRecognition = MMgetPointer<Recognition*>(m, MTOP(recognitionTab));
1877 if (!ObjRecognition)
1878 {
1879 MMset(m, 0, NIL);
1880 return 0;
1881 }
1882
1883 std::string strRule = (char*)MMstartstr(m, MTOP(textRule));
1884 std::string strWord = (char*)MMstartstr(m, MTOP(textWord));
1885
1886 if (strRule.empty() || strWord.empty())
1887 {
1888 MMset(m, 0, NIL);
1889 return 0;
1890 }
1891
1892 ObjRecognition->AddWord(strRule, strWord);
1893 MMset(m, 0, ITOM(1));
1894
1895#ifdef _SCOL_DEBUG_
1896 MMechostr(MSKDEBUG, "ok\n");
1897#endif
1898 return 0;
1899}
1900
1901
1905NativeDefinition natSpeech[] = {
1906 { "ObjSpeech", TYPTYPE, NULL, NULL },
1907 { "ObjRecognition", TYPTYPE, NULL, NULL },
1908 { "_CRSpeech", 1, "fun [Chn] ObjSpeech", _CRSpeech },
1909 { "_DSSpeech", 1, "fun [ObjSpeech] I", _DSSpeech },
1910 { "_SetSpeechText", 2, "fun [ObjSpeech S] I", _SetSpeechText },
1911 { "_SetSpeechVolume", 2, "fun [ObjSpeech I] I", _SetSpeechVolume },
1912 { "_GetSpeechVolume", 1, "fun [ObjSpeech] I", _GetSpeechVolume },
1913 { "_SetSpeechRate", 2, "fun [ObjSpeech I] I", _SetSpeechRate },
1914 { "_GetSpeechRate", 1, "fun [ObjSpeech] I", _GetSpeechRate },
1915 { "_PlaySpeech", 1, "fun [ObjSpeech] I", _PlaySpeech },
1916 { "_PauseSpeech", 1, "fun [ObjSpeech] I", _PauseSpeech },
1917 { "_ResumeSpeech", 1, "fun [ObjSpeech] I", _ResumeSpeech },
1918 { "_StopSpeech", 1, "fun [ObjSpeech] I", _StopSpeech },
1919 { "_CBSpeechStart", 3, "fun [ObjSpeech fun [ObjSpeech u0] u1 u0] ObjSpeech", _CBSpeechStart },
1920 { "_CBSpeechEnd", 3, "fun [ObjSpeech fun [ObjSpeech u0] u1 u0] ObjSpeech", _CBSpeechEnd },
1921 { "_GetSpeechVoices", 2, "fun [ObjSpeech I] [S r1]", _GetSpeechVoices },
1922 { "_GetSpeechVoice", 1, "fun [ObjSpeech] S", _GetSpeechVoice },
1923 { "_SetSpeechVoice", 2, "fun [ObjSpeech S] I", _SetSpeechVoice },
1924 { "_CBSpeechWord", 3, "fun [ObjSpeech fun [ObjSpeech u0 S] u1 u0] ObjSpeech", _CBSpeechWord },
1925 { "_CBSpeechText", 3, "fun [ObjSpeech fun [ObjSpeech u0 S] u1 u0] ObjSpeech", _CBSpeechText },
1926 { "_CBSpeechPhoneme", 3, "fun [ObjSpeech fun [ObjSpeech u0 I] u1 u0] ObjSpeech", _CBSpeechPhoneme },
1927 { "_CBSpeechViseme", 3, "fun [ObjSpeech fun [ObjSpeech u0 I] u1 u0] ObjSpeech", _CBSpeechViseme },
1928
1929 { "_CRRecognition", 1, "fun [Chn] ObjRecognition", _CRRecognition },
1930 { "_CRRecognition2", 3, "fun [Chn P S] ObjRecognition", _CRRecognition2 },
1931 { "_DSRecognition", 1, "fun [ObjRecognition] I", _DSRecognition },
1932 { "_FillRecognitionBuffer", 2, "fun [ObjRecognition S] I", _FillRecognitionBuffer },
1933 { "_CBRecognitionEnd", 3, "fun [ObjRecognition fun [ObjRecognition u0] u1 u0] ObjRecognition", _CBRecognitionEnd },
1934 { "_CBRecognitionText", 3, "fun [ObjRecognition fun [ObjRecognition u0 S] u1 u0] ObjRecognition", _CBRecognitionText },
1935 { "_CBRecognitionTextsAlt", 3, "fun [ObjRecognition fun [ObjRecognition u0 [[S F] r1]] u1 u0] ObjRecognition", _CBRecognitionTextsAlt },
1936 { "_CBRecognitionStart", 3, "fun [ObjRecognition fun [ObjRecognition u0] u1 u0] ObjRecognition", _CBRecognitionStart },
1937 { "_SetRecogntionVolume", 2, "fun [ObjRecognition I] I", _SetRecogntionVolume },
1938 { "_GetRecogntionVolume", 1, "fun [ObjRecognition] I", _GetRecogntionVolume },
1939 { "_AddRecognitionWord", 3, "fun [ObjRecognition S S] I", _AddRecognitionWord }
1940};
1941
1942
1947int LoadSpeech(mmachine m)
1948{
1949 int k;
1950
1951 //SPEECH
1952 OBJSPEECHSCOL = OBJregister(6, 1, destroySpeechObj, "OBJSPEECHSCOL");
1953
1954 SPEECH_START_CB = OBJgetUserEvent();
1955 OBJdefEvent(SPEECH_START_CB, getSpeechStartCb);
1956
1957 SPEECH_END_CB = OBJgetUserEvent();
1958 OBJdefEvent(SPEECH_END_CB, getSpeechEndCb);
1959
1960 SPEECH_WORD_CB = OBJgetUserEvent();
1961 OBJdefEvent(SPEECH_WORD_CB, getSpeechWordCb);
1962
1963 SPEECH_TEXT_CB = OBJgetUserEvent();
1964 OBJdefEvent(SPEECH_TEXT_CB, getSpeechTextCb);
1965
1966 SPEECH_PHONEME_CB = OBJgetUserEvent();
1968
1969 SPEECH_VISEME_CB = OBJgetUserEvent();
1970 OBJdefEvent(SPEECH_VISEME_CB, getSpeechVisemeCb);
1971
1972 //RECO
1973 OBJRECOSCOL = OBJregister(4, 1, destroyRecognitionObj, "OBJRECOSCOL");
1974
1975 RECOGNITION_END_CB = OBJgetUserEvent();
1977
1978 RECOGNITION_TEXT_CB = OBJgetUserEvent();
1980
1981 RECOGNITION_TEXTS_ALT_CB = OBJgetUserEvent();
1983
1984 //RECOGNITION_WORDS_CB = OBJgetUserEvent() ;
1985 //OBJdefEvent( RECOGNITION_WORDS_CB, getRecognitionWordsCb);
1986
1987 RECOGNITION_START_CB = OBJgetUserEvent();
1989
1990 return PKhardpak2(m, "SpeechEngine", sizeof(natSpeech) / sizeof(natSpeech[0]), natSpeech);
1991
1992#ifdef SPEECH_USE_SAPI
1993 if (FAILED(::CoInitialize(NULL)))
1994 return 0;
1995#endif
1996
1997 return k;
1998}
1999
2000
2004#ifndef SCOL_STATIC
2005extern "C" SCOL_EXPORT int ScolLoadPlugin(mmachine m, cbmachine w)
2006#else
2007extern "C" SCOL_EXPORT int ScolSpeechLoadPlugin(mmachine m, cbmachine w)
2008#endif
2009{
2010 int k = 0;
2011 SCOLinitplugin(w);
2012 LoadSpeech(m);
2013 return k;
2014}
2015
2016
2020#ifndef SCOL_STATIC
2021extern "C" SCOL_EXPORT int ScolUnloadPlugin()
2022#else
2023extern "C" SCOL_EXPORT int ScolSpeechUnloadPlugin()
2024#endif
2025{
2026#ifdef SPEECH_USE_SAPI
2027 ::CoUninitialize();
2028#endif
2029
2030 return 0;
2031}
2032
2033// Everything inside _cond and _endcond is ignored by doxygen
Management of the recognition class .
Definition reco.h:50
void setVolume(int volume)
Set The volume for the recognition.
Definition reco.cpp:340
void AddWord(std::string s_Rule, std::string s_Word)
Add word to recognition.
Definition reco.cpp:66
void fillAudioBuffer(const char *data, size_t lenght)
bool initializeObjects()
Init Recognition Objects.
Definition reco.cpp:123
int getVolume()
Get The volume from recognition.
Definition reco.cpp:327
void SetSpeechVoice(std::string voice)
To set the speech voice.
Definition speech.cpp:366
void stop()
To stop the speech instance.
Definition speech.cpp:238
std::string getSpeechVoice()
To get the speech voice.
Definition speech.cpp:411
std::list< char * > getVoices(int voiceType)
To get the speech voices.
Definition speech.cpp:313
int getVolumeSpeech()
To get the speech volume.
Definition speech.cpp:271
void SetSpeechText(std::string text)
To set the speech text.
Definition speech.cpp:168
void setRateSpeech(int rateSpeech)
To set the speech rate.
Definition speech.cpp:306
void setVolumeSpeech(int volumeSpeech)
To set the speech volume.
Definition speech.cpp:285
int getRateSpeech()
To get the speech rate.
Definition speech.cpp:292
void play()
To play the speech instance.
Definition speech.cpp:175
void pause(bool state)
To pause/resume the speech instance.
Definition speech.cpp:214
std::list< pTextRec * > getlParamText()
std::string getParamChar()
int _DSRecognition(mmachine m)
n_DSRecognition : destroy recognition instance
Definition plugin.cpp:1429
int _CRRecognition(mmachine m)
_CRRecognition : create recognition instance
Definition plugin.cpp:1235
int _CRRecognition2(mmachine m)
_CRRecognition2 : create recognition instance
Definition plugin.cpp:1287
int _CBRecognitionEnd(mmachine m)
_CBRecognitionEnd : set callback end of recognition
Definition plugin.cpp:1465
int _GetRecogntionVolume(mmachine m)
_GetRecogntionVolume : Get recognition volume
Definition plugin.cpp:1811
int _CBRecognitionTextsAlt(mmachine m)
_CBRecognitionTextsAlt : Set callback on recognition texts alternates
Definition plugin.cpp:1615
int _FillRecognitionBuffer(mmachine m)
_FillRecognitionBuffer : fill recognition audio buffer
Definition plugin.cpp:1348
int _AddRecognitionWord(mmachine m)
_AddRecognitionWord : add recogntion word to dictionary
Definition plugin.cpp:1853
int _CBRecognitionText(mmachine m)
_CBRecognitionText : Set callback on recognition text
Definition plugin.cpp:1560
int _SetRecogntionVolume(mmachine m)
_CBRecognitionWords : Set callback on recognition words
Definition plugin.cpp:1766
int _CBRecognitionStart(mmachine m)
_CBRecognitionStart : set callback start of recognition
Definition plugin.cpp:1512
int _SetSpeechVolume(mmachine m)
_SetSpeechVolume : Set speech volume
Definition plugin.cpp:302
int _GetSpeechVoice(mmachine m)
_GetSpeechVoice : get speech voice
Definition plugin.cpp:954
int _ResumeSpeech(mmachine m)
_ResumeSpeech : resume speech
Definition plugin.cpp:588
int _CBSpeechEnd(mmachine m)
n_CBSpeechEnd : set callback end of speech
Definition plugin.cpp:705
int _CRSpeech(mmachine m)
_CRSpeech : create speech instance
Definition plugin.cpp:170
int _CBSpeechViseme(mmachine m)
_CBSpeechViseme : set callback on speech viseme
Definition plugin.cpp:1181
int _SetSpeechRate(mmachine m)
_SetSpeechRate : set speech rate
Definition plugin.cpp:400
int _SetSpeechText(mmachine m)
_SetSpeechText : Set speech Text
Definition plugin.cpp:250
int _StopSpeech(mmachine m)
_StopSpeech : Stop speech
Definition plugin.cpp:635
int _CBSpeechWord(mmachine m)
_CBSpeechWord : Set callback on speech word
Definition plugin.cpp:1014
int _PlaySpeech(mmachine m)
_PlaySpeech : play speech
Definition plugin.cpp:494
int _CBSpeechText(mmachine m)
_CBSpeechText : Set callback on speech text
Definition plugin.cpp:1072
int _SetSpeechVoice(mmachine m)
_SetSpeechVoice : set speech voice
Definition plugin.cpp:900
int _GetSpeechVolume(mmachine m)
_GetSpeechVolume : Get speech volume
Definition plugin.cpp:354
int _DSSpeech(mmachine m)
_DSSpeech : destroy speech instance
Definition plugin.cpp:216
int _GetSpeechVoices(mmachine m)
_GetSpeechVoices : get speech voices
Definition plugin.cpp:782
int _CBSpeechStart(mmachine m)
n_CBSpeechStart : set callback 'start of speech'
Definition plugin.cpp:686
int _CBSpeechPhoneme(mmachine m)
_CBSpeechPhoneme : set callback on speech phoneme
Definition plugin.cpp:1130
int _PauseSpeech(mmachine m)
_PauseSpeech : pause speech
Definition plugin.cpp:541
int _GetSpeechRate(mmachine m)
_GetSpeechRate : get speech rate
Definition plugin.cpp:448
int getSpeechStartCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech start event callback.
Definition plugin.cpp:722
int SCOL_RECO_TEXT_CB
Definition plugin.cpp:101
int getSpeechTextCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech text event callback.
Definition plugin.cpp:1089
int destroySpeechObj(mmachine m, SCOL_PTR_TYPE handsys, int speechTab)
Utils Conversions.
Definition plugin.cpp:144
int LoadSpeech(mmachine m)
Load the packages in Scol virtual machine.
Definition plugin.cpp:1947
int SPEECH_PHONEME_CB
Definition plugin.cpp:91
SCOL_EXPORT int ScolLoadPlugin(mmachine m, cbmachine w)
Starting point of the DLL.
Definition plugin.cpp:2005
int SCOL_RECO_WORDS_CB
Definition plugin.cpp:110
int SCOL_SPEECH_TEXT_CB
Definition plugin.cpp:87
int getRecognitionEndCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the recognition end event callback.
Definition plugin.cpp:1482
int SCOL_RECO_TEXTS_ALT_CB
Definition plugin.cpp:107
int RECOGNITION_TEXT_CB
Definition plugin.cpp:102
int OBJSPEECHSCOL
global object declaration
Definition plugin.cpp:73
int getRecognitionTextsAltCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the recognition alternates text event callback.
Definition plugin.cpp:1632
int SCOL_SPEECH_END_CB
Definition plugin.cpp:81
NativeDefinition natSpeech[]
Definition plugin.cpp:1905
int RECOGNITION_START_CB
Definition plugin.cpp:105
int getSpeechWordCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech word event callback.
Definition plugin.cpp:1031
int SCOL_SPEECH_VISEME_CB
Definition plugin.cpp:93
cbmachine ww
Main include.
Definition plugin.cpp:68
int getRecognitionTextCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the recognition text event callback.
Definition plugin.cpp:1577
int SCOL_SPEECH_START_CB
global Callback declaration for text to speech
Definition plugin.cpp:78
int OBJRECOSCOL
Definition plugin.cpp:74
SCOL_EXPORT int ScolUnloadPlugin()
Ending point of the DLL.
Definition plugin.cpp:2021
int SCOL_SPEECH_WORD_CB
Definition plugin.cpp:84
int getSpeechEndCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech end event callback.
Definition plugin.cpp:752
int destroyRecognitionObj(mmachine m, SCOL_PTR_TYPE handsys, int recognitionTab)
function to destroy an OBJRECOSCOL in scol
Definition plugin.cpp:1405
int RECOGNITION_TEXTS_ALT_CB
Definition plugin.cpp:108
int getSpeechVisemeCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech viseme event callback.
Definition plugin.cpp:1197
int SPEECH_WORD_CB
Definition plugin.cpp:85
int getRecognitionStartCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the recognition start event callback.
Definition plugin.cpp:1529
int RECOGNITION_WORDS_CB
Definition plugin.cpp:111
int SPEECH_VISEME_CB
Definition plugin.cpp:94
int SCOL_SPEECH_PHONEME_CB
Definition plugin.cpp:90
int SCOL_RECO_END_CB
global Callback declaration for recognition
Definition plugin.cpp:98
int RECOGNITION_END_CB
Definition plugin.cpp:99
int SPEECH_END_CB
Definition plugin.cpp:82
int getSpeechPhonemeCb(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
C function that prepares the VM for the execution of the speech phoneme event callback.
Definition plugin.cpp:1146
int SCOL_RECO_START_CB
Definition plugin.cpp:104
mmachine mm
Definition plugin.cpp:69
int SPEECH_START_CB
Definition plugin.cpp:79
int SPEECH_TEXT_CB
Definition plugin.cpp:88
wchar_t * convertCharToLPCWSTR(char *s_text)
Utils Conversions.
char * convertWcharToChar(wchar_t *w_text)