Fawkes API  Fawkes Development Version
SpeechRecognitionInterface.h
1 
2 /***************************************************************************
3  * SpeechRecognitionInterface.h - Fawkes BlackBoard Interface - SpeechRecognitionInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2009 Tim Niemueller and Masrur Doostdar
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _INTERFACES_SPEECHRECOGNITIONINTERFACE_H_
25 #define _INTERFACES_SPEECHRECOGNITIONINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
33 class SpeechRecognitionInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(SpeechRecognitionInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  char text[1024]; /**<
47  Last spoken string. Must be properly null-terminated.
48  */
49  uint32_t counter; /**<
50  Counter for messages. Increased after each new recognized string.
51  */
52  bool processing; /**<
53  True, if the the speech recognition is currently processing.
54  */
55  bool enabled; /**<
56  True, if speech processing is currently enabled, false otherwise.
57  */
58  } SpeechRecognitionInterface_data_t;
59 
60  SpeechRecognitionInterface_data_t *data;
61 
62  public:
63  /* messages */
64  class ResetMessage : public Message
65  {
66  private:
67  /** Internal data storage, do NOT modify! */
68  typedef struct {
69  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
70  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
71  } ResetMessage_data_t;
72 
73  ResetMessage_data_t *data;
74 
75  public:
76  ResetMessage();
77  ~ResetMessage();
78 
79  explicit ResetMessage(const ResetMessage *m);
80  /* Methods */
81  virtual Message * clone() const;
82  };
83 
84  class SetEnabledMessage : public Message
85  {
86  private:
87  /** Internal data storage, do NOT modify! */
88  typedef struct {
89  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
90  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
91  bool enabled; /**<
92  True, if speech processing is currently enabled, false otherwise.
93  */
94  } SetEnabledMessage_data_t;
95 
96  SetEnabledMessage_data_t *data;
97 
98  public:
99  SetEnabledMessage(const bool ini_enabled);
102 
103  explicit SetEnabledMessage(const SetEnabledMessage *m);
104  /* Methods */
105  bool is_enabled() const;
106  void set_enabled(const bool new_enabled);
107  size_t maxlenof_enabled() const;
108  virtual Message * clone() const;
109  };
110 
111  virtual bool message_valid(const Message *message) const;
112  private:
115 
116  public:
117  /* Methods */
118  char * text() const;
119  void set_text(const char * new_text);
120  size_t maxlenof_text() const;
121  uint32_t counter() const;
122  void set_counter(const uint32_t new_counter);
123  size_t maxlenof_counter() const;
124  bool is_processing() const;
125  void set_processing(const bool new_processing);
126  size_t maxlenof_processing() const;
127  bool is_enabled() const;
128  void set_enabled(const bool new_enabled);
129  size_t maxlenof_enabled() const;
130  virtual Message * create_message(const char *type) const;
131 
132  virtual void copy_values(const Interface *other);
133  virtual const char * enum_tostring(const char *enumtype, int val) const;
134 
135 };
136 
137 } // end namespace fawkes
138 
139 #endif
fawkes::SpeechRecognitionInterface::set_processing
void set_processing(const bool new_processing)
Set processing value.
Definition: SpeechRecognitionInterface.cpp:173
fawkes::SpeechRecognitionInterface::SetEnabledMessage
Definition: SpeechRecognitionInterface.h:93
fawkes::SpeechRecognitionInterface::counter
uint32_t counter() const
Get counter value.
Definition: SpeechRecognitionInterface.cpp:116
fawkes::SpeechRecognitionInterface::SetEnabledMessage::is_enabled
bool is_enabled() const
Get enabled value.
Definition: SpeechRecognitionInterface.cpp:353
fawkes::SpeechRecognitionInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: SpeechRecognitionInterface.cpp:233
fawkes::SpeechRecognitionInterface::maxlenof_text
size_t maxlenof_text() const
Get maximum length of text value.
Definition: SpeechRecognitionInterface.cpp:90
fawkes::SpeechRecognitionInterface::ResetMessage::~ResetMessage
~ResetMessage()
Destructor.
Definition: SpeechRecognitionInterface.cpp:268
fawkes::SpeechRecognitionInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: SpeechRecognitionInterface.cpp:395
fawkes::Message
Definition: message.h:40
fawkes::SpeechRecognitionInterface::ResetMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SpeechRecognitionInterface.cpp:292
fawkes::SpeechRecognitionInterface::set_enabled
void set_enabled(const bool new_enabled)
Set enabled value.
Definition: SpeechRecognitionInterface.cpp:208
fawkes::SpeechRecognitionInterface::SetEnabledMessage::SetEnabledMessage
SetEnabledMessage()
Constructor.
Definition: SpeechRecognitionInterface.cpp:317
fawkes::SpeechRecognitionInterface::is_enabled
bool is_enabled() const
Get enabled value.
Definition: SpeechRecognitionInterface.cpp:186
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::SpeechRecognitionInterface::maxlenof_counter
size_t maxlenof_counter() const
Get maximum length of counter value.
Definition: SpeechRecognitionInterface.cpp:126
fawkes::SpeechRecognitionInterface::set_counter
void set_counter(const uint32_t new_counter)
Set counter value.
Definition: SpeechRecognitionInterface.cpp:138
fawkes::SpeechRecognitionInterface::create_message
virtual Message * create_message(const char *type) const
Definition: SpeechRecognitionInterface.cpp:216
fawkes::SpeechRecognitionInterface::SetEnabledMessage::maxlenof_enabled
size_t maxlenof_enabled() const
Get maximum length of enabled value.
Definition: SpeechRecognitionInterface.cpp:363
fawkes
fawkes::SpeechRecognitionInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition: SpeechRecognitionInterface.cpp:244
fawkes::SpeechRecognitionInterface::SetEnabledMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SpeechRecognitionInterface.cpp:386
fawkes::SpeechRecognitionInterface::ResetMessage
Definition: SpeechRecognitionInterface.h:73
fawkes::Interface
Definition: interface.h:77
fawkes::SpeechRecognitionInterface::maxlenof_processing
size_t maxlenof_processing() const
Get maximum length of processing value.
Definition: SpeechRecognitionInterface.cpp:161
fawkes::SpeechRecognitionInterface::text
char * text() const
Get text value.
Definition: SpeechRecognitionInterface.cpp:80
fawkes::SpeechRecognitionInterface::ResetMessage::ResetMessage
ResetMessage()
Constructor.
Definition: SpeechRecognitionInterface.cpp:258
fawkes::SpeechRecognitionInterface::SetEnabledMessage::~SetEnabledMessage
~SetEnabledMessage()
Destructor.
Definition: SpeechRecognitionInterface.cpp:328
fawkes::SpeechRecognitionInterface::SetEnabledMessage::set_enabled
void set_enabled(const bool new_enabled)
Set enabled value.
Definition: SpeechRecognitionInterface.cpp:375
fawkes::SpeechRecognitionInterface
Definition: SpeechRecognitionInterface.h:37
fawkes::SpeechRecognitionInterface::maxlenof_enabled
size_t maxlenof_enabled() const
Get maximum length of enabled value.
Definition: SpeechRecognitionInterface.cpp:196
fawkes::SpeechRecognitionInterface::set_text
void set_text(const char *new_text)
Set text value.
Definition: SpeechRecognitionInterface.cpp:102
fawkes::SpeechRecognitionInterface::is_processing
bool is_processing() const
Get processing value.
Definition: SpeechRecognitionInterface.cpp:151