Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * SpeechRecognitionInterface.h - Fawkes BlackBoard Interface - SpeechRecognitionInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2009 Tim Niemueller and Masrur Doostdar 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __INTERFACES_SPEECHRECOGNITIONINTERFACE_H_ 00025 #define __INTERFACES_SPEECHRECOGNITIONINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class SpeechRecognitionInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(SpeechRecognitionInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 00041 private: 00042 #pragma pack(push,4) 00043 /** Internal data storage, do NOT modify! */ 00044 typedef struct { 00045 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00046 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00047 char text[1024]; /**< 00048 Last spoken string. Must be properly null-terminated. 00049 */ 00050 uint32_t counter; /**< 00051 Counter for messages. Increased after each new recognized string. 00052 */ 00053 bool processing; /**< 00054 True, if the the speech recognition is currently processing. 00055 */ 00056 bool enabled; /**< 00057 True, if speech processing is currently enabled, false otherwise. 00058 */ 00059 } SpeechRecognitionInterface_data_t; 00060 #pragma pack(pop) 00061 00062 SpeechRecognitionInterface_data_t *data; 00063 00064 public: 00065 /* messages */ 00066 class ResetMessage : public Message 00067 { 00068 private: 00069 #pragma pack(push,4) 00070 /** Internal data storage, do NOT modify! */ 00071 typedef struct { 00072 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00073 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00074 } ResetMessage_data_t; 00075 #pragma pack(pop) 00076 00077 ResetMessage_data_t *data; 00078 00079 public: 00080 ResetMessage(); 00081 ~ResetMessage(); 00082 00083 ResetMessage(const ResetMessage *m); 00084 /* Methods */ 00085 virtual Message * clone() const; 00086 }; 00087 00088 class SetEnabledMessage : public Message 00089 { 00090 private: 00091 #pragma pack(push,4) 00092 /** Internal data storage, do NOT modify! */ 00093 typedef struct { 00094 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00095 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00096 bool enabled; /**< 00097 True, if speech processing is currently enabled, false otherwise. 00098 */ 00099 } SetEnabledMessage_data_t; 00100 #pragma pack(pop) 00101 00102 SetEnabledMessage_data_t *data; 00103 00104 public: 00105 SetEnabledMessage(const bool ini_enabled); 00106 SetEnabledMessage(); 00107 ~SetEnabledMessage(); 00108 00109 SetEnabledMessage(const SetEnabledMessage *m); 00110 /* Methods */ 00111 bool is_enabled() const; 00112 void set_enabled(const bool new_enabled); 00113 size_t maxlenof_enabled() const; 00114 virtual Message * clone() const; 00115 }; 00116 00117 virtual bool message_valid(const Message *message) const; 00118 private: 00119 SpeechRecognitionInterface(); 00120 ~SpeechRecognitionInterface(); 00121 00122 public: 00123 /* Methods */ 00124 char * text() const; 00125 void set_text(const char * new_text); 00126 size_t maxlenof_text() const; 00127 uint32_t counter() const; 00128 void set_counter(const uint32_t new_counter); 00129 size_t maxlenof_counter() const; 00130 bool is_processing() const; 00131 void set_processing(const bool new_processing); 00132 size_t maxlenof_processing() const; 00133 bool is_enabled() const; 00134 void set_enabled(const bool new_enabled); 00135 size_t maxlenof_enabled() const; 00136 virtual Message * create_message(const char *type) const; 00137 00138 virtual void copy_values(const Interface *other); 00139 virtual const char * enum_tostring(const char *enumtype, int val) const; 00140 00141 }; 00142 00143 } // end namespace fawkes 00144 00145 #endif