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
00042
00043
00044
00045 #if !defined(__SPEECHSET_H)
00046 #define __SPEECHSET_H
00047
00048 #include "../OpenTracker.h"
00049
00050 #include "SpeechDef.h"
00051
00065 #ifndef OT_NO_SPEECH_SUPPORT
00066
00067
00068 namespace ot {
00069
00070 class SpeechSetBase
00071 {
00072
00073 protected:
00074 bool m_Active;
00075
00076 std::string m_Name;
00077 DWORD m_Id;
00078 SpeechCoreBase *m_SpeechCore;
00079
00080 std::vector<SSpeechCommand> m_RegisteredCommands;
00081
00082 StringQueue m_RecogizedCommands;
00083
00084
00085
00086 protected:
00088 virtual void Initialize()
00089 {
00090 m_SpeechCore = 0;
00091 m_Active = true;
00092 };
00093
00095 virtual void Destroy()
00096 {
00097 m_SpeechCore = 0;
00098 m_Active = false;
00099 };
00100
00101
00102
00103 protected:
00104 SpeechSetBase(const char *p_Name, DWORD p_Id, SpeechCoreBase *p_SpeechCore)
00105 {
00106 Initialize();
00107 m_Name = p_Name;
00108 m_Id = p_Id;
00109 m_SpeechCore = p_SpeechCore;
00110 }
00111
00112 virtual ~SpeechSetBase()
00113 {
00114 Destroy();
00115 }
00116
00117
00118
00119 public:
00121 DWORD GetId();
00122
00124 virtual const char* GetName();
00125
00126
00128 virtual bool IsCommandRegistered(const char *p_Command);
00129
00131 virtual bool IsCommandIdRegistered(DWORD p_CommandId);
00132
00133
00135 virtual long GetCommandId(const char *p_Command);
00136
00138 virtual bool GetCommand(DWORD p_CommandId, std::string &p_Command);
00139
00140
00142 virtual void AddCommand(const char *p_Command, DWORD p_CommandId = -1, float p_Weight = 1.0f);
00143
00145 virtual void RemoveCommand(const char *p_Command);
00146
00148 virtual void RemoveCommand(DWORD p_CommandId);
00149
00151 virtual bool GetReco(std::string &p_Result)
00152 {
00153 return false;
00154 };
00155
00156
00158 void Activate();
00160 void Deactivate();
00162 bool IsActive();
00163
00164 friend class SpeechCoreBase;
00165 };
00166
00167 }
00168
00169
00170 #ifdef USE_SAPISPEECH
00171
00172
00173
00174
00183 namespace ot {
00184
00185 class CSpeechSet : public SpeechSetBase
00186 {
00187
00188 protected:
00189 bool m_Active;
00190
00191 std::string m_Name;
00192 DWORD m_Id;
00193 CSpeechCore *m_SpeechCore;
00194
00195 std::vector<SSpeechCommand> m_RegisteredCommands;
00196
00197 StringQueue m_RecogizedCommands;
00198
00199
00200
00201 protected:
00202 void Initialize();
00203 void Destroy();
00204
00205
00206
00207 protected:
00208 CSpeechSet(const char *p_Name, DWORD p_Id, CSpeechCore *p_SpeechCore);
00209
00210
00211 virtual ~CSpeechSet()
00212 {
00213 Destroy();
00214 }
00215
00216
00217
00218 protected:
00220 void Recognize(const char *p_String);
00221
00223 void RebuildRule();
00224
00225
00226
00227 public:
00229 DWORD GetId();
00230
00232 const char* GetName();
00233
00234
00236 bool IsCommandRegistered(const char *p_Command);
00237
00239 bool IsCommandIdRegistered(DWORD p_CommandId);
00240
00241
00243 long GetCommandId(const char *p_Command);
00244
00246 bool GetCommand(DWORD p_CommandId, std::string &p_Command);
00247
00248
00250 void AddCommand(const char *p_Command, DWORD p_CommandId = -1, float p_Weight = 1.0f);
00251
00253 void RemoveCommand(const char *p_Command);
00254
00256 void RemoveCommand(DWORD p_CommandId);
00257
00258
00260 bool IsReco();
00261
00263 bool GetReco(std::string &p_Result);
00264
00265
00267 void Activate();
00269 void Deactivate();
00271 bool IsActive();
00272
00273
00274 friend class CSpeechCore;
00275 };
00276
00277 }
00278
00279 #endif //ifdef USE_SAPISPEECH
00280
00281
00282 #endif // OT_NO_SPEECH_SUPPORT
00283
00284
00285 #endif //#if !defined(__SPEECHSET_H)
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301