Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * SpeechSynthInterface.h - Fawkes BlackBoard Interface - SpeechSynthInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2008 Tim Niemueller 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_SPEECHSYNTHINTERFACE_H_ 00025 #define __INTERFACES_SPEECHSYNTHINTERFACE_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 SpeechSynthInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(SpeechSynthInterface) 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 msgid; /**< 00051 The ID of the message that is currently being processed, 00052 or 0 if no message is being processed. 00053 */ 00054 bool final; /**< 00055 True, if the last text has been spoken, false if it is still running. 00056 */ 00057 float duration; /**< 00058 Length in seconds that it takes to speek the current text, -1 if 00059 unknown. This is the total duration of the current string, *not* the 00060 duration of already spoken or yet to speak text! 00061 */ 00062 } SpeechSynthInterface_data_t; 00063 #pragma pack(pop) 00064 00065 SpeechSynthInterface_data_t *data; 00066 00067 public: 00068 /* messages */ 00069 class SayMessage : public Message 00070 { 00071 private: 00072 #pragma pack(push,4) 00073 /** Internal data storage, do NOT modify! */ 00074 typedef struct { 00075 int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */ 00076 int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */ 00077 char text[1024]; /**< 00078 Last spoken string. Must be properly null-terminated. 00079 */ 00080 } SayMessage_data_t; 00081 #pragma pack(pop) 00082 00083 SayMessage_data_t *data; 00084 00085 public: 00086 SayMessage(const char * ini_text); 00087 SayMessage(); 00088 ~SayMessage(); 00089 00090 SayMessage(const SayMessage *m); 00091 /* Methods */ 00092 char * text() const; 00093 void set_text(const char * new_text); 00094 size_t maxlenof_text() const; 00095 virtual Message * clone() const; 00096 }; 00097 00098 virtual bool message_valid(const Message *message) const; 00099 private: 00100 SpeechSynthInterface(); 00101 ~SpeechSynthInterface(); 00102 00103 public: 00104 /* Methods */ 00105 char * text() const; 00106 void set_text(const char * new_text); 00107 size_t maxlenof_text() const; 00108 uint32_t msgid() const; 00109 void set_msgid(const uint32_t new_msgid); 00110 size_t maxlenof_msgid() const; 00111 bool is_final() const; 00112 void set_final(const bool new_final); 00113 size_t maxlenof_final() const; 00114 float duration() const; 00115 void set_duration(const float new_duration); 00116 size_t maxlenof_duration() const; 00117 virtual Message * create_message(const char *type) const; 00118 00119 virtual void copy_values(const Interface *other); 00120 virtual const char * enum_tostring(const char *enumtype, int val) const; 00121 00122 }; 00123 00124 } // end namespace fawkes 00125 00126 #endif